cellmil.utils.wandb¶
Classes
|
Parsed components of an experiment ID. |
|
Client for retrieving and processing wandb runs. |
- class cellmil.utils.wandb.ExperimentComponents(task: str, features: str, model: str, regularization: str, stratification: str)[source]¶
Bases:
objectParsed components of an experiment ID.
- class cellmil.utils.wandb.WandbClient(team: str, projects: list[str], tasks: Optional[list[str]] = None)[source]¶
Bases:
objectClient for retrieving and processing wandb runs.
- __init__(team: str, projects: list[str], tasks: Optional[list[str]] = None)[source]¶
Initialize the WandB client.
- Parameters:
team – Team name where the projects belong in wandb.
projects – List of project names to retrieve runs from.
tasks – Optional list of valid tasks for filtering runs.
- get_runs(preprocess: bool = True) list[Any][source]¶
Retrieve wandb runs for configured projects and team.
- Parameters:
preprocess – Whether to preprocess the runs (default: True).
- Returns:
List of wandb runs (preprocessed if requested).
- get_experiment_id(run: Any) str[source]¶
Get the experiment ID from a run.
Handles both formats: - FOLD_N_EXPERIMENTID_YYYY-MM-DD_HH-MM-SS - FINAL_EXPERIMENTID_YYYY-MM-DD_HH-MM-SS
- Parameters:
run – The wandb run object
- Returns:
The extracted experiment ID
- static parse_experiment_components(experiment_id: str) ExperimentComponents[source]¶
Parse an experiment ID into its components.
Format: TASK+FEATURES+MODEL+REG+STRA Example: DCR+ALL+ABMIL+REG+* or OS+PYRAD+HEAD4TYPE+*+STRA
- Parameters:
experiment_id – The experiment ID string
- Returns:
ExperimentComponents with parsed values
- Raises:
ValueError – If experiment ID doesn’t match expected format
- get_task(experiment_id: str) str | None[source]¶
Get the task associated with a given experiment ID.
- Parameters:
experiment_id – The ID of the experiment
- Returns:
The name of the task, or None if not valid
- Raises:
ValueError – If tasks are specified and the experiment ID doesn’t correspond to a known task
- _has_dataloader_error(run: Any, exp_id: str) bool[source]¶
Check if a run has a DataLoader worker error in its logs.
- Parameters:
run – A wandb run object
exp_id – The experiment ID to look for in the error message
- Returns:
True if the error is found, False otherwise
- static get_metric(run: Any, metric: str) float[source]¶
Get the highest validation metric across all epochs for a given run.
- Parameters:
run – A wandb run object
metric – The metric name (e.g., “f1”, “c_index”, “balacc”)
- Returns:
The highest validation metric score
- Raises:
ValueError – If the metric is not found or has no valid values