Path utilities for inferring absolute paths from the project structure.
This module provides utilities to infer absolute paths based on the fixed project structure, eliminating the need for directory path configuration.
get_project_root()
Get the absolute path to the project root directory.
Returns: Path (Absolute path to the project root)
get_tasks_dir()
Get the absolute path to the tasks directory.
Returns: Path (Absolute path to tempus_bench/tasks/)
Raises: FileNotFoundError (If the tasks directory doesn't exist)
get_models_dir()
Get the absolute path to the models directory.
Returns: Path (Absolute path to tempus_bench/models/)
Raises: FileNotFoundError (If the models directory doesn't exist)
get_available_models()
Get all available model names from the models directory structure.
This function scans the models directory to find all model folders that contain a corresponding model file. The model file naming convention is {model_name}_model.py.
Returns: set (Set of available model names found in the models directory)
get_absolute_runs_dir(runs_dir_relative)
Get the absolute path to the runs directory from a relative path.
| Parameter | Type | Default | Description |
|---|---|---|---|
| runs_dir_relative | str |
- | Relative path to runs directory (e.g., "runs") |
Returns: Path (Absolute path to runs directory)
get_task_path(task_name)
Get the absolute path to a specific task directory.
| Parameter | Type | Default | Description |
|---|---|---|---|
| task_name | str |
- | Name of the task (e.g., 'multivariate/baggage_100_multivariate') |
Returns: Path (Absolute path to the task directory)
Raises: FileNotFoundError (If the task directory doesn't exist)
get_dataset_path(task_name)
Get the absolute path to a specific dataset file.
| Parameter | Type | Default | Description |
|---|---|---|---|
| task_name | str |
- | Name of the task (e.g., 'baggage_100_multivariate') |
Returns: Path (Absolute path to the dataset file)
Raises: FileNotFoundError (If the dataset file doesn't exist)
get_model_path(model_type, model_name)
Get the absolute path to a specific model directory.
| Parameter | Type | Default | Description |
|---|---|---|---|
| model_type | str |
- | Type of model ('deterministic', 'stochastic', or 'hybrid') - deprecated, kept for backwards compatibility |
| model_name | str |
- | Name of the model |
Returns: Path (Absolute path to the model directory)
Raises: FileNotFoundError (If the model directory doesn't exist)
get_runs_dir()
Get the absolute path to the runs directory.
Returns: Path (Absolute path to runs directory)
Raises: FileNotFoundError (If the runs directory doesn't exist)
get_logs_path()
Get the absolute path to the project logs directory (may not exist yet).
Returns: Path (Absolute path to <project_root>/logs)
find_task_directories(task_path_pattern)
Find task directories based on a task path pattern.
This function searches for task directories that match the specified pattern. Supported patterns include:
- *: All task directories
- univariate/*: All univariate task directories
- multivariate/*: All multivariate task directories
- specific_task: A specific task directory (e.g., "univariate/specific_task")
| Parameter | Type | Default | Description |
|---|---|---|---|
| task_path_pattern | str |
- | Pattern to match task directories against |
Returns: dict[str, str] (Mapping from task names to absolute directory paths that match the pattern.)
>>> find_task_directories("univariate/*")
{'task1': '/path/to/tasks/univariate/task1', 'task2': '/path/to/tasks/univariate/task2'}
ensure_directory_exists(path)
Ensure that a directory exists, creating it if necessary.
| Parameter | Type | Default | Description |
|---|---|---|---|
| path | Path |
- | Path to the directory to ensure exists |
get_available_metrics()
Get all files containing subclasses of the BaseMetric class.
This function scans the metrics directory for Python files and assumes all files (except base_metric.py, init.py, and cache files) contain BaseMetric subclasses.
Returns: list[Path] (List of absolute file paths containing BaseMetric subclasses)
Raises: FileNotFoundError (If the metrics directory doesn't exist)