Skip to content
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

Add run_name argument to the MLFlowLogger constructor #7622

Merged
merged 9 commits into from
May 21, 2021

Conversation

i-aki-y
Copy link
Contributor

@i-aki-y i-aki-y commented May 20, 2021

What does this PR do?

This PR adds a run_name argument to the MLFlowLogger constructor.
As is shown in #7571, the run_name is used to identify the specific execution (run) in mlflow.
By default, the run_name is the same value as the run_id that is a UUID.
So, mlflow allows the user to set more informative run_name in mlflow.start_run method argument^[1].

The current MLFlowLogger does not support setting the run_name explicitly.
(As I pointed out in #7571, there is a workaround, but it is hard to notice, I think.)
So, in this PR, the run_name argument is added to the MLFlowLogger.

To make this PR, I referred to the current implementation of mlflow.start_run^[1]

I would appreciate it if you could review this PR.

[1] https://www.mlflow.org/docs/latest/python_api/mlflow.html#mlflow.start_run

Fixes #7571

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃
👍

@codecov
Copy link

codecov bot commented May 20, 2021

Codecov Report

Merging #7622 (d0b3900) into master (20f6337) will decrease coverage by 4%.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master   #7622    +/-   ##
=======================================
- Coverage      92%     88%    -4%     
=======================================
  Files         197     198     +1     
  Lines       12878   12942    +64     
=======================================
- Hits        11899   11380   -519     
- Misses        979    1562   +583     

@i-aki-y i-aki-y changed the title Add run_name argument to the MLFlowLogger constructor [WIP]Add run_name argument to the MLFlowLogger constructor May 20, 2021
@i-aki-y i-aki-y changed the title [WIP]Add run_name argument to the MLFlowLogger constructor Add run_name argument to the MLFlowLogger constructor May 20, 2021
@awaelchli awaelchli added logger Related to the Loggers feature Is an improvement or enhancement labels May 20, 2021
@awaelchli awaelchli added this to the v1.4 milestone May 20, 2021
@@ -155,6 +161,14 @@ def experiment(self) -> MlflowClient:
)

if self._run_id is None:
if self._run_name is not None:
self.tags = self.tags or {}
Copy link
Member

Choose a reason for hiding this comment

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

can we maybe lift this to the init already? So that self.tags is always a dict?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I have a concern about this. The current self.tags looks to be a public attribute (it has no prefix '_'), so I worried that the user could set None to it after the initialization.

Note that the document does not say the tags are public, so I'm not sure it is intentional:
https://pytorch-lightning.readthedocs.io/en/latest/api/pytorch_lightning.loggers.mlflow.html#mlflow-logger

Another minor reason why I put this here is to minimize the side effect. If the run_name is not set explicitly, the self.tags still be 'None' after this PR. this is the same behavior as the current version.

I could not judge which is better, so any suggestions and comments are welcome!

CHANGELOG.md Outdated Show resolved Hide resolved
tests/loggers/test_mlflow.py Outdated Show resolved Hide resolved
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

LGTM !

@tchaton tchaton merged commit 7eafd8e into Lightning-AI:master May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement logger Related to the Loggers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MLFlowLogger can‘t set Run Name
4 participants