Spaces:
Sleeping
Sleeping
Download scripts/check_hf_token.py from byte-vortex/Myco: direct link, hf CLI and curl.
- Browser
- Download file 931 Bytes
-
https://huggingface.co/spaces/byte-vortex/Myco/resolve/ab514bca52f6e76dba25b640d85db5893bfa279f/scripts/check_hf_token.py
- Command line
-
hf download hf://spaces/byte-vortex/Myco@ab514bca52f6e76dba25b640d85db5893bfa279f/scripts/check_hf_token.py
-
curl -L -o check_hf_token.py https://huggingface.co/spaces/byte-vortex/Myco/resolve/ab514bca52f6e76dba25b640d85db5893bfa279f/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() | |