Skip to content

setup_mlflow API Ray Train V2 Compatibility#58705

Merged
justinvyu merged 15 commits into
ray-project:masterfrom
JasonLi1909:fix-setup_mlflow-tune
Nov 20, 2025
Merged

setup_mlflow API Ray Train V2 Compatibility#58705
justinvyu merged 15 commits into
ray-project:masterfrom
JasonLi1909:fix-setup_mlflow-tune

Conversation

@JasonLi1909

@JasonLi1909 JasonLi1909 commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Users have run into issues using the setup_mlflow API with Ray Train V2 enabled:

  • When using setup_mlflow in a tune run, a DeprecationWarning is raised because ray.train.get_context() is called from with a Ray Tune run
  • When using setup_mlflow in a regular Train run, a DeprecationWarning is raised because TrainContext.get_trial_id() is called but this is no longer supported in Train V2

This PR:

  • Makes setup_mlflow compatible with Ray Train V2 by avoiding deprecated API usage
  • Adds tests for testing the compatibility of Train V2 with setup_mlflow
…p_mlflow

Signed-off-by: JasonLi1909 <jasli1909@gmail.com>
@JasonLi1909 JasonLi1909 requested a review from a team as a code owner November 17, 2025 18:13
Comment thread python/ray/air/integrations/mlflow.py Outdated

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request aims to add compatibility with Ray Train V2 for the setup_mlflow API by handling deprecation warnings. The changes introduce try-except blocks to catch DeprecationWarning and fall back to alternative APIs or gracefully handle the situation.

While the intent is good, I've found a critical issue where the new structure could lead to a NameError if ray.train.get_context() raises a RuntimeError. I've provided a suggestion to restructure the code to prevent this.

Additionally, I've pointed out that simply catching DeprecationWarning for context methods like get_world_rank() and then proceeding without trial information could lead to silent failures in MLflow logging. It would be better to use the newer APIs if possible.

Comment thread python/ray/air/integrations/mlflow.py
Comment thread python/ray/air/integrations/mlflow.py Outdated
Comment thread python/ray/air/integrations/mlflow.py Outdated
@ray-gardener ray-gardener Bot added the train Ray Train Related Issue label Nov 17, 2025
JasonLi1909 and others added 7 commits November 17, 2025 13:37
Signed-off-by: JasonLi1909 <jasli1909@gmail.com>
Signed-off-by: JasonLi1909 <jasli1909@gmail.com>
Signed-off-by: JasonLi1909 <jasli1909@gmail.com>
Signed-off-by: JasonLi1909 <jasli1909@gmail.com>
Signed-off-by: JasonLi1909 <jasli1909@gmail.com>
Signed-off-by: JasonLi1909 <jasli1909@gmail.com>

@justinvyu justinvyu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, just a few minor things

Comment thread python/ray/air/integrations/mlflow.py Outdated
Comment thread python/ray/air/tests/test_integration_mlflow.py Outdated
Comment thread python/ray/air/tests/test_integration_mlflow.py
JasonLi1909 and others added 3 commits November 18, 2025 16:32
Signed-off-by: JasonLi1909 <jasli1909@gmail.com>
Signed-off-by: JasonLi1909 <jasli1909@gmail.com>
Comment thread python/ray/air/integrations/mlflow.py Outdated
Signed-off-by: JasonLi1909 <jasli1909@gmail.com>
Comment thread python/ray/air/tests/test_integration_mlflow.py
JasonLi1909 and others added 2 commits November 19, 2025 11:52
Signed-off-by: JasonLi1909 <jasli1909@gmail.com>

@justinvyu justinvyu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

Comment thread python/ray/air/integrations/mlflow.py Outdated
Co-authored-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Jason Li <57246540+JasonLi1909@users.noreply.github.com>
@justinvyu justinvyu enabled auto-merge (squash) November 20, 2025 19:53
@github-actions github-actions Bot added the go add ONLY when ready to merge, run all tests label Nov 20, 2025
@justinvyu justinvyu merged commit ffeec63 into ray-project:master Nov 20, 2025
8 checks passed
SheldonTsen pushed a commit to SheldonTsen/ray that referenced this pull request Dec 1, 2025
- Makes setup_mlflow compatible with Ray Train V2 by avoiding deprecated
API usage
- Adds tests for testing the compatibility of Train V2 with setup_mlflow

---------

Signed-off-by: JasonLi1909 <jasli1909@gmail.com>
Signed-off-by: Jason Li <57246540+JasonLi1909@users.noreply.github.com>
Co-authored-by: Justin Yu <justinvyu@anyscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests train Ray Train Related Issue

2 participants