from spotforecast2.manager.multitask import CleanTask
task = CleanTask(data_frame_name="demo10")
print(f"Task: {task.TASK}")
print(f"Task name: {task._task_name}")Task: clean
Task name: clean
manager.multitask.CleanTask(
dataframe=None,
data_test=None,
data_frame_name='default',
cache_home=None,
agg_weights=None,
index_name='DateTime',
number_folds=10,
predict_size=24,
bounds=None,
contamination=0.03,
imputation_method='weighted',
use_exogenous_features=True,
n_trials_optuna=15,
n_trials_spotoptim=10,
n_initial_spotoptim=5,
auto_save_models=True,
train_days=365 * 2,
val_days=7 * 2,
log_level=logging.INFO,
verbose=False,
**config_overrides,
)Cache-cleaning task — removes all cached data from the pipeline cache.
CleanTask deletes the entire cache directory configured for the pipeline, including saved models, tuning results, and any other cached artefacts written by training or tuning tasks.
Unlike training or prediction tasks, CleanTask does not require prepare_data() to be called before run(). It operates purely on the file system and can be used as a standalone reset mechanism between experiments or deployments.
Passing dry_run=True to run() reports what would be deleted without actually removing anything, which is useful for inspecting cache contents before committing to removal.
| Name | Description |
|---|---|
| run | Remove all cached data from the pipeline cache directory. |
Remove all cached data from the pipeline cache directory.
Does not require prepare_data() to be called first.
| Name | Type | Description | Default |
|---|---|---|---|
| dry_run | bool | If True, report what would be deleted without actually removing anything. Useful for inspecting the cache before committing to removal. |
False |
| cache_home | Optional[Path] | Override the directory to clean. None uses the directory configured on this instance via get_cache_home(). |
None |
| show | bool | Accepted for API consistency with other tasks. Not used by the clean task. | True |
| Name | Type | Description |
|---|---|---|
| Dict[str, Any] | Dict with keys: status: "success", "dry_run", or "empty". cache_dir: The Path targeted for cleaning. deleted_items: Names of top-level items removed (or that would have been removed in dry_run mode). |
| Name | Type | Description |
|---|---|---|
| RuntimeError | If the cache directory cannot be removed due to a permissions error or OS-level failure. |
import tempfile
from pathlib import Path
from spotforecast2.manager.multitask import CleanTask
with tempfile.TemporaryDirectory() as tmp:
task = CleanTask(cache_home=Path(tmp) / "test_cache")
result = task.run(dry_run=True)
print(result["status"])[clean] Dry run — would delete: /tmp/tmp58if_0hx/test_cache
Would remove: logging
dry_run