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 resume wandb reporter #293

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion fl4health/reporting/wandb_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
tags: list[str] | None = None,
name: str | None = None,
id: str | None = None,
resume: str = "allow",
**kwargs: Any,
) -> None:
"""
Expand All @@ -56,7 +57,11 @@ def __init__(
name (str | None, optional): A short display name for this run. Default generates a random two-word name.
id (str | None, optional): A unique ID for this run. It must be unique in the project, and if you delete a
run you can't reuse the ID.
kwargs (Any): Keyword arguments to wandb.init excluding the ones explicitly described above.
resume (str): Indicates how to handle the case when a run has the same entity, project and run id as
a previous run. 'must' enforces the run must resume from the run with same id and throws an error
if it does not exist. 'never' enforces that a run will not resume and throws an error if run id exists.
'allow' resumes if the run id already exists. Defaults to 'allow'.
kwargs (Any): Keyword arguments to wandb.init excluding the ones explicitly described above.
Documentation here: https://docs.wandb.ai/ref/python/init/
"""

Expand All @@ -77,6 +82,7 @@ def __init__(
self.tags = tags
self.name = name
self.id = id
self.resume = resume

# Keep track of epoch and step. Initialize as 0.
self.current_epoch = 0
Expand Down Expand Up @@ -157,6 +163,7 @@ def start_run(self, wandb_init_kwargs: dict[str, Any]) -> None:
tags=self.tags,
name=self.name,
id=self.id,
resume=self.resume,
**wandb_init_kwargs, # Other less commonly used kwargs
)
self.run_id = self.run._run_id # If run_id was None, we need to reset run id
Expand Down