Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions openml/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
check_datasets_active,
create_dataset,
delete_dataset,
delete_dataset_cache,
edit_dataset,
fork_dataset,
get_dataset,
Expand All @@ -22,6 +23,7 @@
"create_dataset",
"get_dataset",
"get_datasets",
"delete_dataset_cache",
"list_datasets",
"OpenMLDataset",
"OpenMLDataFeature",
Expand Down
18 changes: 18 additions & 0 deletions openml/datasets/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1461,3 +1461,21 @@ def delete_dataset(dataset_id: int) -> bool:
True if the deletion was successful. False otherwise.
"""
return openml.utils._delete_entity("data", dataset_id)


def delete_dataset_cache(dataset_id: int | str) -> None:
"""Delete the cache directory for a specific dataset.

Parameters
----------
dataset_id : int | str
Dataset ID (integer) or dataset name (string).
"""
if isinstance(dataset_id, str):
try:
dataset_id = int(dataset_id)
except ValueError:
dataset_id = _name_to_id(str(dataset_id))

did_cache_dir = _get_cache_dir_for_id(DATASETS_CACHE_DIR_NAME, dataset_id)
_remove_cache_dir_for_id(DATASETS_CACHE_DIR_NAME, did_cache_dir)
2 changes: 2 additions & 0 deletions openml/flows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .functions import (
assert_flows_equal,
delete_flow,
delete_flow_cache,
flow_exists,
get_flow,
get_flow_id,
Expand All @@ -13,6 +14,7 @@
__all__ = [
"OpenMLFlow",
"get_flow",
"delete_flow_cache",
"list_flows",
"get_flow_id",
"flow_exists",
Expand Down
18 changes: 18 additions & 0 deletions openml/flows/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,3 +552,21 @@ def delete_flow(flow_id: int) -> bool:
True if the deletion was successful. False otherwise.
"""
return openml.utils._delete_entity("flow", flow_id)


def delete_flow_cache(flow_id: int) -> None:
"""Delete the cache directory for a specific flow.

Parameters
----------
flow_id : int
Flow ID (integer).
"""
if isinstance(flow_id, str):
try:
flow_id = int(flow_id)
except ValueError:
raise ValueError("Flow ID should be an integer") from None

fid_cache_dir = openml.utils._create_cache_directory_for_id(FLOWS_CACHE_DIR_NAME, flow_id)
openml.utils._remove_cache_dir_for_id(FLOWS_CACHE_DIR_NAME, fid_cache_dir)
2 changes: 2 additions & 0 deletions openml/runs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .functions import (
delete_run,
delete_run_cache,
get_run,
get_run_trace,
get_runs,
Expand All @@ -22,6 +23,7 @@
"run_model_on_task",
"run_flow_on_task",
"get_run",
"delete_run_cache",
"list_runs",
"get_runs",
"get_run_trace",
Expand Down
18 changes: 18 additions & 0 deletions openml/runs/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,3 +1301,21 @@ def delete_run(run_id: int) -> bool:
True if the deletion was successful. False otherwise.
"""
return openml.utils._delete_entity("run", run_id)


def delete_run_cache(run_id: int) -> None:
"""Delete the cache directory for a specific run.

Parameters
----------
run_id : int
Run ID (integer).
"""
if isinstance(run_id, str):
try:
run_id = int(run_id)
except ValueError:
raise ValueError("Run ID should be an integer") from None

run_cache_dir = openml.utils._create_cache_directory_for_id(RUNS_CACHE_DIR_NAME, run_id)
openml.utils._remove_cache_dir_for_id(RUNS_CACHE_DIR_NAME, run_cache_dir)
2 changes: 2 additions & 0 deletions openml/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .functions import (
create_task,
delete_task,
delete_task_cache,
get_task,
get_tasks,
list_tasks,
Expand All @@ -28,6 +29,7 @@
"create_task",
"get_task",
"get_tasks",
"delete_task_cache",
"list_tasks",
"OpenMLSplit",
"TaskType",
Expand Down
18 changes: 18 additions & 0 deletions openml/tasks/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,21 @@ def delete_task(task_id: int) -> bool:
True if the deletion was successful. False otherwise.
"""
return openml.utils._delete_entity("task", task_id)


def delete_task_cache(task_id: int) -> None:
"""Delete the cache directory for a specific task.

Parameters
----------
task_id : int
Task ID (integer).
"""
if isinstance(task_id, str):
try:
task_id = int(task_id)
except ValueError:
raise ValueError("Task ID should be an integer") from None

tid_cache_dir = openml.utils._create_cache_directory_for_id(TASKS_CACHE_DIR_NAME, task_id)
openml.utils._remove_cache_dir_for_id(TASKS_CACHE_DIR_NAME, tid_cache_dir)