Skip to content

Commit c7997fa

Browse files
sdks/python: make milvus as extra dependency
1 parent 2784cde commit c7997fa

5 files changed

Lines changed: 50 additions & 21 deletions

File tree

sdks/python/apache_beam/ml/rag/enrichment/milvus_search_it_test.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,9 @@ def create_user_yaml(service_port: int, max_vector_field_num=5):
467467
os.remove(path)
468468

469469

470-
@pytest.mark.uses_testcontainer
470+
# Mark Milvus itests with non_self_hosted due to Docker-in-Docker runtime issues
471+
# on the self-hosted envs. This typically runs on the ubuntu-latest env.
472+
@pytest.mark.non_self_hosted
471473
@unittest.skipUnless(
472474
platform.system() == "Linux",
473475
"Test runs only on Linux due to lack of support, as yet, for nested "
@@ -483,22 +485,17 @@ class TestMilvusSearchEnrichment(unittest.TestCase):
483485

484486
@classmethod
485487
def setUpClass(cls):
486-
try:
487-
cls._db = MilvusEnrichmentTestHelper.start_db_container(
488-
cls._version, vector_client_max_retries=1, tc_max_retries=1)
489-
cls._connection_params = MilvusConnectionParameters(
490-
uri=cls._db.uri,
491-
user=cls._db.user,
492-
password=cls._db.password,
493-
db_id=cls._db.id,
494-
token=cls._db.token)
495-
cls._collection_load_params = MilvusCollectionLoadParameters()
496-
cls._collection_name = MilvusEnrichmentTestHelper.initialize_db_with_data(
497-
cls._connection_params)
498-
except Exception as e:
499-
pytest.skip(
500-
f"Skipping all tests in {cls.__name__} due to DB startup failure: {e}"
501-
)
488+
cls._db = MilvusEnrichmentTestHelper.start_db_container(
489+
cls._version, vector_client_max_retries=1)
490+
cls._connection_params = MilvusConnectionParameters(
491+
uri=cls._db.uri,
492+
user=cls._db.user,
493+
password=cls._db.password,
494+
db_id=cls._db.id,
495+
token=cls._db.token)
496+
cls._collection_load_params = MilvusCollectionLoadParameters()
497+
cls._collection_name = MilvusEnrichmentTestHelper.initialize_db_with_data(
498+
cls._connection_params)
502499

503500
@classmethod
504501
def tearDownClass(cls):

sdks/python/pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ markers =
7070
uses_mock_api: tests that uses the mock API cluster.
7171
uses_feast: tests that uses feast in some way
7272
gemini_postcommit: gemini postcommits that need additional deps.
73+
non_self_hosted: tests requiring specialized environments or infrastructure not present in self-hosted setups.
7374

7475
# Default timeout intended for unit tests.
7576
# If certain tests need a different value, please see the docs on how to

sdks/python/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ def get_portability_package_data():
401401
'typing-extensions>=3.7.0',
402402
'zstandard>=0.18.0,<1',
403403
'pyyaml>=3.12,<7.0.0',
404-
'pymilvus>=2.5.10,<3.0.0',
405404
# Dynamic dependencies must be specified in a separate list, otherwise
406405
# Dependabot won't be able to parse the main list. Any dynamic
407406
# dependencies will not receive updates from Dependabot.
@@ -588,7 +587,8 @@ def get_portability_package_data():
588587
'transformers==4.25.1'
589588
],
590589
'xgboost': ['xgboost>=1.6.0,<2.1.3', 'datatable==1.0.0'],
591-
'tensorflow-hub': ['tensorflow-hub>=0.14.0,<0.16.0']
590+
'tensorflow-hub': ['tensorflow-hub>=0.14.0,<0.16.0'],
591+
'milvus': ['pymilvus>=2.5.10,<3.0.0']
592592
},
593593
zip_safe=False,
594594
# PyPI package information.

sdks/python/test-suites/direct/common.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,27 @@ task feastIntegrationTest {
419419
}
420420
}
421421

422+
// Integration tests that runs on non self-hosted environments.
423+
task nonSelfHostedIntegrationTest {
424+
dependsOn 'installGcpTest'
425+
dependsOn ':sdks:python:sdist'
426+
427+
doLast {
428+
def testOpts = basicTestOpts
429+
def argMap = [
430+
"test_opts": testOpts,
431+
"suite": "postCommitIT-direct-py${pythonVersionSuffix}",
432+
"collect": "non_self_hosted",
433+
"runner": "TestDirectRunner",
434+
]
435+
def cmdArgs = mapToArgString(argMap)
436+
exec {
437+
executable 'sh'
438+
args '-c', ". ${envdir}/bin/activate && ${runScriptsDir}/run_integration_test.sh $cmdArgs"
439+
}
440+
}
441+
}
442+
422443
// Add all the RunInference framework IT tests to this gradle task that runs on Direct Runner Post commit suite.
423444
project.tasks.register("inferencePostCommitIT") {
424445
dependsOn = [

sdks/python/tox.ini

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@ commands_pre =
8585
pip --version
8686
# pip check
8787
bash {toxinidir}/scripts/run_tox_cleanup.sh
88+
extras = test,milvus
8889
commands =
8990
python apache_beam/examples/complete/autocomplete_test.py
9091
bash {toxinidir}/scripts/run_pytest.sh {envname} "{posargs}"
9192

9293
[testenv:py{39,310,311,312,313}-win]
94+
extras = test,milvus
9395
commands =
9496
python apache_beam/examples/complete/autocomplete_test.py
9597
bash {toxinidir}/scripts/run_pytest.sh {envname} "{posargs}"
@@ -109,7 +111,7 @@ deps =
109111
pip==25.0.1
110112
accelerate>=1.6.0
111113
setenv =
112-
extras = test,gcp,dataframe,ml_test
114+
extras = test,gcp,dataframe,milvus,ml_test
113115
commands =
114116
# Log tensorflow version for debugging
115117
/bin/sh -c "pip freeze | grep -E tensorflow"
@@ -121,7 +123,7 @@ commands =
121123
deps =
122124
accelerate>=1.6.0
123125
setenv =
124-
extras = test,gcp,dataframe,p312_ml_test
126+
extras = test,gcp,dataframe,milvus,p312_ml_test
125127
commands =
126128
# Log tensorflow version for debugging
127129
/bin/sh -c "pip freeze | grep -E tensorflow"
@@ -546,6 +548,14 @@ commands =
546548
/bin/sh -c 'pytest apache_beam/ml/transforms/embeddings -o junit_suite_name={envname} --junitxml=pytest_{envname}.xml -n 6 {posargs}; ret=$?; [ $ret = 5 ] && exit 0 || exit $ret'
547549

548550

551+
[testenv:py{39,310,311,312,313}-milvus]
552+
extras = test,gcp,milvus
553+
commands =
554+
# Log versions for debugging.
555+
/bin/sh -c "pip freeze | grep -E 'pymilvus|testcontainers'"
556+
bash {toxinidir}/scripts/run_pytest.sh {envname} "{posargs}"
557+
558+
549559
[testenv:py{39,310}-TFHubEmbeddings-{014,015}]
550560
deps =
551561
014: tensorflow-hub>=0.14.0,<0.15.0

0 commit comments

Comments
 (0)