-
Couldn't load subscription status.
- Fork 4.4k
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
Changes from 6 commits
f43bc14
d076950
a711d1b
6f71f1f
960f063
a51cbbb
b1ff007
174edff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,9 +13,12 @@ | |
| 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 | ||
|
|
||
|
|
||
| assert_has_pandas() | ||
|
||
|
|
||
|
|
||
| class WandbLogger: | ||
|
|
@@ -34,9 +37,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, | ||
| ): | ||
| """ | ||
|
|
@@ -52,13 +56,19 @@ def sync( | |
| 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 +86,7 @@ def sync( | |
| project, | ||
| entity, | ||
| force, | ||
| legacy, | ||
| show_individual_warnings, | ||
| **kwargs_wandb_init, | ||
| ) | ||
|
|
@@ -94,6 +105,7 @@ def _log_fine_tune( | |
| project, | ||
| entity, | ||
| force, | ||
| legacy, | ||
| show_individual_warnings, | ||
| **kwargs_wandb_init, | ||
| ): | ||
|
|
@@ -110,7 +122,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: | ||
|
|
||
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-pythonversion 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