Skip to content

Error when logging to MLFlow deleted experiment #20556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

millskyle
Copy link
Contributor

@millskyle millskyle commented Jan 21, 2025

What does this PR do?

Addresses issue #20555.

When logging to an MLFlow experiment name that has been deleted (e.g. deleted from the MLFlow UI), the MLFlow experiment still exists in the backend, so expt = self._mlflow_client.get_experiment_by_name(self._experiment_name) retrieves it and Lightning proceeds as if the experiment already exists. When Lightning actually tries to log to the experiment, it stalls as MLFlow returns many 500 errors. Eventually it times out and the program crashes.

This PR simply modifies the check to ensure that the run exists and also is not deleted. This will cause the experiment creation to fail, but with an error message that explicitly states that it cannot be created because there is a deleted experiment with the same name.

This could be handled differently to not crash the run (e.g. increment the experiment name by post-pending _1, _2, etc.) but I think the explicit failure with a clear message is my preferred behaviour.

Fixes #20555>


📚 Documentation preview 📚: https://pytorch-lightning--20556.org.readthedocs.build/en/20556/

@github-actions github-actions bot added the pl Generic label for PyTorch Lightning package label Jan 21, 2025
Copy link

codecov bot commented Feb 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79%. Comparing base (711abb4) to head (3bf11be).
Report is 27 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (711abb4) and HEAD (3bf11be). Click for more details.

HEAD has 99 uploads less than BASE
Flag BASE (711abb4) HEAD (3bf11be)
cpu 48 24
lightning 37 18
pytest 25 0
python3.9 12 6
python3.11 12 6
lightning_fabric 6 0
python3.10 6 3
python3.12.7 18 9
gpu 1 0
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #20556     +/-   ##
=========================================
- Coverage      88%      79%     -9%     
=========================================
  Files         267      264      -3     
  Lines       23380    23325     -55     
=========================================
- Hits        20481    18366   -2115     
- Misses       2899     4959   +2060     
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@lantiga lantiga left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!

A test is not strictly needed but would be great to have one that verifies the condition here https://github.com/Lightning-AI/pytorch-lightning/blob/master/tests/tests_pytorch/loggers/test_mlflow.py

@Borda Borda added logger Related to the Loggers 3rd party Related to a 3rd-party community This PR is from the community labels Feb 14, 2025
@Borda Borda merged commit 29ed24f into Lightning-AI:master Mar 17, 2025
75 of 76 checks passed
Borda pushed a commit that referenced this pull request Mar 18, 2025
* Make error MLFlow deleted experiment explicit

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit 29ed24f)
lexierule pushed a commit that referenced this pull request Mar 18, 2025
* Make error MLFlow deleted experiment explicit

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit 29ed24f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party Related to a 3rd-party community This PR is from the community logger Related to the Loggers pl Generic label for PyTorch Lightning package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MLFlow ResponseError('too many 500 error responses') if try to log to deleted experiment
3 participants