mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-19 08:05:20 +00:00
actually pass env to popen
This commit is contained in:
1 parent
cc4b7deaa9
commit
413960b6cf
3 files changed
+19
No files matched your search
Generated
+1
@@ -17,6 +17,7 @@
|
||||
<w>hanashi</w>
|
||||
<w>hifigan</w>
|
||||
<w>hparams</w>
|
||||
<w>huggingface</w>
|
||||
<w>replayable</w>
|
||||
<w>retryably</w>
|
||||
<w>scrollback</w>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use crate::AnyhowResult;
|
||||
use filesys::path_to_string::path_to_string;
|
||||
use log::info;
|
||||
@@ -20,6 +21,9 @@ pub struct VitsInferenceCommand {
|
||||
/// eg. `python3`
|
||||
maybe_override_python_interpreter: Option<String>,
|
||||
|
||||
/// The directory huggingface should cache models
|
||||
maybe_huggingface_cache_dir: Option<String>,
|
||||
|
||||
/// If this is run under Docker (eg. in development), these are the options.
|
||||
maybe_docker_options: Option<DockerOptions>,
|
||||
}
|
||||
@@ -55,12 +59,14 @@ impl VitsInferenceCommand {
|
||||
inference_script_name: P,
|
||||
maybe_override_python_interpreter: Option<&str>,
|
||||
maybe_virtual_env_activation_command: Option<&str>,
|
||||
maybe_huggingface_cache_directory: Option<&str>,
|
||||
maybe_docker_options: Option<DockerOptions>,
|
||||
) -> Self {
|
||||
Self {
|
||||
vits_root_code_directory: vits_root_code_directory.as_ref().to_path_buf(),
|
||||
inference_script_name: inference_script_name.as_ref().to_path_buf(),
|
||||
maybe_virtual_env_activation_command: maybe_virtual_env_activation_command.map(|s| s.to_string()),
|
||||
maybe_huggingface_cache_dir: maybe_huggingface_cache_directory.map(|s| s.to_string()),
|
||||
maybe_override_python_interpreter: maybe_override_python_interpreter.map(|s| s.to_string()),
|
||||
maybe_docker_options,
|
||||
}
|
||||
@@ -128,6 +134,14 @@ impl VitsInferenceCommand {
|
||||
&command
|
||||
];
|
||||
|
||||
let mut config = PopenConfig::default();
|
||||
|
||||
if let Some(cache_dir) = self.maybe_huggingface_cache_dir.as_deref() {
|
||||
let name = OsString::from("HF_DATASETS_CACHE");
|
||||
let value = OsString::from(cache_dir);
|
||||
config.env = Some(vec![(name, value)])
|
||||
}
|
||||
|
||||
let mut p = Popen::create(&command_parts, PopenConfig {
|
||||
..Default::default()
|
||||
})?;
|
||||
|
||||
@@ -304,6 +304,9 @@ fn vits_inference_command() -> AnyhowResult<VitsInferenceCommand> {
|
||||
let maybe_python_interpreter = easyenv::get_env_string_optional(
|
||||
"VITS_INFERENCE_MAYBE_PYTHON_INTERPRETER");
|
||||
|
||||
let maybe_huggingface_dataset_cache = easyenv::get_env_string_optional(
|
||||
"HF_DATASETS_CACHE");
|
||||
|
||||
let maybe_docker_options = easyenv::get_env_string_optional(
|
||||
"VITS_INFERENCE_MAYBE_DOCKER_IMAGE_SHA")
|
||||
.map(|image_name| {
|
||||
@@ -319,6 +322,7 @@ fn vits_inference_command() -> AnyhowResult<VitsInferenceCommand> {
|
||||
inference_script,
|
||||
maybe_python_interpreter.as_deref(),
|
||||
maybe_venv_command.as_deref(),
|
||||
maybe_huggingface_dataset_cache.as_deref(),
|
||||
maybe_docker_options,
|
||||
))
|
||||
}
|
||||
Reference in new issue
Block a user