(args: argparse.Namespace, image_path: Path, output_path: Path | None = None)
| 867 | |
| 868 | |
| 869 | def _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 | |
| 913 | def cmd_generate(args: argparse.Namespace) -> int: |
no test coverage detected