diff --git a/openai/wandb_logger.py b/openai/wandb_logger.py index fd2df9d7b6..bc6696fb39 100644 --- a/openai/wandb_logger.py +++ b/openai/wandb_logger.py @@ -10,6 +10,7 @@ import datetime import io import json + import re from pathlib import Path import numpy as np @@ -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: @@ -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", @@ -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: