File size: 1,914 Bytes
81663e8 24c0393 81663e8 | 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | """Upload this standalone directory to a Docker Space."""
import argparse
from pathlib import Path
from huggingface_hub import HfApi
ROOT = Path(__file__).resolve().parent
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--repo", required=True)
parser.add_argument("--public", action="store_true")
parser.add_argument("--concurrency", type=int)
args = parser.parse_args()
if args.concurrency is not None and args.concurrency < 1:
parser.error("Concurrency must be positive")
api = HfApi()
api.create_repo(
args.repo,
repo_type="space",
space_sdk="docker",
private=not args.public,
exist_ok=True,
)
variables = api.get_space_variables(args.repo)
concurrency = args.concurrency or (
int(variables["MAX_CONCURRENT_ENVS"].value)
if "MAX_CONCURRENT_ENVS" in variables
else 40
)
api.add_space_variable(args.repo, "MAX_CONCURRENT_ENVS", str(concurrency))
api.add_space_variable(args.repo, "ENABLE_WEB_INTERFACE", "true")
api.upload_folder(
repo_id=args.repo,
repo_type="space",
folder_path=ROOT,
allow_patterns=[
"*.py",
"*.json",
"*.toml",
"*.txt",
"*.sh",
"*.yaml",
"README.md",
"Dockerfile",
".dockerignore",
".gitignore",
".gitattributes",
],
ignore_patterns=[
".deps/**",
".venv/**",
"prepared/**",
".archive/**",
"**/__pycache__/**",
"**/*.egg-info/**",
".env",
".git/**",
],
commit_message="Deploy SmolDataEnvs Multi-harness | Native OpenCode",
)
print(f"https://huggingface.co/spaces/{args.repo}")
if __name__ == "__main__":
main()
|