diff --git a/crates/service/job/inference_job/config/inference-job.development.env b/crates/service/job/inference_job/config/inference-job.development.env index 9e1d5e5807..957a4f5132 100644 --- a/crates/service/job/inference_job/config/inference-job.development.env +++ b/crates/service/job/inference_job/config/inference-job.development.env @@ -152,6 +152,7 @@ COMFY_INFERENCE_EXECUTABLE_OR_COMMAND="venv/bin/python ../ComfyLauncher/ComfyRun # directory to where files should be downloaded to (default to just the comfy directory) COMFY_MOUNTS_DIRECTORY="/home/salt/clone/storyteller/storyteller-ml/workflows/comfy/ComfyUI/" COMFY_VIDEO_PROCESSING_SCRIPT="/home/salt/clone/storyteller/storyteller-ml/workflows/comfy/format_video.py" +COMFY_SETUP_SCRIPT="/home/salt/clone/storyteller/storyteller-ml/workflows/comfy/install.py" # ================================= # # # diff --git a/crates/service/job/inference_job/src/job/job_types/workflow/comfy_ui/comfy_ui_dependencies.rs b/crates/service/job/inference_job/src/job/job_types/workflow/comfy_ui/comfy_ui_dependencies.rs index fee7faac54..4d1d3b16ef 100644 --- a/crates/service/job/inference_job/src/job/job_types/workflow/comfy_ui/comfy_ui_dependencies.rs +++ b/crates/service/job/inference_job/src/job/job_types/workflow/comfy_ui/comfy_ui_dependencies.rs @@ -1,4 +1,5 @@ use std::path::PathBuf; +use std::process::Command; use errors::AnyhowResult; use crate::job::job_types::workflow::comfy_ui::comfy_ui_inference_command::ComfyInferenceCommand; @@ -10,8 +11,23 @@ pub struct ComfyDependencies { impl ComfyDependencies { pub fn setup() -> AnyhowResult { + // run the setup scripts for the comfy dependencies + let inference_command = ComfyInferenceCommand::from_env()?; + // check to see if the flag file exists + if PathBuf::from("comfy_setup_complete").exists() { + println!("Comfy setup already complete"); + } else { + // if the flag file does not exist, run the setup script + // run setup script + let comfy_setup_script = inference_command.clone().comfy_setup_script; + let output = Command::new("python3") + .arg(comfy_setup_script) + .output() + .expect("failed to run comfyui setup script"); + println!("stdout: {}", String::from_utf8_lossy(&output.stdout)); + } Ok(Self { - inference_command: ComfyInferenceCommand::from_env()?, + inference_command: inference_command, dependency_tokens: RequiredModels::init(), }) } 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 f5999aef88..805494f956 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 @@ -44,6 +44,8 @@ pub struct ComfyInferenceCommand { // Video processing script pub(crate) processing_script: PathBuf, + pub(crate) comfy_setup_script: PathBuf, + /// Config file to use config_path: Option, @@ -95,6 +97,9 @@ impl ComfyInferenceCommand { } }; + let comfy_setup_script = easyenv::get_env_pathbuf_required( + "COMFY_SETUP_SCRIPT")?; + let maybe_virtual_env_activation_command = easyenv::get_env_string_optional( "COMFY_INFERENCE_MAYBE_VENV_COMMAND"); @@ -124,6 +129,7 @@ impl ComfyInferenceCommand { config_path, mounts_directory, processing_script, + comfy_setup_script, maybe_virtual_env_activation_command, maybe_docker_options, maybe_execution_timeout,