| 577 | throw std::runtime_error("workflow step cannot specify both device and device_name"); |
| 578 | } |
| 579 | if (backend.has_value()) { |
| 580 | fallback.type = minitts::cli::parse_backend(*backend); |
| 581 | fallback.impl.clear(); |
| 582 | } |
| 583 | if (device_name.has_value()) { |
| 584 | const std::optional<engine::core::BackendType> filter = |
| 585 | backend.has_value() ? std::optional<engine::core::BackendType>(fallback.type) : std::nullopt; |
| 586 | const auto resolved = engine::core::resolve_backend_device(*device_name, filter); |
| 587 | if (resolved.type != fallback.type) { |
| 588 | fallback.impl.clear(); |
| 589 | } |
| 590 | fallback.type = resolved.type; |
| 591 | fallback.device = resolved.device; |
| 592 | } else if (device.has_value()) { |
| 593 | fallback.device = static_cast<int>(*device); |
| 594 | } |
| 595 | if (impl.has_value()) { |
| 596 | fallback.impl = *impl; |
| 597 | } |
| 598 | if (const auto threads = workflow_optional_number(step, "threads")) { |
| 599 | fallback.threads = static_cast<int>(*threads); |
| 600 | } |
| 601 | if (fallback.threads <= 0) { |
| 602 | throw std::runtime_error("workflow step threads must be positive"); |
| 603 | } |
| 604 | return fallback; |
| 605 | } |
| 606 | |
| 607 | void run_model_step_impl( |
| 608 | const engine::runtime::ModelRegistry & registry, |
| 609 | const engine::io::json::Value & step, |
| 610 | const WorkflowRunOptions & options, |
| 611 | WorkflowContext & context) { |
| 612 | const std::string id = workflow_string(step, "id"); |
| 613 | const auto request_value = step.find("request"); |
| 614 | if (request_value == nullptr || request_value->is_null()) { |
| 615 | throw std::runtime_error("model step requires request object: " + id); |
| 616 | } |
| 617 | |
| 618 | engine::runtime::ModelLoadRequest load_request; |
| 619 | load_request.model_path = resolve_workflow_path(workflow_string(step, "model"), context); |
| 620 | load_request.model_spec_override = options.model_spec_override; |
| 621 | if (const auto family = workflow_optional_string(step, "family")) { |
| 622 | load_request.family_hint = *family; |
| 623 | } |
| 624 | if (const auto config = workflow_optional_string(step, "config")) { |
| 625 | load_request.config_id = *config; |
| 626 | } |
| 627 | if (const auto weight = workflow_optional_string(step, "weight")) { |
| 628 | load_request.weight_id = *weight; |
| 629 | } |
| 630 | load_request.options = merged_options(options.load_options, step.find("load_options"), context); |
| 631 | |
| 632 | engine::runtime::SessionOptions session_options; |
| 633 | session_options.backend = parse_step_backend(step, options.backend); |
| 634 | session_options.options = merged_options(options.session_options, step.find("session_options"), context); |
| 635 | |
| 636 | const engine::runtime::TaskSpec task_spec{ |
no test coverage detected