-
Notifications
You must be signed in to change notification settings - Fork 292
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
Adds flytekitplugin.wandb #2405
Conversation
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
plugins/flytekit-wandb/README.md
Outdated
@wandb_init( | ||
project=WANDB_PROJECT, | ||
entity=WANDB_ENTITY, | ||
secret_key=WANDB_SECRET_KEY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to specify the secret key two times? (@task
and @wandb_init
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, you can simply use the one specified in the task. as it will be part of the context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the PR to pass the secret object around:
wandb_secret = Secret(key=WANDB_SECRET_KEY, group=WANDB_SECRET_GROUP)
@task(
container_image=image,
secret_requests=[wandb_secret],
)
@wandb_init(
project=WANDB_PROJECT,
entity=WANDB_ENTITY,
secret=wandb_secret,
)
We can do something more implicit by pulling the secret request out of the task, but the wandb_init
decorator still needs to know the name of the Secret associated with W&B. I prefer the more explicit approach of passing the Secret
object around.
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2405 +/- ##
==========================================
- Coverage 75.85% 75.83% -0.02%
==========================================
Files 181 181
Lines 18395 18393 -2
Branches 3601 3600 -1
==========================================
- Hits 13953 13949 -4
- Misses 3840 3841 +1
- Partials 602 603 +1 ☔ View full report in Codecov by Sentry. |
This is incredible! |
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
plugins: | ||
logs: | ||
dynamic-log-links: | ||
- wandb-execution-id: | ||
displayName: Weights & Biases | ||
templateUris: '{{ .taskConfig.host }}/{{ .taskConfig.entity }}/{{ .taskConfig.project }}/runs/{{ .executionName }}-{{ .nodeId }}-{{ .taskRetryAttempt }}' | ||
- wandb-custom-id: | ||
displayName: Weights & Biases | ||
templateUris: '{{ .taskConfig.host }}/{{ .taskConfig.entity }}/{{ .taskConfig.project }}/runs/{{ .taskConfig.id }}' | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Giving Weights and Biases two keys here to support:
- Our auto-generated execution id -> Default unique id for Weights and Biases
- User provided id -> useful for continue training.
from flytekit.core.context_manager import FlyteContextManager | ||
from flytekit.core.utils import ClassDecorator | ||
|
||
wandb = lazy_module("wandb") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why lazy here out of curiosity? wandb is a dependency of this plugin, so if the env can access this file shouldn't it also be able to access wandb?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw it as a pattern in the mlflow
plugin:
go = lazy_module("plotly.graph_objects") | |
plotly_subplots = lazy_module("plotly.subplots") | |
pd = lazy_module("pandas") | |
mlflow = lazy_module("mlflow") |
Personally, I would go with a normal import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For direct dependencies (which is the case, since wandb
is listed in setup.py
) we should go with a regular import.
|
||
def __init__( | ||
self, | ||
task_function: Optional[Callable] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the future, do you want to also add P, R here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, f we want this decorator to type correctly with @task
, we'll likely end up needing ParamSpec
and TypeVar
here.
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com> Signed-off-by: Jan Fiedler <jan@union.ai>
Tracking issue
Related to flyteorg/flyte#2798
Why are the changes needed?
This PR adds a
wandb
plugin to better integrate with Weights and Biases.What changes were proposed in this pull request?
This PR proposes a simple
wandb_init
task decorator that gives the user full control on how theproject
,entity
are named in Weights and Biases. If theid
is not given, then theHOSTNAME
is used for wandb's run id. Currently,HOSTNAME
is set to{.executionName}-{.nodeID}-{.taskRetryAttempt}
, which is unique to the node.How was this patch tested?
This PR adds unit tests and docs to help users enable the feature.
For local testing, I've built an image with this plugin installed at
ghcr.io/thomasjpfan/wandb:0.0.4
and ran:Workflow contents
Check all the applicable boxes
Docs link
The associated flytesnacks docs are in: flyteorg/flytesnacks#1673
With multiple runs, this is what shows up in the Weights and Bias UI, the runs are ID with Flyte specific run_ids: