Skip to content

Commit 121b323

Browse files
authored
mraba/rt-exp: rt parallelisation
1 parent 8f2c486 commit 121b323

File tree

7 files changed

+48
-60
lines changed

7 files changed

+48
-60
lines changed

ci/test_docker.sh

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
set -o pipefail
88

99
# In case this is ran from dev-vm
10-
PYTHON_ENV=${1:-3.7}
10+
PYTHON_ENV=${1:-3.8}
1111

1212
# Set constants
13-
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
14-
SQLALCHEMY_DIR="$( dirname "${THIS_DIR}")"
13+
THIS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14+
SQLALCHEMY_DIR="$(dirname "${THIS_DIR}")"
1515
WORKSPACE=${WORKSPACE:-$SQLALCHEMY_DIR}
1616
source $THIS_DIR/set_base_image.sh
1717

@@ -35,19 +35,19 @@ echo "[Info] Start building docker image and testing"
3535

3636
user_id=$(id -u ${USER})
3737
docker run \
38-
--rm \
39-
--network=host \
40-
-e TERM=vt102 \
41-
-e PIP_DISABLE_PIP_VERSION_CHECK=1 \
42-
-e OPENSSL_FIPS=1 \
43-
-e LOCAL_USER_ID=${user_id} \
44-
-e AWS_ACCESS_KEY_ID \
45-
-e AWS_SECRET_ACCESS_KEY \
46-
-e SF_REGRESS_LOGS \
47-
-e SF_PROJECT_ROOT \
48-
-e cloud_provider \
49-
-e JENKINS_HOME \
50-
-e GITHUB_ACTIONS \
51-
--mount type=bind,source="${SQLALCHEMY_DIR}",target=/home/user/snowflake-sqlalchemy \
52-
$(docker build --pull --build-arg BASE_IMAGE=$BASE_IMAGE --build-arg GOSU_URL="$GOSU_URL" -q .) \
53-
/home/user/snowflake-sqlalchemy/ci/test_linux.sh ${PYTHON_ENV}
38+
--rm \
39+
--network=host \
40+
-e TERM=vt102 \
41+
-e PIP_DISABLE_PIP_VERSION_CHECK=1 \
42+
-e OPENSSL_FIPS=1 \
43+
-e LOCAL_USER_ID=${user_id} \
44+
-e AWS_ACCESS_KEY_ID \
45+
-e AWS_SECRET_ACCESS_KEY \
46+
-e SF_REGRESS_LOGS \
47+
-e SF_PROJECT_ROOT \
48+
-e cloud_provider \
49+
-e JENKINS_HOME \
50+
-e GITHUB_ACTIONS \
51+
--mount type=bind,source="${SQLALCHEMY_DIR}",target=/home/user/snowflake-sqlalchemy \
52+
$(docker build --pull --build-arg BASE_IMAGE=$BASE_IMAGE --build-arg GOSU_URL="$GOSU_URL" -q .) \
53+
/home/user/snowflake-sqlalchemy/ci/test_linux.sh ${PYTHON_ENV}

ci/test_linux.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# - This script assumes that ../dist/repaired_wheels has the wheel(s) built for all versions to be tested
77
# - This is the script that test_docker.sh runs inside of the docker container
88

9-
PYTHON_VERSIONS="${1:-3.8 3.9 3.10 3.11}"
9+
PYTHON_VERSIONS="${1:-3.8 3.9 3.10 3.11 3.12 3.13 3.14}"
1010
THIS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1111
SQLALCHEMY_DIR="$(dirname "${THIS_DIR}")"
1212

@@ -19,7 +19,7 @@ for PYTHON_VERSION in ${PYTHON_VERSIONS}; do
1919
echo "[Info] Testing with ${PYTHON_VERSION}"
2020
SHORT_VERSION=$(python3 -c "print('${PYTHON_VERSION}'.replace('.', ''))")
2121
SQLALCHEMY_WHL=$(ls $SQLALCHEMY_DIR/dist/snowflake_sqlalchemy-*-py3-none-any.whl | sort -r | head -n 1)
22-
TEST_ENVLIST=fix_lint,py${SHORT_VERSION}-ci,py${SHORT_VERSION}-coverage
22+
TEST_ENVLIST=fix_lint,py${SHORT_VERSION}-ci,py${SHORT_VERSION}-coverage,py${SHORT_VERSION}-pandas-ci,py${SHORT_VERSION}-pandas-coverage
2323
echo "[Info] Running tox for ${TEST_ENVLIST}"
2424
python3 -m tox -e ${TEST_ENVLIST} --installpkg ${SQLALCHEMY_WHL}
2525
done

tests/conftest.py

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def pytest_addoption(parser):
5959

6060
def pytest_collection_modifyitems(config, items):
6161
if config.getoption("--ignore_v20_test"):
62-
# --ignore_v20_test given in cli: skip sqlalchemy 2.0 tests
6362
skip_feature_v2 = pytest.mark.skip(
6463
reason="need remove --ignore_v20_test option to run"
6564
)
@@ -68,35 +67,6 @@ def pytest_collection_modifyitems(config, items):
6867
item.add_marker(skip_feature_v2)
6968

7069

71-
@pytest.fixture(scope="session")
72-
def on_travis():
73-
return os.getenv("TRAVIS", "").lower() == "true"
74-
75-
76-
@pytest.fixture(scope="session")
77-
def on_appveyor():
78-
return os.getenv("APPVEYOR", "").lower() == "true"
79-
80-
81-
@pytest.fixture(scope="session")
82-
def on_public_ci(on_travis, on_appveyor):
83-
return on_travis or on_appveyor
84-
85-
86-
def help():
87-
print(
88-
"""Connection parameter must be specified in parameters.py,
89-
for example:
90-
CONNECTION_PARAMETERS = {
91-
'account': 'testaccount',
92-
'user': 'user1',
93-
'password': 'test',
94-
'database': 'testdb',
95-
'schema': 'public',
96-
}"""
97-
)
98-
99-
10070
logger = getLogger(__name__)
10171

10272
TZ_ENV_VAR: Literal["TZ"] = "TZ"
@@ -137,6 +107,11 @@ def external_stage():
137107
raise ValueError("External_stage is not set")
138108

139109

110+
@pytest.fixture(scope="session")
111+
def on_public_ci():
112+
return running_on_public_ci()
113+
114+
140115
@pytest.fixture(scope="function")
141116
def base_location(external_stage, engine_testaccount):
142117
unique_id = str(uuid.uuid4())
@@ -325,6 +300,7 @@ def running_on_public_ci() -> bool:
325300

326301
def pytest_runtest_setup(item) -> None:
327302
"""Ran before calling each test, used to decide whether a test should be skipped."""
303+
_ensure_optional_dependencies(item)
328304
test_tags = [mark.name for mark in item.iter_markers()]
329305

330306
# Get what cloud providers the test is marked for if any
@@ -342,3 +318,9 @@ def pytest_runtest_setup(item) -> None:
342318
pytest.skip("cannot run this test on external CI")
343319
elif INTERNAL_SKIP_TAGS.intersection(test_tags) and not running_on_public_ci():
344320
pytest.skip("cannot run this test on internal CI")
321+
322+
323+
def _ensure_optional_dependencies(item):
324+
"""Skip optional-dependency tests when the dependency is unavailable."""
325+
if "pandas" in item.keywords:
326+
pytest.importorskip("pandas")

tests/test_core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ def test_connect_args():
171171

172172

173173
def test_boolean_query_argument_parsing():
174-
175174
engine = create_engine(
176175
URL(
177176
**CONNECTION_PARAMETERS,
@@ -1385,12 +1384,12 @@ def test_special_schema_character(db_parameters, on_public_ci):
13851384
with connect(**options) as sf_conn:
13861385
sf_connection = (
13871386
sf_conn.cursor()
1388-
.execute("select current_database(), " "current_schema();")
1387+
.execute("select current_database(), current_schema();")
13891388
.fetchall()
13901389
)
13911390
with create_engine(URL(**options)).connect() as sa_conn:
13921391
sa_connection = sa_conn.execute(
1393-
text("select current_database(), " "current_schema();")
1392+
text("select current_database(), current_schema();")
13941393
).fetchall()
13951394
# Teardown
13961395
with connect(**options) as conn:
@@ -1823,6 +1822,7 @@ def test_normalize_and_denormalize_empty_string_column_name(engine_testaccount):
18231822
)
18241823

18251824

1825+
@pytest.mark.pandas
18261826
def test_snowflake_sqlalchemy_as_valid_client_type():
18271827
engine = create_engine(
18281828
URL(**CONNECTION_PARAMETERS),

tests/test_pandas.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
import uuid
1111

1212
import numpy as np
13-
import pandas as pd
1413
import pytest
14+
15+
pytest.importorskip("pandas")
16+
import pandas as pd
1517
import sqlalchemy
1618
from sqlalchemy import (
1719
Column,

tests/test_qmark.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
import os
66
import sys
77

8-
import pandas as pd
98
import pytest
9+
10+
pytest.importorskip("pandas")
11+
import pandas as pd
1012
from sqlalchemy import text
1113

1214
THIS_DIR = os.path.dirname(os.path.realpath(__file__))

tox.ini

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
22
min_version = 4.0.0
33
envlist = fix_lint,
4-
py{37,38,39,310,311,312,313,314}{,-pandas},
4+
py{38,39,310,311,312,313,314}{,-pandas},
55
coverage,
66
skip_missing_interpreters = true
77

@@ -10,9 +10,8 @@ package = external
1010
description = run the tests with pytest under {basepython}
1111
extras =
1212
development
13-
pandas
13+
pandas: pandas
1414
external_wheels =
15-
py37-ci: dist/*.whl
1615
py38-ci: dist/*.whl
1716
py39-ci: dist/.whl
1817
py310-ci: dist/.whl
@@ -21,6 +20,7 @@ external_wheels =
2120
py313-ci: dist/.whl
2221
py314-ci: dist/.whl
2322
deps = pip
23+
pytest-xdist
2424
passenv =
2525
AWS_ACCESS_KEY_ID
2626
AWS_SECRET_ACCESS_KEY
@@ -44,10 +44,12 @@ commands = pytest \
4444
--cov "snowflake.sqlalchemy" \
4545
--junitxml {toxworkdir}/junit_{envname}.xml \
4646
--ignore=tests/sqlalchemy_test_suite \
47+
-n8 \
4748
{posargs:tests}
4849
pytest {env:SNOWFLAKE_PYTEST_OPTS:} \
4950
--cov "snowflake.sqlalchemy" --cov-append \
5051
--junitxml {toxworkdir}/junit_{envname}.xml \
52+
-n8 \
5153
{posargs:tests/sqlalchemy_test_suite}
5254

5355
[testenv:.pkg_external]
@@ -70,7 +72,7 @@ commands = coverage combine
7072
coverage xml -o {toxworkdir}/coverage.xml
7173
coverage html -d {toxworkdir}/htmlcov
7274
;diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {toxworkdir}/coverage.xml
73-
depends = py37, py38, py39, py310, py311, py312, py313, py314
75+
depends = py38, py39, py310, py311, py312, py313, py314
7476

7577
[testenv:fix_lint]
7678
description = format the code base to adhere to our styles, and complain about what we cannot do automatically

0 commit comments

Comments
 (0)