25 lines
622 B
Python
25 lines
622 B
Python
import argparse
|
|
import random
|
|
|
|
from huggingface_hub import HfApi
|
|
|
|
from lib.hf import list_spaces, login
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--token", required=True, help="Your HF API token")
|
|
parser.add_argument("--username", required=True, help="Your HF username")
|
|
args = parser.parse_args()
|
|
|
|
login(args.token)
|
|
|
|
our_spaces = [x.id for x in list_spaces(args.username) if 'proxy' in x.id]
|
|
random.shuffle(our_spaces)
|
|
|
|
for space in our_spaces:
|
|
api = HfApi()
|
|
try:
|
|
api.restart_space(repo_id=space)
|
|
print(space)
|
|
except Exception as e:
|
|
print('Failed to restart space!', e)
|