remove (unused) tts-inference-job shell out code

This commit is contained in:
Brandon Thomas committed 2023-11-27 20:55:13 -05:00
1 parent bf5dddf6a9
commit eaadc8242d
4 files changed
-140

No files matched your search

@@ -16,7 +16,6 @@ use crate::caching::cache_miss_strategizer_multi::SyncMultiCacheMissStrategizer;
use crate::caching::virtual_lfu_cache::SyncVirtualLfuCache;
use crate::http_clients::tts_inference_sidecar_client::TtsInferenceSidecarClient;
use crate::http_clients::tts_sidecar_health_check_client::TtsSidecarHealthCheckClient;
use crate::script_execution::tacotron_inference_command::TacotronInferenceCommand;
use crate::util::scoped_temp_dir_creator::ScopedTempDirCreator;
pub struct JobArgs {
@@ -39,8 +38,6 @@ pub struct JobArgs {
pub job_stats: JobStats,
pub tts_inference_command: TacotronInferenceCommand,
pub newrelic_client: NewRelicClient,
pub newrelic_disabled: bool,
@@ -59,13 +59,11 @@ use crate::job_steps::job_args::{JobArgs, JobCaches, JobHttpClients};
use crate::job_steps::job_args::JobWorkerDetails;
use crate::job_steps::process_single_job::process_single_job;
use crate::job_steps::process_single_job_error::ProcessSingleJobError;
use crate::script_execution::tacotron_inference_command::TacotronInferenceCommand;
use crate::util::scoped_temp_dir_creator::ScopedTempDirCreator;
pub mod caching;
pub mod http_clients;
pub mod job_steps;
pub mod script_execution;
pub mod util;
// Buckets (shared config)
@@ -154,14 +152,6 @@ async fn main() -> AnyhowResult<()> {
Some(bucket_timeout),
)?;
let py_code_directory = easyenv::get_env_string_required(ENV_CODE_DIRECTORY)?;
let py_script_name = easyenv::get_env_string_required(ENV_INFERENCE_SCRIPT_NAME)?;
let tts_inference_command = TacotronInferenceCommand::new(
&py_code_directory,
&py_script_name,
);
let mut sidecar_hostname =
easyenv::get_env_string_required(ENV_TTS_INFERENCE_SIDECAR_HOSTNAME)?;
@@ -306,7 +296,6 @@ async fn main() -> AnyhowResult<()> {
job_progress_reporter,
public_bucket_client,
private_bucket_client,
tts_inference_command,
http_clients: JobHttpClients {
tts_inference_sidecar_client,
tts_sidecar_health_check_client,
@@ -1 +0,0 @@
pub mod tacotron_inference_command;
@@ -1,125 +0,0 @@
use std::fs::OpenOptions;
use std::path::Path;
use log::info;
use subprocess::{Popen, PopenConfig, Redirection};
use crate::AnyhowResult;
/// This command is used to run inference.
#[derive(Clone)]
pub struct TacotronInferenceCommand {
tacotron_directory: String,
inference_script_name: String,
}
impl TacotronInferenceCommand {
pub fn new(
tacotron_directory: &str,
inference_script_name: &str,
) -> Self {
Self {
tacotron_directory: tacotron_directory.to_string(),
inference_script_name: inference_script_name.to_string(),
}
}
pub fn execute<P: AsRef<Path>>(
&self,
synthesizer_checkpoint_path: P,
vocoder_checkpoint_path: P,
input_text_filename: P,
output_audio_filename: P,
output_spectrogram_filename: P,
output_metadata_filename: P,
spawn_process: bool
) -> AnyhowResult<()> {
let mut command = String::new();
command.push_str("echo 'test'");
command.push_str(" && ");
command.push_str(&format!("cd {}", self.tacotron_directory));
command.push_str(" && ");
command.push_str("source python/bin/activate");
command.push_str(" && ");
command.push_str("python ");
command.push_str(&self.inference_script_name);
command.push_str(" --synthesizer_checkpoint_path ");
command.push_str(&synthesizer_checkpoint_path.as_ref().display().to_string());
command.push_str(" --vocoder_checkpoint_path ");
command.push_str(&vocoder_checkpoint_path.as_ref().display().to_string());
command.push_str(" --input_text_filename ");
command.push_str(&input_text_filename.as_ref().display().to_string());
command.push_str(" --output_audio_filename ");
command.push_str(&output_audio_filename.as_ref().display().to_string());
command.push_str(" --output_spectrogram_filename ");
command.push_str(&output_spectrogram_filename.as_ref().display().to_string());
command.push_str(" --output_metadata_filename ");
command.push_str(&output_metadata_filename.as_ref().display().to_string());
info!("Command: {:?}", command);
let command_parts = [
"bash",
"-c",
&command
];
if spawn_process {
// NB: This forks and returns immediately.
//let _child_pid = command_builder.spawn()?;
let stdout_file = OpenOptions::new()
.read(true)
.write(true)
.create(true)
.truncate(true)
.open("/tmp/tacotron_upload_stdout.txt")?;
let stderr_file = OpenOptions::new()
.read(true)
.write(true)
.create(true)
.truncate(true)
.open("/tmp/tacotron_upload_stderr.txt")?;
let mut p = Popen::create(&command_parts, PopenConfig {
//stdout: Redirection::Pipe,
//stderr: Redirection::Pipe,
stdout: Redirection::File(stdout_file),
stderr: Redirection::File(stderr_file),
..Default::default()
})?;
info!("Pid : {:?}", p.pid());
p.detach();
} else {
// NB: This is a blocking call.
/*let output = command_builder.output()?;
info!("Output status: {}", output.status);
info!("Stdout: {:?}", String::from_utf8(output.stdout));
error!("Stderr: {:?}", String::from_utf8(output.stderr));
if !output.status.success() {
bail!("Bad error code: {:?}", output.status);
}*/
let mut p = Popen::create(&command_parts, PopenConfig {
//stdout: Redirection::Pipe,
//stderr: Redirection::Pipe,
..Default::default()
})?;
info!("Pid : {:?}", p.pid());
let exit_status = p.wait()?;
info!("Exit status: {:?}", exit_status);
}
Ok(())
}
}