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

Use best practices for wandb.init() and the Run object #1146

Merged
merged 6 commits into from
Mar 12, 2025

Conversation

timoffex
Copy link
Contributor

@timoffex timoffex commented Mar 6, 2025

  • Updates some documentation that uses the global run explicitly (wandb.run) or implicitly (wandb.config, wandb.log, etc.) to use a Run object directly instead.
  • Updates some documentation to use wandb.init() as a context manager by default. This is a best practice from the SDK's perspective because it avoids dangling runs: when the with block exits, the run is marked complete (on normal exit) or failed (on exception) and the process waits for its data to finish uploading.

This regex finds most places that need to be updated (with some false positives):

run = wandb\.init\(|wandb\.(run|finish|config|log\(|summary|save|use|link|watch|unwatch|define|alert|mark)

Unfortunately, there are quite a few places left to update---523 by my count! This PR just updates some top-level guides for users and integrations, which I think are the most important places to start with.

@timoffex timoffex requested a review from a team as a code owner March 6, 2025 01:53
Copy link

cloudflare-workers-and-pages bot commented Mar 6, 2025

Deploying docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 356c22e
Status: ✅  Deploy successful!
Preview URL: https://cd87887d.docodile.pages.dev
Branch Preview URL: https://timoffex-avoid-global-run.docodile.pages.dev

View logs

Copy link
Contributor

@mdlinville mdlinville left a comment

Choose a reason for hiding this comment

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

I did a copyedit pass to try to help out. I think @ngrayluna should take a look at the technical changes and may have other feedback. Thanks!

@timoffex timoffex force-pushed the timoffex/avoid-global-run branch from e42eb01 to 737642b Compare March 7, 2025 19:30
@timoffex timoffex requested review from mdlinville and kptkin March 8, 2025 01:09
Copy link
Contributor

@mdlinville mdlinville left a comment

Choose a reason for hiding this comment

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

A few more small suggestions for the copy in case they are helpful. I am not sure whether @ngrayluna wants to take another look before we merge?

@ngrayluna
Copy link
Contributor

Nice. Thanks so much @timoffex!

@ngrayluna ngrayluna merged commit 218df89 into main Mar 12, 2025
6 checks passed
@ngrayluna ngrayluna deleted the timoffex/avoid-global-run branch March 12, 2025 21:45
@ngrayluna ngrayluna restored the timoffex/avoid-global-run branch March 12, 2025 21:50
@ngrayluna
Copy link
Contributor

Ticket for tracking other code blocks that need updating: https://wandb.atlassian.net/browse/DOCS-1336

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