Skip to content

feat(wandb): sanitize name #77

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 2 commits into from
Mar 28, 2022
Merged
Changes from all 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
16 changes: 12 additions & 4 deletions openai/wandb_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import datetime
import io
import json
import re
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -108,6 +109,15 @@ def _log_fine_tune(
)
return

# check results are present
try:
results_id = fine_tune["result_files"][0]["id"]
results = File.download(id=results_id).decode("utf-8")
except:
if show_individual_warnings:
print(f"Fine-tune {fine_tune_id} has no results and will not be logged")
return

# check run has not been logged already
run_path = f"{project}/{fine_tune_id}"
if entity is not None:
Expand Down Expand Up @@ -135,10 +145,6 @@ def _log_fine_tune(
if wandb_status == "succeeded" and not force:
return

# retrieve results
results_id = fine_tune["result_files"][0]["id"]
results = File.download(id=results_id).decode("utf-8")

# start a wandb run
wandb.init(
job_type="fine-tune",
Expand Down Expand Up @@ -251,6 +257,8 @@ def _log_artifact_inputs(cls, file, prefix, artifact_type, project, entity):

# get input artifact
artifact_name = f"{prefix}-{filename}"
# sanitize name to valid wandb artifact name
artifact_name = re.sub(r"[^a-zA-Z0-9_\-.]", "_", artifact_name)
artifact_alias = file_id
artifact_path = f"{project}/{artifact_name}:{artifact_alias}"
if entity is not None:
Expand Down