-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Update the wandb logger #590
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f43bc14
Update WandbLogger for new FineTuningJob api
d076950
remove prints
a711d1b
add docs link
6f71f1f
remove pd
960f063
add pandas check
a51cbbb
list all jobs
tcapelle b1ff007
move pandas assert
tcapelle 174edff
Merge branch 'main' into update_wandb_logger
jhallard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,9 @@ | |
import re | ||
from pathlib import Path | ||
|
||
from openai import File, FineTune | ||
from openai import File, FineTune, FineTuningJob | ||
from openai.datalib.numpy_helper import numpy as np | ||
from openai.datalib.pandas_helper import pandas as pd | ||
from openai.datalib.pandas_helper import assert_has_pandas, pandas as pd | ||
|
||
|
||
class WandbLogger: | ||
|
@@ -34,9 +34,10 @@ def sync( | |
cls, | ||
id=None, | ||
n_fine_tunes=None, | ||
project="GPT-3", | ||
project="OpenAI-Fine-Tune", | ||
entity=None, | ||
force=False, | ||
legacy=False, | ||
**kwargs_wandb_init, | ||
): | ||
""" | ||
|
@@ -47,18 +48,26 @@ def sync( | |
:param entity: Username or team name where you're sending runs. By default, your default entity is used, which is usually your username. | ||
:param force: Forces logging and overwrite existing wandb run of the same fine-tune. | ||
""" | ||
|
||
assert_has_pandas() | ||
|
||
if not WANDB_AVAILABLE: | ||
return | ||
|
||
if id: | ||
fine_tune = FineTune.retrieve(id=id) | ||
print("Retrieving fine-tune job...") | ||
if legacy: | ||
fine_tune = FineTune.retrieve(id=id) | ||
else: | ||
fine_tune = FineTuningJob.retrieve(id=id) | ||
fine_tune.pop("events", None) | ||
fine_tunes = [fine_tune] | ||
|
||
else: | ||
# get list of fine_tune to log | ||
fine_tunes = FineTune.list() | ||
if legacy: | ||
fine_tunes = FineTune.list() | ||
else: | ||
fine_tunes = list(FineTuningJob.auto_paging_iter()) | ||
if not fine_tunes or fine_tunes.get("data") is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fine_tunes is a list when not legacy so .get() now fails. |
||
print("No fine-tune has been retrieved") | ||
return | ||
|
@@ -76,6 +85,7 @@ def sync( | |
project, | ||
entity, | ||
force, | ||
legacy, | ||
show_individual_warnings, | ||
**kwargs_wandb_init, | ||
) | ||
|
@@ -94,6 +104,7 @@ def _log_fine_tune( | |
project, | ||
entity, | ||
force, | ||
legacy, | ||
show_individual_warnings, | ||
**kwargs_wandb_init, | ||
): | ||
|
@@ -110,7 +121,10 @@ def _log_fine_tune( | |
|
||
# check results are present | ||
try: | ||
results_id = fine_tune["result_files"][0]["id"] | ||
if legacy: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good |
||
results_id = fine_tune["result_files"][0]["id"] | ||
else: | ||
results_id = fine_tune["result_files"][0] | ||
results = File.download(id=results_id).decode("utf-8") | ||
except: | ||
if show_individual_warnings: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
One question - will this break existing workflows for users who expect to be able to use WandB sync with the old version of the fine tuning API? That might be okay, we'll just need to note as much in the release notes. My understanding is, if an existing user of the old API (
/v1/fine-tunes
) upgraded theiropenai-python
version and tried to run fine tuning, unless they provided--legacy
, this would break?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.
Yep that’s correct