MCPcopy
hub / github.com/lightningpixel/modly / _generate_one

Function _generate_one

tools/modly-cli/agent.py:869–910  ·  view source on GitHub ↗
(args: argparse.Namespace, image_path: Path, output_path: Path | None = None)

Source from the content-addressed store, hash-verified

867
868
869def _generate_one(args: argparse.Namespace, image_path: Path, output_path: Path | None = None) -> dict[str, Any]:
870 base_url = args.base_url.rstrip("/")
871 _require_health(base_url, args.request_timeout)
872 image_path = image_path.expanduser().resolve()
873 if not image_path.exists() or not image_path.is_file():
874 raise ModlyCliError(f"image file not found: {image_path}", code="IMAGE_NOT_FOUND")
875
876 _ensure_no_external_texture_process(args)
877 params = _canonical_generation_params(args)
878 model_id = _resolve_model_id(args, base_url)
879 run_id, status, rel_path = _run_workflow_run(
880 args,
881 image_path,
882 base_url=base_url,
883 model_id=model_id,
884 params=params,
885 wait=True,
886 )
887 assert rel_path is not None
888
889 export_dest = None
890 bytes_written = None
891 if not getattr(args, "no_export", False):
892 export_dest = output_path or image_path.resolve().parent / f"{Path(rel_path).stem}.{args.format}"
893 export_dest = export_dest.expanduser().resolve()
894 bytes_written = _export_workspace_path(base_url, rel_path, args.format, export_dest, timeout=args.request_timeout)
895 result: dict[str, Any] = {
896 "ok": True,
897 "base_url": base_url,
898 "image": str(image_path),
899 "model_id": model_id,
900 "run": {"kind": "workflowRun", "id": run_id},
901 "status": status,
902 "workspace_path": rel_path,
903 "texture_enabled": bool(params.get("enable_texture")),
904 "export_format": args.format,
905 "meta": _recovery_meta(base_url, run_id),
906 }
907 if export_dest is not None:
908 result["export_path"] = str(export_dest)
909 result["bytes_written"] = bytes_written
910 return result
911
912
913def cmd_generate(args: argparse.Namespace) -> int:

Callers 3

cmd_generateFunction · 0.85
cmd_batchFunction · 0.85

Calls 8

_require_healthFunction · 0.85
ModlyCliErrorClass · 0.85
_resolve_model_idFunction · 0.85
_run_workflow_runFunction · 0.85
_export_workspace_pathFunction · 0.85
_recovery_metaFunction · 0.85

Tested by

no test coverage detected