Spaces:
Running
Running
Download storage_listing.py from Shoraky/Sporalize-api: direct link, hf CLI and curl.
- Browser
- Download file 728 Bytes
-
https://huggingface.co/spaces/Shoraky/Sporalize-api/resolve/main/storage_listing.py
- Command line
-
hf download hf://spaces/Shoraky/Sporalize-api/storage_listing.py
-
curl -L -o storage_listing.py https://huggingface.co/spaces/Shoraky/Sporalize-api/resolve/main/storage_listing.py
728 Bytes
| """Keep metadata requests scoped to the session being viewed.""" | |
| from huggingface_hub import RepoFile | |
| from huggingface_hub.errors import RemoteEntryNotFoundError | |
| def session_files(api, repo_id, folder): | |
| try: | |
| return [ | |
| entry.path for entry in api.list_repo_tree( | |
| repo_id=repo_id, repo_type="dataset", path_in_repo=folder, | |
| recursive=False, expand=False, | |
| ) if isinstance(entry, RepoFile) | |
| ] | |
| except RemoteEntryNotFoundError: | |
| # Old sessions can have results but no source video folder. | |
| return [] | |
| def session_folder_exists(api, repo_id, folder): | |
| return bool(api.get_paths_info(repo_id=repo_id, repo_type="dataset", paths=[folder])) | |