Download scripts/export_to_creadrug.py from chihsing/DrugOps: direct link, hf CLI and curl.
- Browser
- Download file 1.56 kB
-
https://huggingface.co/spaces/chihsing/DrugOps/resolve/af894e00fa0d85600aee678d54006857568aeb05/scripts/export_to_creadrug.py
- Command line
-
hf download hf://spaces/chihsing/DrugOps@af894e00fa0d85600aee678d54006857568aeb05/scripts/export_to_creadrug.py
-
curl -L -o export_to_creadrug.py https://huggingface.co/spaces/chihsing/DrugOps/resolve/af894e00fa0d85600aee678d54006857568aeb05/scripts/export_to_creadrug.py
1.56 kB
| #!/usr/bin/env python3 | |
| """Export a DrugOps session to CreaDrug24 case pack.""" | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| import sys | |
| from pathlib import Path | |
| UI = Path(__file__).resolve().parents[1] | |
| if str(UI) not in sys.path: | |
| sys.path.insert(0, str(UI)) | |
| from molgate_ui.creadrug_export import export_session_to_creadrug | |
| from molgate_ui.paths import load_env_file | |
| def main() -> int: | |
| load_env_file() | |
| ap = argparse.ArgumentParser(description="Export DrugOps session → CreaDrug24 case") | |
| ap.add_argument("session_id", help="16-char session id") | |
| ap.add_argument("--case-id", help="CreaDrug case id (default M{drug_id} or M_{session8})") | |
| ap.add_argument("--no-overwrite", action="store_true", help="fail if case dir exists") | |
| ap.add_argument("--json", action="store_true", help="print JSON result") | |
| args = ap.parse_args() | |
| result = export_session_to_creadrug( | |
| args.session_id, | |
| case_id=args.case_id, | |
| overwrite=not args.no_overwrite, | |
| ) | |
| if args.json: | |
| print(json.dumps(result, indent=2, ensure_ascii=False)) | |
| elif result.get("ok"): | |
| print(f"OK case={result['case_id']}") | |
| print(f" dir={result['case_dir']}") | |
| print(f" registry={result['registry']}") | |
| print("Next: push CreaDrug24 to stromapath, open showboard with ?case=" + result["case_id"]) | |
| else: | |
| print(f"FAIL {result.get('error', 'unknown')}", file=sys.stderr) | |
| return 0 if result.get("ok") else 1 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |