Spaces:
Running on T4
Running on T4
Download tools/register_sam_api_worker.py from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/3249fe49e382459cd4ccd5ca1883f14ffd8b5ab4/tools/register_sam_api_worker.py
- Command line
-
hf download hf://spaces/modventures/baseball-engine@3249fe49e382459cd4ccd5ca1883f14ffd8b5ab4/tools/register_sam_api_worker.py
-
curl -L -o register_sam_api_worker.py https://huggingface.co/spaces/modventures/baseball-engine/resolve/3249fe49e382459cd4ccd5ca1883f14ffd8b5ab4/tools/register_sam_api_worker.py
1.31 kB
| """Register installed SAM runtime/assets without downloading or loading weights.""" | |
| import argparse | |
| from pathlib import Path | |
| import subprocess | |
| from baseball_batting.storage import atomic_json, sha256_file | |
| from tools.setup_full_worker import SAM_REVISION | |
| def main(): | |
| parser = argparse.ArgumentParser() | |
| for argument in ("worker-python", "sam-repo", "sam-checkpoint", "sam-config", "mhr-path", "output"): | |
| parser.add_argument("--"+argument, required=True) | |
| args = parser.parse_args() | |
| record = {key: str(Path(getattr(args, key)).resolve()) for key in | |
| ("worker_python", "sam_repo", "sam_checkpoint", "sam_config", "mhr_path")} | |
| if not all(Path(value).exists() for value in record.values()): raise ValueError("Configured SAM files are missing") | |
| revision = subprocess.check_output(["git", "-C", record["sam_repo"], "rev-parse", "HEAD"], text=True).strip() | |
| if revision != SAM_REVISION: raise ValueError("SAM source revision differs from pinned adapter") | |
| record.update(source_revision=revision, status="installed_requires_inference", | |
| artifact_hashes={key: sha256_file(record[key]) for key in ("sam_checkpoint", "sam_config", "mhr_path")}) | |
| atomic_json(args.output, record) | |
| print("Registered SAM:", args.output) | |
| if __name__ == "__main__": main() | |