Spaces:
Sleeping
Sleeping
Download scripts/check_hf_token.py from build-small-hackathon/Myco: direct link, hf CLI and curl.
- Browser
- Download file 931 Bytes
-
https://huggingface.co/spaces/build-small-hackathon/Myco/resolve/5b6725d501a8e358094de1531e00a92e938dcfc9/scripts/check_hf_token.py
- Command line
-
hf download hf://spaces/build-small-hackathon/Myco@5b6725d501a8e358094de1531e00a92e938dcfc9/scripts/check_hf_token.py
-
curl -L -o check_hf_token.py https://huggingface.co/spaces/build-small-hackathon/Myco/resolve/5b6725d501a8e358094de1531e00a92e938dcfc9/scripts/check_hf_token.py
931 Bytes
| """Check whether the Hugging Face deployment token is available.""" | |
| from __future__ import annotations | |
| import os | |
| from pathlib import Path | |
| TOKEN_ENV_VAR = "HF_BUILD_SMALL_HACKATHON_TOKEN" | |
| def main() -> None: | |
| """Emit a GitHub Actions output instead of raising KeyError for a missing token.""" | |
| token = os.environ.get(TOKEN_ENV_VAR, "").strip() | |
| available = "true" if token else "false" | |
| github_output = os.environ.get("GITHUB_OUTPUT") | |
| if github_output: | |
| with Path(github_output).open("a", encoding="utf-8") as output_file: | |
| output_file.write(f"available={available}\n") | |
| if token: | |
| print(f"{TOKEN_ENV_VAR} is configured; Hugging Face Space deployment can continue.") | |
| return | |
| print( | |
| f"::warning::{TOKEN_ENV_VAR} is not configured. " | |
| "Skipping Hugging Face Space deployment instead of failing with KeyError." | |
| ) | |
| if __name__ == "__main__": | |
| main() | |