Spaces:
Build error
Build error
Download src/huggingface/get_environments.py from c-gohlke/LitRL-Inference: direct link, hf CLI and curl.
- Browser
- Download file 642 Bytes
-
https://huggingface.co/spaces/c-gohlke/LitRL-Inference/resolve/main/src/huggingface/get_environments.py
- Command line
-
hf download hf://spaces/c-gohlke/LitRL-Inference/src/huggingface/get_environments.py
-
curl -L -o get_environments.py https://huggingface.co/spaces/c-gohlke/LitRL-Inference/resolve/main/src/huggingface/get_environments.py
642 Bytes
| from __future__ import annotations | |
| from typing import TYPE_CHECKING | |
| if TYPE_CHECKING: | |
| from huggingface_hub import HfApi | |
| from src.constants import ENV_RESULTS_FILE_DEPTH, MODEL_REPO, MODEL_REPO_TYPE | |
| def get_environments(hf_api: HfApi) -> list[str]: | |
| environments: list[str] = [] | |
| files = hf_api.list_repo_files(MODEL_REPO, repo_type=MODEL_REPO_TYPE) | |
| for file in files: | |
| vals = file.split("/") | |
| # e.g. ['models', 'CartPole-v1', 'results.yaml'] | |
| if len(vals) == ENV_RESULTS_FILE_DEPTH and vals[2] == "results.yaml" and vals[0] == "models": | |
| environments.append(vals[1]) | |
| return environments | |