File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,4 @@ jobs:
100
100
101
101
- name : Restart HuggingFace Spaces Build
102
102
run : |
103
- poetry run python ./scripts/factory_restart_space.py
104
- env :
105
- HUGGINGFACE_API_TOKEN : ${{ secrets.HUGGINGFACE_API_TOKEN }}
103
+ poetry run python ./scripts/factory_restart_space.py --space "Langflow/Langflow-Preview" --token ${{ secrets.HUGGINGFACE_API_TOKEN }}
Original file line number Diff line number Diff line change 1
- import os
1
+ import argparse
2
2
3
3
from huggingface_hub import HfApi , list_models
4
4
from rich import print
5
5
6
6
# Use root method
7
7
models = list_models ()
8
8
9
+ args = argparse .ArgumentParser (description = "Restart a space in the Hugging Face Hub." )
10
+ args .add_argument ("--space" , type = str , help = "The space to restart." )
11
+ args .add_argument ("--token" , type = str , help = "The Hugging Face API token." )
12
+
13
+ parsed_args = args .parse_args ()
14
+
15
+ space = parsed_args .space
16
+
17
+ if not space :
18
+ print ("Please provide a space to restart." )
19
+ exit ()
20
+
21
+ if not parsed_args .api_token :
22
+ print ("Please provide an API token." )
23
+ exit ()
24
+
9
25
# Or configure a HfApi client
10
26
hf_api = HfApi (
11
27
endpoint = "https://huggingface.co" , # Can be a Private Hub endpoint.
12
- token = os . getenv ( "HUGGINFACE_API_TOKEN" ) ,
28
+ token = parsed_args . token ,
13
29
)
14
30
15
- space_runtime = hf_api .restart_space ("Langflow/Langflow-Preview" , factory_reboot = True )
31
+ space_runtime = hf_api .restart_space (space , factory_reboot = True )
16
32
print (space_runtime )
You can’t perform that action at this time.
0 commit comments