lewtun HF staff commited on
Commit
2ed83bb
1 Parent(s): ac54d65

Store dataset ID in AutoTrain project name

Browse files
Files changed (2) hide show
  1. app.py +2 -3
  2. utils.py +10 -0
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import os
2
- import uuid
3
  from pathlib import Path
4
 
5
  import pandas as pd
@@ -13,6 +12,7 @@ from evaluation import filter_evaluated_models
13
  from utils import (
14
  AUTOTRAIN_TASK_TO_HUB_TASK,
15
  commit_evaluation_log,
 
16
  format_col_mapping,
17
  get_compatible_models,
18
  get_dataset_card_url,
@@ -459,10 +459,9 @@ with st.form(key="form"):
459
  )
460
  print("INFO -- Selected models after filter:", selected_models)
461
  if len(selected_models) > 0:
462
- project_id = str(uuid.uuid4())[:8]
463
  project_payload = {
464
  "username": AUTOTRAIN_USERNAME,
465
- "proj_name": f"eval-project-{project_id}",
466
  "task": TASK_TO_ID[selected_task],
467
  "config": {
468
  "language": AUTOTRAIN_TASK_TO_LANG[selected_task]
 
1
  import os
 
2
  from pathlib import Path
3
 
4
  import pandas as pd
 
12
  from utils import (
13
  AUTOTRAIN_TASK_TO_HUB_TASK,
14
  commit_evaluation_log,
15
+ create_autotrain_project_name,
16
  format_col_mapping,
17
  get_compatible_models,
18
  get_dataset_card_url,
 
459
  )
460
  print("INFO -- Selected models after filter:", selected_models)
461
  if len(selected_models) > 0:
 
462
  project_payload = {
463
  "username": AUTOTRAIN_USERNAME,
464
+ "proj_name": create_autotrain_project_name(selected_dataset),
465
  "task": TASK_TO_ID[selected_task],
466
  "config": {
467
  "language": AUTOTRAIN_TASK_TO_LANG[selected_task]
utils.py CHANGED
@@ -1,4 +1,5 @@
1
  import inspect
 
2
  from typing import Dict, List, Union
3
 
4
  import jsonlines
@@ -180,3 +181,12 @@ def get_dataset_card_url(dataset_id: str) -> str:
180
  return f"https://huggingface.co/datasets/{dataset_id}/edit/main/README.md"
181
  else:
182
  return f"https://github.com/huggingface/datasets/edit/master/datasets/{dataset_id}/README.md"
 
 
 
 
 
 
 
 
 
 
1
  import inspect
2
+ import uuid
3
  from typing import Dict, List, Union
4
 
5
  import jsonlines
 
181
  return f"https://huggingface.co/datasets/{dataset_id}/edit/main/README.md"
182
  else:
183
  return f"https://github.com/huggingface/datasets/edit/master/datasets/{dataset_id}/README.md"
184
+
185
+
186
+ def create_autotrain_project_name(dataset_id: str) -> str:
187
+ """Creates an AutoTrain project name for the given dataset ID."""
188
+ # Project names cannot have "/", so we need to format community datasets accordingly
189
+ dataset_id_formatted = dataset_id.replace("/", "--")
190
+ # Project names need to be unique, so we append a random string to guarantee this
191
+ project_id = str(uuid.uuid4())[:8]
192
+ return f"eval-project-{dataset_id_formatted}-{project_id}"