Skip to content

Conversation

@mohamedawnallah
Copy link
Contributor

@mohamedawnallah mohamedawnallah commented Aug 20, 2025

Description

Cherry-picked from #35816.
Cherry-picked from #35954.

Motivation and Context

This PR properly adds milvus as extra dependency in addition to resolving the recent flakes of PostCommit Python Arm job (#30760 (comment)). Though the following PR #35900 patch was previously submitted to address this, It didn't resolve the root cause issue of milvus extra dependency issue


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@mohamedawnallah
Copy link
Contributor Author

cc @Amar3tto, @damccorm

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @mohamedawnallah, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on correctly integrating Milvus as an extra dependency for the Python SDK and resolving persistent flakiness in the PostCommit Python Arm job. The changes involve a significant update of various Python package versions across different Python environment requirement files, alongside a structural refinement in the setup.py file to better manage the Milvus dependency. The overall goal is to enhance the stability and maintainability of the Python SDK's build and test processes.

Highlights

  • Milvus Dependency Management Refinement: The setup.py file has been updated to properly define pymilvus as a dedicated milvus_dependency list. This ensures pymilvus is correctly handled as an extra dependency and is no longer directly listed within the general io extra, streamlining dependency management.
  • Comprehensive Python Dependency Version Bumps: Numerous Python package versions have been updated across base_image_requirements.txt and ml_image_requirements.txt files for Python 3.9, 3.10, 3.11, 3.12, and 3.13 environments. These updates include critical packages such as charset-normalizer, cloud-sql-python-connector, Cython, google-cloud-aiplatform, pymilvus, requests, SQLAlchemy, and transformers, among others, contributing to a more stable and up-to-date environment.
  • CI Trigger for Validation: A minor, trivial change was made to .github/trigger_files/beam_PostCommit_Python.json to trigger the associated CI job, which is a standard practice to validate the impact of dependency changes on the build system.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@mohamedawnallah
Copy link
Contributor Author

Fixed linting and formatting issues proposed by CI

@mohamedawnallah mohamedawnallah changed the title sdks/python: properly add Milvus as extra dependency [bug] sdks/python: properly add Milvus as extra dependency Aug 20, 2025
@mohamedawnallah mohamedawnallah changed the title [bug] sdks/python: properly add Milvus as extra dependency [bugFix] sdks/python: properly add Milvus as extra dependency Aug 20, 2025
@github-actions
Copy link
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@damccorm
Copy link
Contributor

Waiting on checks to complete, but the change looks good to me

@damccorm
Copy link
Contributor

Hm, I see the following error logs in the postcommit python:

<testcase classname="apache_beam.ml.rag.enrichment.milvus_search_it_test.TestMilvusSearchEnrichment" name="test_empty_input_chunks" time="26.780">
<error message="failed on setup with "pymilvus.exceptions.MilvusException: <MilvusException: (code=2, message=Fail connecting to server on 172.17.0.2:51635, illegal connection params or server unavailable)>"">cls = <class 'apache_beam.ml.rag.enrichment.milvus_search_it_test.TestMilvusSearchEnrichment'> @classmethod def setUpClass(cls): cls._db = MilvusEnrichmentTestHelper.start_db_container(cls._version) cls._connection_params = MilvusConnectionParameters( uri=cls._db.uri, user=cls._db.user, password=cls._db.password, db_id=cls._db.id, token=cls._db.token) cls._collection_load_params = MilvusCollectionLoadParameters() > cls._collection_name = MilvusEnrichmentTestHelper.initialize_db_with_data( cls._connection_params) apache_beam/ml/rag/enrichment/milvus_search_it_test.py:496: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ apache_beam/ml/rag/enrichment/milvus_search_it_test.py:365: in initialize_db_with_data client = MilvusClient(**connc_params.__dict__) target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/milvus_client/milvus_client.py:64: in __init__ self._using = create_connection( target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/milvus_client/_utils.py:49: in create_connection raise ex from ex target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/milvus_client/_utils.py:44: in create_connection connections.connect( target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/orm/connections.py:459: in connect connect_milvus(**kwargs, user=user, password=password, token=token, db_name=db_name) target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/orm/connections.py:420: in connect_milvus raise e from e target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/orm/connections.py:412: in connect_milvus gh._wait_for_channel_ready(timeout=timeout) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pymilvus.client.grpc_handler.GrpcHandler object at 0x7cdbb04fed30> timeout = 10.0 def _wait_for_channel_ready(self, timeout: Union[float] = 10): if self._channel is None: raise MilvusException( code=Status.CONNECT_FAILED, message="No channel in handler, please setup grpc channel first", ) try: grpc.channel_ready_future(self._channel).result(timeout=timeout) self._setup_identifier_interceptor(self._user, timeout=timeout) except grpc.FutureTimeoutError as e: self.close() > raise MilvusException( code=Status.CONNECT_FAILED, message=f"Fail connecting to server on {self._address}, illegal connection params or server unavailable", ) from e E pymilvus.exceptions.MilvusException: <MilvusException: (code=2, message=Fail connecting to server on 172.17.0.2:51635, illegal connection params or server unavailable)> target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/client/grpc_handler.py:159: MilvusException</error>
</testcase>

Could you please take a look?

@mohamedawnallah
Copy link
Contributor Author

Hm, I see the following error logs in the postcommit python:

<testcase classname="apache_beam.ml.rag.enrichment.milvus_search_it_test.TestMilvusSearchEnrichment" name="test_empty_input_chunks" time="26.780">
<error message="failed on setup with "pymilvus.exceptions.MilvusException: <MilvusException: (code=2, message=Fail connecting to server on 172.17.0.2:51635, illegal connection params or server unavailable)>"">cls = <class 'apache_beam.ml.rag.enrichment.milvus_search_it_test.TestMilvusSearchEnrichment'> @classmethod def setUpClass(cls): cls._db = MilvusEnrichmentTestHelper.start_db_container(cls._version) cls._connection_params = MilvusConnectionParameters( uri=cls._db.uri, user=cls._db.user, password=cls._db.password, db_id=cls._db.id, token=cls._db.token) cls._collection_load_params = MilvusCollectionLoadParameters() > cls._collection_name = MilvusEnrichmentTestHelper.initialize_db_with_data( cls._connection_params) apache_beam/ml/rag/enrichment/milvus_search_it_test.py:496: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ apache_beam/ml/rag/enrichment/milvus_search_it_test.py:365: in initialize_db_with_data client = MilvusClient(**connc_params.__dict__) target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/milvus_client/milvus_client.py:64: in __init__ self._using = create_connection( target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/milvus_client/_utils.py:49: in create_connection raise ex from ex target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/milvus_client/_utils.py:44: in create_connection connections.connect( target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/orm/connections.py:459: in connect connect_milvus(**kwargs, user=user, password=password, token=token, db_name=db_name) target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/orm/connections.py:420: in connect_milvus raise e from e target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/orm/connections.py:412: in connect_milvus gh._wait_for_channel_ready(timeout=timeout) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pymilvus.client.grpc_handler.GrpcHandler object at 0x7cdbb04fed30> timeout = 10.0 def _wait_for_channel_ready(self, timeout: Union[float] = 10): if self._channel is None: raise MilvusException( code=Status.CONNECT_FAILED, message="No channel in handler, please setup grpc channel first", ) try: grpc.channel_ready_future(self._channel).result(timeout=timeout) self._setup_identifier_interceptor(self._user, timeout=timeout) except grpc.FutureTimeoutError as e: self.close() > raise MilvusException( code=Status.CONNECT_FAILED, message=f"Fail connecting to server on {self._address}, illegal connection params or server unavailable", ) from e E pymilvus.exceptions.MilvusException: <MilvusException: (code=2, message=Fail connecting to server on 172.17.0.2:51635, illegal connection params or server unavailable)> target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/pymilvus/client/grpc_handler.py:159: MilvusException</error>
</testcase>

Could you please take a look?

@damccorm - The root cause of this because of changing milvus server version in the integration tests from v2.5.10to v2.3.9 in that PR #35889. This is not aligned with our pymilvus dependency in sdk/python/setup.py: 'pymilvus>=2.5.10,<3.0.0'

@A1K28 Could please elaborate more about the rational behind this change? I see the note there in PR description Downgrades milvus version to account for CPU instability and I am not sure I am able to get this

With a note as well if we decided to downgrade that we will lose nice features like BM25 Metric Type. Seeing:
milvus-io/milvus#39652 (comment)

@A1K28
Copy link
Contributor

A1K28 commented Aug 25, 2025

@A1K28 Could please elaborate more about the rational behind this change? I see the note there in PR description Downgrades milvus version to account for CPU instability and I am not sure I am able to get this

Yes, feel free to revert that specific change. The reason for it was:

"Your CPU must support one of the following instruction sets to run Milvus: SSE4. 2, AVX, AVX2, AVX512.". Retrieved from https://milvus.io/docs/v2.4.x/product_faq.md. Some of my self hosted runners were screaming about that.

@damccorm
Copy link
Contributor

I'm still seeing the precommit coverage workflow failing with similar errors unfortunately:

<testcase classname="apache_beam.ml.rag.enrichment.milvus_search_it_test.TestMilvusSearchEnrichment" name="test_keyword_search_with_inner_product_sparse_embedding" time="0.001">
<error message="failed on setup with "Failed: Timeout (>600.0s) from pytest-timeout."">wrapped = <bound method DockerContainer.get_exposed_port of <apache_beam.ml.rag.enrichment.milvus_search_it_test.CustomMilvusContainer object at 0x79a1ec603cd0>> instance = <apache_beam.ml.rag.enrichment.milvus_search_it_test.CustomMilvusContainer object at 0x79a1ec603cd0> args = (36185,), kwargs = {} @wrapt.decorator # type: ignore[misc] def wrapper(wrapped: Callable[..., Any], instance: Any, args: list[Any], kwargs: dict[str, Any]) -> Any: from testcontainers.core.container import DockerContainer if isinstance(instance, DockerContainer): logger.info("Waiting for container %s with image %s to be ready ...", instance._container, instance.image) else: logger.info("Waiting for %s to be ready ...", instance) exception = None for attempt_no in range(config.max_tries): try: > return wrapped(*args, **kwargs) target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/testcontainers/core/waiting_utils.py:59: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/testcontainers/core/container.py:237: in get_exposed_port return int(self.get_docker_client().port(c.id, port)) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <testcontainers.core.docker_client.DockerClient object at 0x79a1ec603d30> container_id = 'feced16dceea3235bfbdda7d020425c9513b4cb37360ab33254292421da7c97d' port = 36185 def port(self, container_id: str, port: int) -> str: """ Lookup the public-facing port that is NAT-ed to :code:`port`. """ port_mappings = self.client.api.port(container_id, port) if not port_mappings: > raise ConnectionError(f"Port mapping for container {container_id} and port {port} is not available") E ConnectionError: Port mapping for container feced16dceea3235bfbdda7d020425c9513b4cb37360ab33254292421da7c97d and port 36185 is not available target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/testcontainers/core/docker_client.py:170: ConnectionError During handling of the above exception, another exception occurred: cls = <class 'apache_beam.ml.rag.enrichment.milvus_search_it_test.TestMilvusSearchEnrichment'> @classmethod def setUpClass(cls): > cls._db = MilvusEnrichmentTestHelper.start_db_container(cls._version) apache_beam/ml/rag/enrichment/milvus_search_it_test.py:488: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ apache_beam/ml/rag/enrichment/milvus_search_it_test.py:318: in start_db_container vector_db_container.start() target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/testcontainers/milvus/__init__.py:83: in start self._connect() target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/testcontainers/core/waiting_utils.py:59: in wrapper return wrapped(*args, **kwargs) target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/testcontainers/milvus/__init__.py:65: in _connect self._healthcheck() target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/testcontainers/core/waiting_utils.py:59: in wrapper return wrapped(*args, **kwargs) target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/testcontainers/milvus/__init__.py:74: in _healthcheck healthcheck_url = self._get_healthcheck_url() target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/testcontainers/milvus/__init__.py:69: in _get_healthcheck_url port = self.get_exposed_port(self.healthcheck_port) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ wrapped = <bound method DockerContainer.get_exposed_port of <apache_beam.ml.rag.enrichment.milvus_search_it_test.CustomMilvusContainer object at 0x79a1ec603cd0>> instance = <apache_beam.ml.rag.enrichment.milvus_search_it_test.CustomMilvusContainer object at 0x79a1ec603cd0> args = (36185,), kwargs = {} @wrapt.decorator # type: ignore[misc] def wrapper(wrapped: Callable[..., Any], instance: Any, args: list[Any], kwargs: dict[str, Any]) -> Any: from testcontainers.core.container import DockerContainer if isinstance(instance, DockerContainer): logger.info("Waiting for container %s with image %s to be ready ...", instance._container, instance.image) else: logger.info("Waiting for %s to be ready ...", instance) exception = None for attempt_no in range(config.max_tries): try: return wrapped(*args, **kwargs) except transient_exceptions as e: logger.debug( f"Connection attempt '{attempt_no + 1}' of '{config.max_tries + 1}' " f"failed: {traceback.format_exc()}" ) > time.sleep(config.sleep_time) E Failed: Timeout (>600.0s) from pytest-timeout. target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/testcontainers/core/waiting_utils.py:65: Failed</error>

@mohamedawnallah
Copy link
Contributor Author

5,), kwargs = {} @wrapt.decorator # type: ignore[misc] def wrapper(wrapped: Callable[..., Any], instance: Any, args: list[Any], kwargs: dict[str, Any]) -> Any: from testcontainers.core.container import DockerContainer if isinstance(instance, DockerContainer): logger.info("Waiting for container %s with image %s to be ready ...", instance._container, instance.image) else: logger.info("Waiting for %s to be ready ...", instance) exception = None for attempt_no in range(config.max_tries): try: return wrapped(*args, **kwargs) except transient_exceptions as e: logger.debug( f"Connection attempt '{attempt_no + 1}' of '{config.max_tries + 1}' " f"failed: {traceback.format_exc()}" ) > time.sleep(config.sleep_time) E Failed: Timeout (>600.0s) from pytest-timeout. target/.tox-py39-cloudcoverage/py39-cloudcoverage/lib/python3.9/site-packages/testcontainers/core/waiting_utils.py:65: Failed

Thanks 🙏. Given we haven't integrated the ubuntu-latest yet to run those tests with require_docker_in_docker pytest marker, Curious why they are currently even running. Let me check this out and report back here

@github-actions github-actions bot added the build label Aug 27, 2025
@damccorm
Copy link
Contributor

Merged into my test branch here - https://github.com/apache/beam/actions/runs/17278672942

And running checks here - https://github.com/apache/beam/actions/runs/17278672942

Copy link
Contributor

@damccorm damccorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, thanks for being patient through the review process!

@damccorm damccorm merged commit 5447d64 into apache:master Aug 28, 2025
109 of 125 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants