diff --git a/crates/service/job/inference_job/src/job/job_types/workflow/comfy_ui/comfy_ui_inference_command.rs b/crates/service/job/inference_job/src/job/job_types/workflow/comfy_ui/comfy_ui_inference_command.rs index b62110d84a..548ab0fd55 100644 --- a/crates/service/job/inference_job/src/job/job_types/workflow/comfy_ui/comfy_ui_inference_command.rs +++ b/crates/service/job/inference_job/src/job/job_types/workflow/comfy_ui/comfy_ui_inference_command.rs @@ -82,28 +82,36 @@ pub struct InferenceArgs<'s> { pub stderr_output_file: &'s Path, pub stdout_output_file: &'s Path, - /// Location of the prompt JSON file - pub prompt_location: &'s Path, - - /// Positive prompt file. - /// If set, Python will be in charge of overwriting the prompt JSON file - /// with the correct workflow args. - pub maybe_positive_prompt_filename: Option<&'s Path>, - - /// Negative prompt file. - /// If set, Python will be in charge of overwriting the prompt JSON file - /// with the correct workflow args. - pub maybe_negative_prompt_filename: Option<&'s Path>, - - /// Style name - /// If set, Python will be in charge of overwriting the prompt JSON file - /// with the correct workflow args. - pub maybe_style: Option, + pub inference_details: InferenceDetails<'s>, pub face_detailer_enabled: bool, pub upscaler_enabled: bool, } +pub enum InferenceDetails<'s> { + OldRustArgs { + /// Location of the prompt JSON file + /// Optional: This is used if the Rust side controls this prompt JSON construction. + prompt_location: PathBuf, + }, + NewPythonArgs { + /// Positive prompt file. + /// Optional: If set, Python will be in charge of overwriting the prompt JSON file + /// with the correct workflow args. + maybe_positive_prompt_filename: Option<&'s Path>, + + /// Negative prompt file. + /// Optional: If set, Python will be in charge of overwriting the prompt JSON file + /// with the correct workflow args. + maybe_negative_prompt_filename: Option<&'s Path>, + + /// Style name + /// Optional: If set, Python will be in charge of overwriting the prompt JSON file + /// with the correct workflow args. + maybe_style: Option, + }, +} + impl ComfyInferenceCommand { pub fn from_env() -> AnyhowResult { let comfy_root_code_directory = easyenv::get_env_pathbuf_required( @@ -215,26 +223,35 @@ impl ComfyInferenceCommand { } } - command.push_str(" --prompt "); - command.push_str(&path_to_string(args.prompt_location)); - command.push_str(" "); + match args.inference_details { + InferenceDetails::OldRustArgs { ref prompt_location } => { + command.push_str(" --prompt "); + command.push_str(&path_to_string(prompt_location)); + command.push_str(" "); + } + InferenceDetails::NewPythonArgs { + maybe_positive_prompt_filename, + maybe_negative_prompt_filename, + maybe_style + } => { + if let Some(positive_prompt_filename) = maybe_positive_prompt_filename { + command.push_str(" --positive_prompt_filename "); + command.push_str(&path_to_string(positive_prompt_filename)); + command.push_str(" "); + } - if let Some(positive_prompt_filename) = args.maybe_positive_prompt_filename { - command.push_str(" --positive_prompt_filename "); - command.push_str(&path_to_string(positive_prompt_filename)); - command.push_str(" "); - } + if let Some(negative_prompt_filename) = maybe_negative_prompt_filename { + command.push_str(" --negative_prompt_filename "); + command.push_str(&path_to_string(negative_prompt_filename)); + command.push_str(" "); + } - if let Some(negative_prompt_filename) = args.maybe_negative_prompt_filename { - command.push_str(" --negative_prompt_filename "); - command.push_str(&path_to_string(negative_prompt_filename)); - command.push_str(" "); - } - - if let Some(style) = args.maybe_style { - command.push_str(" --style "); - command.push_str(style.to_str()); - command.push_str(" "); + if let Some(style) = maybe_style { + command.push_str(" --style "); + command.push_str(style.to_str()); + command.push_str(" "); + } + } } if args.face_detailer_enabled { diff --git a/crates/service/job/inference_job/src/job/job_types/workflow/comfy_ui/process_job.rs b/crates/service/job/inference_job/src/job/job_types/workflow/comfy_ui/process_job.rs index f0cc4e77c8..495fc2790a 100644 --- a/crates/service/job/inference_job/src/job/job_types/workflow/comfy_ui/process_job.rs +++ b/crates/service/job/inference_job/src/job/job_types/workflow/comfy_ui/process_job.rs @@ -39,7 +39,7 @@ use tokens::tokens::prompts::PromptToken; use crate::job::job_loop::job_success_result::{JobSuccessResult, ResultEntity}; use crate::job::job_loop::process_single_job_error::ProcessSingleJobError; -use crate::job::job_types::workflow::comfy_ui::comfy_ui_inference_command::InferenceArgs; +use crate::job::job_types::workflow::comfy_ui::comfy_ui_inference_command::{InferenceArgs, InferenceDetails}; use crate::job::job_types::workflow::comfy_ui::job_outputs::JobOutputs; use crate::job::job_types::workflow::comfy_ui::validate_job::validate_job; use crate::job_dependencies::JobDependencies; @@ -374,29 +374,41 @@ pub async fn process_job(args: ComfyProcessJobArgs<'_>) -> Result) -> Result