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

Fix comet_ml import and add ensure availability #7933

Merged
merged 6 commits into from
Oct 27, 2020
Merged

Fix comet_ml import and add ensure availability #7933

merged 6 commits into from
Oct 27, 2020

Conversation

dsblank
Copy link
Contributor

@dsblank dsblank commented Oct 20, 2020

What does this PR do?

  1. Adds a better check to make sure comet_ml is ready to use
  2. Moves the integration imports above the ML imports. This is required to use comet_ml

The current version 3.4.0 is broken, and can not be used with comet_ml without a workaround. This PR fixes that.

Before submitting

Who can review?

Trainer: @sgugger

@dsblank
Copy link
Contributor Author

dsblank commented Oct 20, 2020

FYI: @stas00

if comet_ml.config.get_config("comet.api_key"):
_has_comet = True
else:
logger.warning("comet_ml is installed but `COMET_API_KEY` is not set.")
Copy link
Contributor

@stas00 stas00 Oct 20, 2020

Choose a reason for hiding this comment

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

excellent, but IMHO this shouldn't be of level warning() - it's an optional feature and it shouldn't be noisy if some other package installed comet_ml as an automatic dependency and the user doesn't have it configured and has no idea why she gets this warning.

Any level above will do, since warning is the default level in transformers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I merely duplicated the logic and level from the wandb logger (below this code). Let me know if you want to change both, or leave them as-is.

Copy link
Contributor

@stas00 stas00 Oct 20, 2020

Choose a reason for hiding this comment

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

this is a totally reasonable assumption, @dsblank. Thank you for clarifying.

@sgugger - what is your thinking on that?

Copy link
Contributor

@stas00 stas00 Oct 20, 2020

Choose a reason for hiding this comment

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

I may be in minority of someone who looks at test logs, that's why I have been trying to clean up a lot of those unnecessary warnings.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The reasoning for the Wandb warning if that if users installed it, they probably want to use it, so should be aware there is something missing. That being said, I'm not aware of people getting wandb installed as a dependency from another lib.
The same logic applies to comet_ml so the warning makes sense if someone has not finished setting the API but at the same time, I understand your point @stas00.

I don't think there is a way to satisfy everyone, so I'd err on the side of what makes life easier for beginners, which is to leave the warning. We can add an env variable to ignore one or the other integration (I think there is one for Wandb already) and test that env variable before raising the warning, so that the experienced user has a way of shutting up an integration they don't want.

How does that sound?

Copy link
Contributor

@stas00 stas00 Oct 21, 2020

Choose a reason for hiding this comment

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

FWIW, I know for sure that I haven't installed comet_pl and yet it's there. I have recently reset my conda env and currently don't have this package, so it might take time before I find which package forced it on me.

Normally one can find it with:

pip install pipdeptree
pipdeptree --reverse --packages comet_ml

but only after the package in question has been installed.

Copy link
Contributor

@stas00 stas00 Oct 21, 2020

Choose a reason for hiding this comment

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

I still don't understand what is the purpose of these warnings - if a user expects wandb/comet ml to work w/o the keys - it's not going to happen, so surely they can figure it out. Requiring users who don't use these modules endure warnings and forcing them to either succumb and register with those both services or seek out how to shut them down is not cool. The user who has an issue sorting out how to make them work, will face this once. The user who doesn't want to become wandb/comet_ml user will have this warning happening all the time. Please re-think this.
I'd add an env var to activate the warning as a debug measure for someone who needs it once - not to turn it off.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Weird! I can't think of any standard package that has comet_ml as a dependency. Let us know if you find it :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Will certainly do.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sitting on this some more, I am feeling I'm being difficult here, so I will let it go and trust that it'll sort itself out in a good time. Thank you for letting me share my thoughts.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

@sgugger sgugger requested a review from LysandreJik October 21, 2020 14:50
Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

LGTM but I agree with @stas00: I wouldn't want to see warnings about cometml or wandb if I don't have the libraries installed.

Looking at the code, however, it seems weird that you're still getting warnings @stas00 as if it's not in your env it should raise an exception which wouldn't trigger the warnings.

@stas00
Copy link
Contributor

stas00 commented Oct 22, 2020

but I agree with @stas00: I wouldn't want to see warnings about cometml or wandb if I don't have the libraries installed.

This is not the case already. We were talking about the odd case where some other package installed one of these as its auto-dependencies. So the user now unwittingly needs to figure out why in the world she needs to get an API key for something she didn't ask for in first place.

Unfortunately I am forced to reset my conda env a lot recently, so I lost the one where this exact scenario has happened, so at the moment I can't point the guilty finger at which package installed cometml without me doing so intentionally/directly. If it happens again I will report back.

Otherwise all is good.

@dsblank
Copy link
Contributor Author

dsblank commented Oct 27, 2020

Resolved merge conflicts. Should be ready to go.

@sgugger
Copy link
Collaborator

sgugger commented Oct 27, 2020

Thanks!

@sgugger sgugger merged commit 1496931 into huggingface:master Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants