-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add dangling repo cleanup to hf repos (#891)
* feat: add clean_hf script to all.sh
- Loading branch information
1 parent
19f5ad0
commit 9a9afcb
Showing
3 changed files
with
27 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ set +a | |
./scripts/doctest.sh | ||
./scripts/notebook_runner.sh | ||
./scripts/test.sh | ||
python "$(dirname "$0")/clean_hf.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import os | ||
import warnings | ||
|
||
from dotenv import load_dotenv | ||
from huggingface_hub import HfApi # type: ignore | ||
|
||
|
||
def clean_up_dangling_hf_repos(hugging_face_token: str) -> None: | ||
api = HfApi(token=hugging_face_token) | ||
datasets = list( | ||
api.list_datasets(author="Aleph-Alpha", dataset_name="IL-temp-tests") | ||
) | ||
if len(datasets) > 0: | ||
warnings.warn("dangling hf datasets found, attempting to delete") | ||
for dataset in datasets: | ||
api.delete_repo(dataset.id, repo_type="dataset", missing_ok=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
load_dotenv() | ||
token = os.getenv("HUGGING_FACE_TOKEN") | ||
assert isinstance(token, str) | ||
clean_up_dangling_hf_repos(token) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters