The factory_restart_space.py script has been updated to use the value of the HUGGINFACE_API_TOKEN environment variable for the HfApi client token. This change improves security by avoiding hardcoding the token in the script and allows for flexibility in different environments. Note: The commit message has been generated based on the provided code changes and recent commits.
16 lines
399 B
Python
16 lines
399 B
Python
import os
|
|
|
|
from huggingface_hub import HfApi, list_models
|
|
from rich import print
|
|
|
|
# Use root method
|
|
models = list_models()
|
|
|
|
# Or configure a HfApi client
|
|
hf_api = HfApi(
|
|
endpoint="https://huggingface.co", # Can be a Private Hub endpoint.
|
|
token=os.getenv("HUGGINFACE_API_TOKEN"),
|
|
)
|
|
|
|
space_runtime = hf_api.restart_space("Langflow/Langflow-Preview", factory_reboot=True)
|
|
print(space_runtime)
|