Skip to content

Commit b5fa5e3

Browse files
committed
fix(train): automatically add datestamp at the end of run name
1 parent 89a8640 commit b5fa5e3

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/labelr/apps/train.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ def train_object_detection(
4747
help="The Hugging Face token, used to push the trained model to Hugging Face Hub.",
4848
),
4949
run_name: str = typer.Option(..., help="A name for the training run."),
50+
add_date_to_run_name: bool = typer.Option(
51+
True, help="Whether to append the date to the run name."
52+
),
5053
hf_repo_id: str = typer.Option(
5154
..., help="The Hugging Face dataset repository ID to use to train."
5255
),
@@ -69,6 +72,11 @@ def train_object_detection(
6972
f"Invalid model name '{model_name}'. Available models are: {', '.join(AVAILABLE_OBJECT_DETECTION_MODELS)}"
7073
)
7174

75+
datestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
76+
77+
if add_date_to_run_name:
78+
run_name = f"{run_name}-{datestamp}"
79+
7280
env_variables = {
7381
"HF_REPO_ID": hf_repo_id,
7482
"HF_TRAINED_MODEL_REPO_ID": hf_trained_model_repo_id,
@@ -82,8 +90,12 @@ def train_object_detection(
8290
"USE_AWS_IMAGE_CACHE": "False",
8391
"YOLO_MODEL_NAME": model_name,
8492
}
85-
job_name = "train-yolo-job"
86-
job_name = job_name + "-" + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
93+
94+
job_name = f"train-yolo-job-{run_name}"
95+
if not add_date_to_run_name:
96+
# Ensure job name is unique by adding a datestamp if date is not added to run name
97+
job_name = f"{job_name}-{datestamp}"
98+
8799
job = launch_job(
88100
job_name=job_name,
89101
container_image_uri="europe-west9-docker.pkg.dev/robotoff/gcf-artifacts/train-yolo",

0 commit comments

Comments
 (0)