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: automatically upload config file when using WandbLogger with PTL CLI #19268

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

ayulockin
Copy link

@ayulockin ayulockin commented Jan 11, 2024

What does this PR do?

While using the CLI, the config file is logged to W&B partially (run page). Ideally, it should log the entirety of the config for better reproducibility and comparison of experiments. This PR fixes this issue by modifying the SaveConfigCallback to execute some logic only when WandbLogger is used (run page).

To further support user convenience, the change saves the config passed to the CLI to the correct wandb/exp_name dir.

Fixes #<issue_number>

Before submitting
  • Was this discussed/agreed 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 list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

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

Reviewer checklist
  • 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

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

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

codecov bot commented Jan 11, 2024

Codecov Report

Merging #19268 (7240741) into master (6bc27d5) will decrease coverage by 34%.
The diff coverage is 40%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19268      +/-   ##
==========================================
- Coverage      83%      49%     -34%     
==========================================
  Files         445      437       -8     
  Lines       37289    37146     -143     
==========================================
- Hits        31119    18241   -12878     
- Misses       6170    18905   +12735     

Copy link

gitguardian bot commented Jan 16, 2024

⚠️ GitGuardian has uncovered 4 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
- Generic High Entropy Secret 68d1169 tests/tests_data/streaming/test_resolver.py View secret
- Generic High Entropy Secret 68d1169 tests/tests_data/streaming/test_resolver.py View secret
- Generic High Entropy Secret 68d1169 tests/tests_data/streaming/test_resolver.py View secret
- Generic High Entropy Secret 68d1169 tests/tests_data/streaming/test_resolver.py View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@ayulockin
Copy link
Author

@aniketmaurya who would be the right person to review this PR. :)

@ayulockin
Copy link
Author

Hey @awaelchli, was curious if you can take a look at this PR. Thanks 🌮

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.

Hey @ayulockin

Sorry for the very late review, it's very busy atm.

I think it's a good idea, and this will also be useful for the other loggers. Let's do it.
I left a design suggestion below.

@@ -293,6 +296,23 @@ def save_config(self, trainer, pl_module, stage):
instead.

"""
if isinstance(trainer.logger, WandbLogger):
Copy link
Member

@awaelchli awaelchli Mar 8, 2024

Choose a reason for hiding this comment

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

The code below looks good in general.
However, this save_config hook is meant to be overridden by users who want to add their own saving logic. We should not implement it here. I propose to simply create a new callback:

class LoggerSaveConfigCallback(SaveConfigCallback)
    def save_config(...):
        # your logic here

and then we register that one by default if the CLI is used.

What do you think?

@awaelchli awaelchli added logger Related to the Loggers lightningcli pl.cli.LightningCLI community This PR is from the community labels Mar 8, 2024
@awaelchli awaelchli self-assigned this Mar 8, 2024
@awaelchli awaelchli added this to the 2.3 milestone Mar 8, 2024
@awaelchli awaelchli modified the milestones: 2.3, future Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community This PR is from the community has conflicts lightningcli pl.cli.LightningCLI 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.

None yet

3 participants