langflow/scripts/factory_restart_space.py
Gabriel Luiz Freitas Almeida 54dd81a681
chore: removes Poetry references from pyproject.toml and updates the project metadata (#4019)
* Remove Poetry references from pyproject.toml and update project metadata

* Remove '--no-update' flag from 'uv lock' commands in Makefile

* Add script metadata with Python version and dependencies

* Remove Poetry references and integrate UV setup in CI workflow

* Remove Poetry setup and installation from integration tests workflow

* Remove Poetry references and update workflow to use custom setup action

* Remove references to Poetry from configuration files
2024-10-04 17:24:55 +00:00

39 lines
923 B
Python

# /// script
# requires-python = ">=3.10"
# dependencies = [
# "huggingface-hub",
# "rich",
# ]
# ///
import argparse
from huggingface_hub import HfApi, list_models
from rich import print
# Use root method
models = list_models()
args = argparse.ArgumentParser(description="Restart a space in the Hugging Face Hub.")
args.add_argument("--space", type=str, help="The space to restart.")
args.add_argument("--token", type=str, help="The Hugging Face API token.")
parsed_args = args.parse_args()
space = parsed_args.space
if not space:
print("Please provide a space to restart.")
exit()
if not parsed_args.token:
print("Please provide an API token.")
exit()
# Or configure a HfApi client
hf_api = HfApi(
endpoint="https://huggingface.co", # Can be a Private Hub endpoint.
token=parsed_args.token,
)
space_runtime = hf_api.restart_space(space, factory_reboot=True)
print(space_runtime)