File size: 897 Bytes
21c7db9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3
"""Pause or downgrade the HF training Space after artifacts are retrieved."""

from __future__ import annotations

import argparse

from huggingface_hub import HfApi


def parse_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser(description="Pause or downgrade the PolyGuard training Space.")
    parser.add_argument("--repo-id", default="TheJackBright/polyguard-openenv-training")
    parser.add_argument("--mode", choices=["pause", "cpu-basic"], default="cpu-basic")
    return parser.parse_args()


def main() -> None:
    args = parse_args()
    api = HfApi()
    if args.mode == "pause":
        runtime = api.pause_space(repo_id=args.repo_id)
    else:
        runtime = api.request_space_hardware(repo_id=args.repo_id, hardware="cpu-basic")
    print(f"space={args.repo_id} mode={args.mode} runtime={runtime}")


if __name__ == "__main__":
    main()