Spaces:
Runtime error
Runtime error
Deploy Space: update src
Browse files122 unmodified lines123124125126127128129130131132133134135136137500 unmodified lines63863964064164264364464564664769 unmodified lines71771871972072172272372472572672772824 unmodified lines753754755756757758122 unmodified linesdf = df.sort_values(by=["model", "dataset"]).reset_index(drop=True)df["model"] = df["model"].replace(LEGACY_MODEL_NAMES)ALLOWED_MODELS = {"Toto-2.0-1B","Moirai-1.1-Large","Chronos-2","Timer-S1","TiRex","TimesFM-2.5"}df = df[df["model"].isin(ALLOWED_MODELS)]parts = df["dataset"].astype(str).str.split("/", expand=True)if parts.shape[1] < 3:500 unmodified linesdef get_dataset_last_eval_time(ds_base: str, root_dir: str = "results") -> datetime | None:latest_dt: datetime | None = NoneALLOWED_SLUGS = {"chronos_2", "moirai_1_1_large", "timer_s1", "timesfm_2_5", "tirex", "toto_2_0_1b"}# Scan model directoriesfor model_dir in Path(root_dir).iterdir():if not model_dir.is_dir() or model_dir.name not in ALLOWED_SLUGS:continueforecasts_dir = model_dir / "forecasts"if not forecasts_dir.is_dir():69 unmodified linesexcept Exception:pass# Fallback to current snapshots count if history is empty or failsif not timestamp_counts:seen_datasets: set[str] = set()ALLOWED_SLUGS = {"chronos_2", "moirai_1_1_large", "timer_s1", "timesfm_2_5", "tirex", "toto_2_0_1b"}for model_dir in sorted(Path(root_dir).iterdir()):if not model_dir.is_dir() or model_dir.name not in ALLOWED_SLUGS:continueforecasts_dir = model_dir / "forecasts"if not forecasts_dir.is_dir():24 unmodified linestimestamp_counts[domain] = timestamp_counts.get(domain, 0) + n_tsdomain_datasets.setdefault(domain, set()).add(dataset_short_name(ds_base))if not timestamp_counts:return None122 unmodified lines123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162500 unmodified lines66366466566666766866967067169 unmodified lines74174274374474574674774874975075175275375475575675775875976076176276376476576676724 unmodified lines792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822122 unmodified linesdf = df.sort_values(by=["model", "dataset"]).reset_index(drop=True)df["model"] = df["model"].replace(LEGACY_MODEL_NAMES)# Dynamically detect evaluated models in root_dir.# A model is valid if its subdirectory contains 'all_results.csv'.detected_models = set()root_path = Path(root_dir)if root_path.exists():for p in root_path.iterdir():if p.is_dir() and (p / "all_results.csv").exists():config_json = p / "config.json"if config_json.exists():try:cfg = json.loads(config_json.read_text())if "model" in cfg:detected_models.add(cfg["model"])except Exception:pass# Read model display names from the CSV file itself as a fallbacktry:temp_df = pd.read_csv(p / "all_results.csv", nrows=5)if "model" in temp_df.columns:detected_models.update(temp_df["model"].dropna().unique())except Exception:pass# Fallback to defaults if no models are detectedif not detected_models:detected_models = {"Toto-2.0-1B","Moirai-1.1-Large","Chronos-2","Timer-S1","TiRex","TimesFM-2.5"}df = df[df["model"].isin(detected_models)]parts = df["dataset"].astype(str).str.split("/", expand=True)if parts.shape[1] < 3:500 unmodified linesdef get_dataset_last_eval_time(ds_base: str, root_dir: str = "results") -> datetime | None:latest_dt: datetime | None = None# Scan model directoriesfor model_dir in Path(root_dir).iterdir():if not model_dir.is_dir() or not (model_dir / "all_results.csv").exists():continueforecasts_dir = model_dir / "forecasts"if not forecasts_dir.is_dir():69 unmodified linesexcept Exception:pass# Fallback to cumulative history (no today filter) if today is emptyif not timestamp_counts and history_path.exists():try:with open(history_path) as f:for line in f:if not line.strip():continueentry = json.loads(line)ds_base = entry.get("dataset", "")pred_len = entry.get("prediction_length", 0)domain = get_domain(ds_base)timestamp_counts[domain] = timestamp_counts.get(domain, 0) + pred_lendomain_datasets.setdefault(domain, set()).add(dataset_short_name(ds_base))except Exception:pass# Fallback to current snapshots count (today-only first)if not timestamp_counts:seen_datasets: set[str] = set()for model_dir in sorted(Path(root_dir).iterdir()):if not model_dir.is_dir() or not (model_dir / "all_results.csv").exists():continueforecasts_dir = model_dir / "forecasts"if not forecasts_dir.is_dir():24 unmodified linestimestamp_counts[domain] = timestamp_counts.get(domain, 0) + n_tsdomain_datasets.setdefault(domain, set()).add(dataset_short_name(ds_base))# Fallback to cumulative snapshots count (no today filter) if still emptyif not timestamp_counts:seen_datasets: set[str] = set()for model_dir in sorted(Path(root_dir).iterdir()):if not model_dir.is_dir() or not (model_dir / "all_results.csv").exists():continueforecasts_dir = model_dir / "forecasts"if not forecasts_dir.is_dir():continuefor fp in forecasts_dir.glob("*.json"):try:snap = json.loads(fp.read_text())except Exception:continueds_full = snap.get("dataset", "")ds_base = ds_full.split("/")[0]if ds_base in seen_datasets:continueseen_datasets.add(ds_base)domain = get_domain(ds_base)n_ts = len(snap.get("context", [])) + len(snap.get("actuals", []))timestamp_counts[domain] = timestamp_counts.get(domain, 0) + n_tsdomain_datasets.setdefault(domain, set()).add(dataset_short_name(ds_base))if not timestamp_counts:return None
src/utils.py+78-14