Spaces:
Running
Running
adds improved dataset utils with new interface
Browse files- scripts/trackio_tonic/app.py +6 -3
- src/dataset_utils.py +19 -3
- templates/spaces/trackio/app.py +7 -3
scripts/trackio_tonic/app.py
CHANGED
|
@@ -721,13 +721,16 @@ def get_metrics_dataframe(experiment_id: str) -> pd.DataFrame:
|
|
| 721 |
logger.info(f"Using local data for {experiment_id}")
|
| 722 |
return trackio_space.get_metrics_dataframe(experiment_id)
|
| 723 |
|
| 724 |
-
def create_experiment_interface(name: str, description: str)
|
| 725 |
"""Create a new experiment"""
|
| 726 |
try:
|
| 727 |
experiment = trackio_space.create_experiment(name, description)
|
| 728 |
-
|
|
|
|
|
|
|
| 729 |
except Exception as e:
|
| 730 |
-
|
|
|
|
| 731 |
|
| 732 |
def log_metrics_interface(experiment_id: str, metrics_json: str, step: str) -> str:
|
| 733 |
"""Log metrics for an experiment"""
|
|
|
|
| 721 |
logger.info(f"Using local data for {experiment_id}")
|
| 722 |
return trackio_space.get_metrics_dataframe(experiment_id)
|
| 723 |
|
| 724 |
+
def create_experiment_interface(name: str, description: str):
|
| 725 |
"""Create a new experiment"""
|
| 726 |
try:
|
| 727 |
experiment = trackio_space.create_experiment(name, description)
|
| 728 |
+
msg = f"β
Experiment created successfully!\nID: {experiment['id']}\nName: {experiment['name']}\nStatus: {experiment['status']}"
|
| 729 |
+
dropdown = gr.Dropdown(choices=list(trackio_space.experiments.keys()), value=experiment['id'])
|
| 730 |
+
return msg, dropdown
|
| 731 |
except Exception as e:
|
| 732 |
+
dropdown = gr.Dropdown(choices=list(trackio_space.experiments.keys()), value=None)
|
| 733 |
+
return f"β Error creating experiment: {str(e)}", dropdown
|
| 734 |
|
| 735 |
def log_metrics_interface(experiment_id: str, metrics_json: str, step: str) -> str:
|
| 736 |
"""Log metrics for an experiment"""
|
src/dataset_utils.py
CHANGED
|
@@ -45,12 +45,24 @@ class TrackioDatasetManager:
|
|
| 45 |
bool: True if dataset exists and is accessible, False otherwise
|
| 46 |
"""
|
| 47 |
try:
|
|
|
|
| 48 |
load_dataset(self.dataset_repo, token=self.hf_token)
|
| 49 |
logger.info(f"β
Dataset {self.dataset_repo} exists and is accessible")
|
| 50 |
return True
|
| 51 |
except Exception as e:
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
def load_existing_experiments(self) -> List[Dict[str, Any]]:
|
| 56 |
"""
|
|
@@ -64,7 +76,11 @@ class TrackioDatasetManager:
|
|
| 64 |
logger.info("π No existing dataset found, returning empty list")
|
| 65 |
return []
|
| 66 |
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
if 'train' not in dataset:
|
| 70 |
logger.info("π No 'train' split found in dataset")
|
|
|
|
| 45 |
bool: True if dataset exists and is accessible, False otherwise
|
| 46 |
"""
|
| 47 |
try:
|
| 48 |
+
# Try standard load first
|
| 49 |
load_dataset(self.dataset_repo, token=self.hf_token)
|
| 50 |
logger.info(f"β
Dataset {self.dataset_repo} exists and is accessible")
|
| 51 |
return True
|
| 52 |
except Exception as e:
|
| 53 |
+
# Some hubs raise a split-metadata mismatch; retry with relaxed verification
|
| 54 |
+
try:
|
| 55 |
+
logger.info(f"π Standard load failed: {e}. Retrying with relaxed verification...")
|
| 56 |
+
load_dataset(
|
| 57 |
+
self.dataset_repo,
|
| 58 |
+
token=self.hf_token,
|
| 59 |
+
verification_mode="no_checks" # type: ignore[arg-type]
|
| 60 |
+
)
|
| 61 |
+
logger.info(f"β
Dataset {self.dataset_repo} accessible with relaxed verification")
|
| 62 |
+
return True
|
| 63 |
+
except Exception as e2:
|
| 64 |
+
logger.info(f"π Dataset {self.dataset_repo} doesn't exist or isn't accessible: {e2}")
|
| 65 |
+
return False
|
| 66 |
|
| 67 |
def load_existing_experiments(self) -> List[Dict[str, Any]]:
|
| 68 |
"""
|
|
|
|
| 76 |
logger.info("π No existing dataset found, returning empty list")
|
| 77 |
return []
|
| 78 |
|
| 79 |
+
# Load with relaxed verification to avoid split-metadata mismatches blocking reads
|
| 80 |
+
try:
|
| 81 |
+
dataset = load_dataset(self.dataset_repo, token=self.hf_token)
|
| 82 |
+
except Exception:
|
| 83 |
+
dataset = load_dataset(self.dataset_repo, token=self.hf_token, verification_mode="no_checks") # type: ignore[arg-type]
|
| 84 |
|
| 85 |
if 'train' not in dataset:
|
| 86 |
logger.info("π No 'train' split found in dataset")
|
templates/spaces/trackio/app.py
CHANGED
|
@@ -990,13 +990,17 @@ def get_metrics_dataframe(experiment_id: str) -> pd.DataFrame:
|
|
| 990 |
logger.info(f"Falling back to local data for {experiment_id}")
|
| 991 |
return trackio_space.get_metrics_dataframe(experiment_id)
|
| 992 |
|
| 993 |
-
def create_experiment_interface(name: str, description: str)
|
| 994 |
"""Create a new experiment"""
|
| 995 |
try:
|
| 996 |
experiment = trackio_space.create_experiment(name, description)
|
| 997 |
-
|
|
|
|
|
|
|
|
|
|
| 998 |
except Exception as e:
|
| 999 |
-
|
|
|
|
| 1000 |
|
| 1001 |
def log_metrics_interface(experiment_id: str, metrics_json: str, step: str) -> str:
|
| 1002 |
"""Log metrics for an experiment"""
|
|
|
|
| 990 |
logger.info(f"Falling back to local data for {experiment_id}")
|
| 991 |
return trackio_space.get_metrics_dataframe(experiment_id)
|
| 992 |
|
| 993 |
+
def create_experiment_interface(name: str, description: str):
|
| 994 |
"""Create a new experiment"""
|
| 995 |
try:
|
| 996 |
experiment = trackio_space.create_experiment(name, description)
|
| 997 |
+
# Return both the status message and a refreshed dropdown
|
| 998 |
+
msg = f"β
Experiment created successfully!\nID: {experiment['id']}\nName: {experiment['name']}\nStatus: {experiment['status']}"
|
| 999 |
+
dropdown = gr.Dropdown(choices=get_experiment_dropdown_choices(), value=experiment['id'])
|
| 1000 |
+
return msg, dropdown
|
| 1001 |
except Exception as e:
|
| 1002 |
+
dropdown = gr.Dropdown(choices=get_experiment_dropdown_choices(), value=None)
|
| 1003 |
+
return f"β Error creating experiment: {str(e)}", dropdown
|
| 1004 |
|
| 1005 |
def log_metrics_interface(experiment_id: str, metrics_json: str, step: str) -> str:
|
| 1006 |
"""Log metrics for an experiment"""
|