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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wandb): allow custom init args #6989

Merged
merged 15 commits into from May 4, 2021

Conversation

borisdayma
Copy link
Contributor

@borisdayma borisdayma commented Apr 13, 2021

What does this PR do?

Fixes #6788

This PR lets users define any wandb.init() parameter, including resume which was previously forced to allow.

In addition, it handles the case where arguments are passed as kwargs vs as direct arguments.

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 馃檭

@pep8speaks
Copy link

pep8speaks commented Apr 13, 2021

Hello @borisdayma! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 馃嵒

Comment last updated at 2021-05-04 08:40:14 UTC

@codecov
Copy link

codecov bot commented Apr 13, 2021

Codecov Report

Merging #6989 (f959bee) into master (393b252) will decrease coverage by 8%.
The diff coverage is 100%.

@@           Coverage Diff            @@
##           master   #6989     +/-   ##
========================================
- Coverage      91%     83%     -8%     
========================================
  Files         200     200             
  Lines       12875   13594    +719     
========================================
- Hits        11765   11337    -428     
- Misses       1110    2257   +1147     

@borisdayma borisdayma changed the title feat(wandb): allow custom init args fix(wandb): allow custom init args Apr 13, 2021
@Borda Borda added 3rd party Related to a 3rd-party logger Related to the Loggers feature Is an improvement or enhancement labels Apr 13, 2021
Borda
Borda previously requested changes Apr 13, 2021
@@ -89,13 +88,11 @@ class WandbLogger(LightningLoggerBase):

def __init__(
self,
name: Optional[str] = None,
Copy link
Member

Choose a reason for hiding this comment

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

this will fail if a user uses positional arguments
pls, maintain a proper deprecation process...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I聽put back name and project at their previous positions.

self._kwargs = kwargs
# set wandb init arguments
self._wandb_init = dict(resume='allow', id=version or id, dir=save_dir,
anonymous='allow' if anonymous is True else None if anonymous is False else anonymous)
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 rather define this as look-up-table aka dictionary?

an_lut = {True: 'allow', False: None}
anonymous = an_lut.get(anonymous, anonymous)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea!

@borisdayma borisdayma requested a review from Borda April 14, 2021 04:51
Copy link
Member

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

nice

@stale
Copy link

stale bot commented Apr 29, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you need further help see our docs: https://pytorch-lightning.readthedocs.io/en/latest/generated/CONTRIBUTING.html#pull-request or ask the assistance of a core contributor here or on Slack. Thank you for your contributions.

@stale stale bot added the won't fix This will not be worked on label Apr 29, 2021
@awaelchli awaelchli added this to the v1.4 milestone Apr 29, 2021
@stale stale bot removed the won't fix This will not be worked on label Apr 29, 2021
@borisdayma
Copy link
Contributor Author

Hi, any update on this PR?

@awaelchli awaelchli added the bug Something isn't working label May 1, 2021
@mergify mergify bot removed the has conflicts label May 1, 2021
@awaelchli awaelchli modified the milestones: v1.4, v1.3 May 1, 2021
Copy link
Member

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

LGTM
I think this should go into 1.3 because it's really more a fix than a feature.
Changed milestone. Thanks @borisdayma
@Borda check if your comments were addressed?

@@ -93,7 +92,7 @@ def __init__(
save_dir: Optional[str] = None,
offline: Optional[bool] = False,
id: Optional[str] = None,
anonymous: Optional[bool] = False,
anonymous: Optional[bool] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually still the same behavior but is more in line with the W&B documentation so less prone to potential bugs.

@mergify mergify bot added the has conflicts label May 2, 2021
@awaelchli awaelchli added the ready PRs ready to be merged label May 2, 2021
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 enabled auto-merge (squash) May 4, 2021 08:39
pytorch_lightning/loggers/wandb.py Outdated Show resolved Hide resolved
@tchaton tchaton merged commit 2a20102 into Lightning-AI:master May 4, 2021
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 bug Something isn't working feature Is an improvement or enhancement logger Related to the Loggers ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

can't pass resume flag to WandbLogger
7 participants