Skip to content

Commit

Permalink
SNOW-1284606 Move running_on_* to tests/utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-azhan committed Jun 5, 2024
1 parent 4e328e3 commit ef4d1c7
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 30 deletions.
17 changes: 2 additions & 15 deletions tests/integ/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,12 @@
from snowflake.snowpark.exceptions import SnowparkSQLException
from snowflake.snowpark.mock._connection import MockServerConnection
from tests.parameters import CONNECTION_PARAMETERS
from tests.utils import Utils
from tests.utils import Utils, running_on_jenkins, running_on_public_ci

RUNNING_ON_GH = os.getenv("GITHUB_ACTIONS") == "true"
RUNNING_ON_JENKINS = "JENKINS_HOME" in os.environ
TEST_SCHEMA = f"GH_JOB_{(str(uuid.uuid4()).replace('-', '_'))}"
if RUNNING_ON_JENKINS:
if running_on_jenkins():
TEST_SCHEMA = f"JENKINS_JOB_{(str(uuid.uuid4()).replace('-', '_'))}"


def running_on_public_ci() -> bool:
"""Whether or not tests are currently running on one of our public CIs."""
return RUNNING_ON_GH


def running_on_jenkins() -> bool:
"""Whether or not tests are currently running on a Jenkins node."""
return RUNNING_ON_JENKINS


def print_help() -> None:
print(
"""Connection parameter must be specified in parameters.py,
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/modin/binary/test_binary_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import snowflake.snowpark.modin.plugin # noqa: F401
from snowflake.snowpark.exceptions import SnowparkSQLException
from snowflake.snowpark.modin.pandas.utils import try_convert_index_to_native
from tests.integ.conftest import running_on_public_ci
from tests.integ.modin.series.test_bitwise_operators import try_cast_to_snow_series
from tests.integ.modin.sql_counter import SqlCounter, sql_count_checker
from tests.integ.modin.utils import (
Expand All @@ -27,6 +26,7 @@
create_test_series,
eval_snowpark_pandas_result,
)
from tests.utils import running_on_public_ci


@pytest.mark.parametrize(
Expand Down
3 changes: 1 addition & 2 deletions tests/integ/modin/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
from pytest import fail

import snowflake.snowpark.modin.plugin # noqa: F401
from tests.integ.conftest import running_on_public_ci
from tests.integ.modin.pandas_api_coverage import PandasAPICoverageGenerator
from tests.integ.modin.sql_counter import (
SqlCounter,
clear_sql_counter_called,
generate_sql_count_report,
is_sql_counter_called,
)
from tests.utils import Utils
from tests.utils import Utils, running_on_public_ci

INTEG_PANDAS_SUBPATH = "tests/integ/modin/"

Expand Down
2 changes: 1 addition & 1 deletion tests/integ/modin/frame/test_iloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import snowflake.snowpark.modin.plugin # noqa: F401
from snowflake.snowpark.exceptions import SnowparkSQLException
from snowflake.snowpark.modin.pandas.utils import try_convert_index_to_native
from tests.integ.conftest import running_on_public_ci
from tests.integ.modin.frame.test_head_tail import eval_result_and_query_with_no_join
from tests.integ.modin.sql_counter import SqlCounter, sql_count_checker
from tests.integ.modin.utils import (
assert_frame_equal,
assert_snowpark_pandas_equal_to_pandas,
eval_snowpark_pandas_result,
)
from tests.utils import running_on_public_ci

# default_index_snowpark_pandas_df and default_index_native_df have size of axis_len x axis_len
AXIS_LEN = 7
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/modin/frame/test_itertuples.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import snowflake.snowpark.modin.plugin # noqa: F401
from snowflake.snowpark.modin.pandas.snow_partition_iterator import PARTITION_SIZE
from tests.integ.conftest import running_on_public_ci
from tests.integ.modin.sql_counter import SqlCounter, sql_count_checker
from tests.integ.modin.utils import eval_snowpark_pandas_result
from tests.utils import running_on_public_ci

# To generate seeded random data.
rng = np.random.default_rng(12345)
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/modin/frame/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import snowflake.snowpark.modin.plugin # noqa: F401
from snowflake.snowpark.exceptions import SnowparkSQLException
from snowflake.snowpark.modin.pandas.utils import try_convert_index_to_native
from tests.integ.conftest import running_on_public_ci
from tests.integ.modin.sql_counter import SqlCounter, sql_count_checker
from tests.integ.modin.utils import (
assert_frame_equal,
Expand All @@ -24,6 +23,7 @@
eval_snowpark_pandas_result,
generate_a_random_permuted_list_exclude_self,
)
from tests.utils import running_on_public_ci

EMPTY_LIST_LIKE_VALUES = [
[],
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/modin/frame/test_transpose.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
from snowflake.snowpark.modin.plugin._internal.unpivot_utils import (
UNPIVOT_NULL_REPLACE_VALUE,
)
from tests.integ.conftest import running_on_public_ci
from tests.integ.modin.sql_counter import SqlCounter, sql_count_checker
from tests.integ.modin.utils import (
assert_snowpark_pandas_equal_to_pandas,
assert_snowpark_pandas_equals_to_pandas_with_coerce_to_float64,
eval_snowpark_pandas_result,
)
from tests.utils import running_on_public_ci

transpose_and_double_transpose_parameterize = pytest.mark.parametrize(
"transpose_operation, expected_query_count",
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/modin/groupby/test_groupby_idxmax_idxmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import pytest

import snowflake.snowpark.modin.plugin # noqa: F401
from tests.integ.conftest import running_on_public_ci
from tests.integ.modin.groupby.conftest import multiindex_data
from tests.integ.modin.sql_counter import sql_count_checker
from tests.integ.modin.utils import (
assert_frame_equal,
create_test_dfs,
eval_snowpark_pandas_result,
)
from tests.utils import running_on_public_ci


@pytest.mark.parametrize("grouping_columns", ["B", ["A", "B"]])
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/modin/groupby/test_quantile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import snowflake.snowpark.modin.plugin # noqa: F401
from snowflake.snowpark.exceptions import SnowparkSQLException
from tests.integ.conftest import running_on_public_ci
from tests.integ.modin.sql_counter import SqlCounter, sql_count_checker
from tests.integ.modin.utils import assert_snowpark_pandas_equal_to_pandas
from tests.utils import running_on_public_ci


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/modin/series/test_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from modin.pandas import Index, MultiIndex, Series

import snowflake.snowpark.modin.plugin # noqa: F401
from tests.integ.conftest import running_on_public_ci
from tests.integ.modin.sql_counter import SqlCounter, sql_count_checker
from tests.integ.modin.utils import assert_index_equal, assert_series_equal
from tests.utils import running_on_public_ci


class TestRename:
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/modin/strings/test_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import snowflake.snowpark.modin.plugin # noqa: F401
from snowflake.snowpark.exceptions import SnowparkSQLException
from tests.integ.conftest import running_on_public_ci
from tests.integ.modin.sql_counter import SqlCounter
from tests.integ.modin.utils import assert_snowpark_pandas_equal_to_pandas
from tests.utils import running_on_public_ci


@pytest.fixture(scope="module", autouse=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/modin/strings/test_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import snowflake.snowpark.modin.plugin # noqa: F401
from snowflake.snowpark.exceptions import SnowparkSQLException
from tests.integ.conftest import running_on_public_ci
from tests.integ.modin.sql_counter import SqlCounter, sql_count_checker
from tests.integ.modin.utils import assert_snowpark_pandas_equal_to_pandas
from tests.utils import running_on_public_ci


# TODO (SNOW-767685): This whole suite is skipped in ci run because those are tests for unsupported
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/modin/strings/test_get_dummies.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from pandas import _testing as tm

import snowflake.snowpark.modin.plugin # noqa: F401
from tests.integ.conftest import running_on_public_ci
from tests.integ.modin.sql_counter import sql_count_checker
from tests.integ.modin.utils import assert_snowpark_pandas_equal_to_pandas
from tests.utils import running_on_public_ci


# TODO (SNOW-767685): This whole suite is skipped in ci run because those are tests for unsupported
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/modin/strings/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

import snowflake.snowpark.modin.plugin # noqa: F401
from snowflake.snowpark.exceptions import SnowparkSQLException
from tests.integ.conftest import running_on_public_ci
from tests.integ.modin.sql_counter import SqlCounter, sql_count_checker
from tests.integ.modin.utils import (
assert_snowpark_pandas_equal_to_pandas,
assert_snowpark_pandas_equals_to_pandas_without_dtypecheck,
eval_snowpark_pandas_result,
)
from tests.utils import running_on_public_ci


# This whole suite is skipped in ci run because those are tests for unsupported
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/modin/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
_get_active_sessions,
_remove_session,
)
from tests.integ.conftest import running_on_jenkins, running_on_public_ci
from tests.integ.modin.sql_counter import sql_count_checker
from tests.integ.modin.utils import create_test_dfs, eval_snowpark_pandas_result
from tests.utils import running_on_jenkins, running_on_public_ci

NO_ACTIVE_SESSION_ERROR_PATTERN = (
r"Snowpark pandas requires an active snowpark session, but there is none. "
Expand Down
17 changes: 17 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import platform
import random
import string
import uuid
from datetime import date, datetime, time
from decimal import Decimal
from typing import List, NamedTuple, Optional, Union
Expand Down Expand Up @@ -89,6 +90,22 @@
ICEBERG_ENVIRONMENTS = {"dev", "aws"}
IS_ICEBERG_SUPPORTED = os.getenv("cloud_provider", "dev") in ICEBERG_ENVIRONMENTS

RUNNING_ON_GH = os.getenv("GITHUB_ACTIONS") == "true"
RUNNING_ON_JENKINS = "JENKINS_HOME" in os.environ
TEST_SCHEMA = f"GH_JOB_{(str(uuid.uuid4()).replace('-', '_'))}"
if RUNNING_ON_JENKINS:
TEST_SCHEMA = f"JENKINS_JOB_{(str(uuid.uuid4()).replace('-', '_'))}"


def running_on_public_ci() -> bool:
"""Whether or not tests are currently running on one of our public CIs."""
return RUNNING_ON_GH


def running_on_jenkins() -> bool:
"""Whether or not tests are currently running on a Jenkins node."""
return RUNNING_ON_JENKINS


class Utils:
@staticmethod
Expand Down

0 comments on commit ef4d1c7

Please sign in to comment.