Skip to content

Commit 89f4319

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

File tree

7 files changed

+65
-26
lines changed

7 files changed

+65
-26
lines changed

.github/workflows/beam_PostCommit_Python.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ env:
5454
jobs:
5555
beam_PostCommit_Python:
5656
name: ${{ matrix.job_name }} (${{ matrix.job_phrase }} ${{ matrix.python_version }})
57-
runs-on: [self-hosted, ubuntu-20.04, highmem22]
57+
runs-on:
58+
- [self-hosted, ubuntu-20.04, highmem22]
59+
- ubuntu-latest
5860
timeout-minutes: 240
5961
strategy:
6062
fail-fast: false
@@ -99,7 +101,13 @@ jobs:
99101
arguments: |
100102
-Pjava21Home=$JAVA_HOME_21_X64 \
101103
-PuseWheelDistribution \
102-
-PpythonVersion=${{ matrix.python_version }} \
104+
# Conditionally add -Pposargs based on the runner type.
105+
-Pposargs="${{
106+
contains(matrix.runner_os, 'self-hosted') &&
107+
'-m ''not require_non_self_hosted''' ||
108+
'-m ''require_non_self_hosted'''
109+
}}" \
110+
-PpythonVersion=${{ matrix.python_version }}
103111
env:
104112
CLOUDSDK_CONFIG: ${{ env.KUBELET_GCLOUD_CONFIG_PATH}}
105113
- name: Archive Python Test Results
@@ -115,4 +123,4 @@ jobs:
115123
commit: '${{ env.prsha || env.GITHUB_SHA }}'
116124
comment_mode: ${{ github.event_name == 'issue_comment' && 'always' || 'off' }}
117125
files: '**/pytest*.xml'
118-
large_files: true
126+
large_files: true

.github/workflows/beam_PreCommit_Python_ML.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ env:
5858
jobs:
5959
beam_PreCommit_Python_ML:
6060
name: ${{ matrix.job_name }} (${{ matrix.job_phrase }} ${{ matrix.python_version }})
61-
runs-on: [self-hosted, ubuntu-20.04, main]
61+
runs-on:
62+
- [self-hosted, ubuntu-20.04, main]
63+
- ubuntu-latest
6264
timeout-minutes: 180
6365
strategy:
6466
fail-fast: false
@@ -96,7 +98,12 @@ jobs:
9698
with:
9799
gradle-command: :sdks:python:test-suites:tox:py${{steps.set_py_ver_clean.outputs.py_ver_clean}}:testPy${{steps.set_py_ver_clean.outputs.py_ver_clean}}ML
98100
arguments: |
99-
-Pposargs=apache_beam/ml/ \
101+
# Conditionally add -Pposargs based on the runner type.
102+
-Pposargs="${{
103+
contains(matrix.runner_os, 'self-hosted') &&
104+
'-m ''not require_non_self_hosted''' ||
105+
'-m ''require_non_self_hosted'''
106+
}}" \
100107
-PpythonVersion=${{ matrix.python_version }}
101108
- name: Archive Python Test Results
102109
uses: actions/upload-artifact@v4
@@ -111,4 +118,4 @@ jobs:
111118
commit: '${{ env.prsha || env.GITHUB_SHA }}'
112119
comment_mode: ${{ github.event_name == 'issue_comment' && 'always' || 'off' }}
113120
files: '**/pytest*.xml'
114-
large_files: true
121+
large_files: true

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

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,10 @@ 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 require_non_self_hosted due to Docker-in-Docker
471+
# runtime issues on the self-hosted envs. This typically runs on the
472+
# ubuntu-latest env.
473+
@pytest.mark.require_non_self_hosted
471474
@unittest.skipUnless(
472475
platform.system() == "Linux",
473476
"Test runs only on Linux due to lack of support, as yet, for nested "
@@ -483,22 +486,17 @@ class TestMilvusSearchEnrichment(unittest.TestCase):
483486

484487
@classmethod
485488
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-
)
489+
cls._db = MilvusEnrichmentTestHelper.start_db_container(
490+
cls._version, vector_client_max_retries=1)
491+
cls._connection_params = MilvusConnectionParameters(
492+
uri=cls._db.uri,
493+
user=cls._db.user,
494+
password=cls._db.password,
495+
db_id=cls._db.id,
496+
token=cls._db.token)
497+
cls._collection_load_params = MilvusCollectionLoadParameters()
498+
cls._collection_name = MilvusEnrichmentTestHelper.initialize_db_with_data(
499+
cls._connection_params)
502500

503501
@classmethod
504502
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+
require_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: 4 additions & 3 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.
@@ -445,7 +444,8 @@ def get_portability_package_data():
445444
'mysql-connector-python>=9.3.0',
446445
'python-tds>=1.16.1',
447446
'sqlalchemy-pytds>=1.0.2',
448-
'oracledb>=3.1.1'
447+
'oracledb>=3.1.1',
448+
'milvus'
449449
],
450450
'gcp': [
451451
'cachetools>=3.1.0,<6',
@@ -588,7 +588,8 @@ def get_portability_package_data():
588588
'transformers==4.25.1'
589589
],
590590
'xgboost': ['xgboost>=1.6.0,<2.1.3', 'datatable==1.0.0'],
591-
'tensorflow-hub': ['tensorflow-hub>=0.14.0,<0.16.0']
591+
'tensorflow-hub': ['tensorflow-hub>=0.14.0,<0.16.0'],
592+
'milvus': ['pymilvus>=2.5.10,<3.0.0']
592593
},
593594
zip_safe=False,
594595
# PyPI package information.

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

Lines changed: 22 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": "require_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 = [
@@ -429,6 +450,7 @@ project.tasks.register("inferencePostCommitIT") {
429450
'transformersInferenceTest',
430451
'testcontainersTest',
431452
'feastIntegrationTest',
453+
'nonSelfHostedIntegrationTest',
432454
// (TODO) https://github.com/apache/beam/issues/25799
433455
// uncomment tfx bsl tests once tfx supports protobuf 4.x
434456
// 'tfxInferenceTest',

sdks/python/tox.ini

Lines changed: 2 additions & 0 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
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
9395
commands =
9496
python apache_beam/examples/complete/autocomplete_test.py
9597
bash {toxinidir}/scripts/run_pytest.sh {envname} "{posargs}"

0 commit comments

Comments
 (0)