mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-07 02:21:23 +00:00
root directory option for downloader
This commit is contained in:
1 parent
d28fb07d6d
commit
ba52695f35
3 files changed
+20
-15
No files matched your search
@@ -15,5 +15,3 @@ HIFIGAN_MODEL_CHECK_ROOT_DIRECTORY=/models/tts
|
||||
HIFIGAN_MODEL_CHECK_MAYBE_VENV_COMMAND="source python/bin/activate"
|
||||
HIFIGAN_MODEL_CHECK_COMMAND=./vocodes_model_check_hifigan.py
|
||||
HIFIGAN_MODEL_CHECK_MAYBE_DOCKER_IMAGE=5642d0fd7fc1
|
||||
|
||||
|
||||
@@ -20,21 +20,29 @@ use tempdir::TempDir;
|
||||
/// --output_filename (local download filename)
|
||||
#[derive(Clone)]
|
||||
pub struct GoogleDriveDownloadCommand {
|
||||
/// The python downloader script.
|
||||
download_script: String,
|
||||
|
||||
/// If present, change to this directory before doing anything.
|
||||
maybe_change_to_directory: Option<String>,
|
||||
|
||||
/// If a virtual environment is necessary, this is the name of the activation script (which will be sourced.)
|
||||
maybe_venv_activation_script: Option<String>,
|
||||
|
||||
/// If this is run under Docker (eg. in development), these are the options.
|
||||
/// If this is run under Docker (eg. in development), these are the options for Docker (GPU, mount, etc.)
|
||||
maybe_docker_options: Option<DockerOptions>,
|
||||
}
|
||||
|
||||
impl GoogleDriveDownloadCommand {
|
||||
pub fn new(
|
||||
download_script: &str,
|
||||
maybe_change_to_directory: Option<&str>,
|
||||
maybe_venv_activation_script: Option<&str>,
|
||||
maybe_docker_options: Option<DockerOptions>
|
||||
) -> Self {
|
||||
Self {
|
||||
download_script: download_script.to_string(),
|
||||
maybe_change_to_directory: maybe_change_to_directory.map(|s| s.to_string()),
|
||||
maybe_venv_activation_script: maybe_venv_activation_script.map(|s| s.to_string()),
|
||||
maybe_docker_options,
|
||||
}
|
||||
@@ -43,23 +51,12 @@ impl GoogleDriveDownloadCommand {
|
||||
pub fn new_production(download_script: &str) -> Self {
|
||||
Self {
|
||||
download_script: download_script.to_string(),
|
||||
maybe_change_to_directory: None,
|
||||
maybe_venv_activation_script: None,
|
||||
maybe_docker_options: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_local_dev_docker(
|
||||
download_script: &str,
|
||||
venv_activation_script: &str,
|
||||
docker_options: DockerOptions
|
||||
) -> Self {
|
||||
Self {
|
||||
download_script: download_script.to_string(),
|
||||
maybe_venv_activation_script: Some(venv_activation_script.to_string()),
|
||||
maybe_docker_options: Some(docker_options),
|
||||
}
|
||||
}
|
||||
|
||||
/// Download file from Google Drive into the `TempDir`.
|
||||
/// Return the local filesystem filename.
|
||||
pub async fn download_file(&self,
|
||||
@@ -88,6 +85,12 @@ impl GoogleDriveDownloadCommand {
|
||||
&command);
|
||||
}
|
||||
|
||||
if let Some(change_to_directory) = self.maybe_change_to_directory.as_deref() {
|
||||
command = format!("cd {} && {}",
|
||||
change_to_directory,
|
||||
&command);
|
||||
}
|
||||
|
||||
if let Some(docker_options) = self.maybe_docker_options.as_ref() {
|
||||
command = docker_options.to_command_string(&command);
|
||||
}
|
||||
|
||||
@@ -95,6 +95,9 @@ async fn main() -> AnyhowResult<()> {
|
||||
// =============== Configure Python "Sidecars" ===============
|
||||
|
||||
let google_drive_downloader = {
|
||||
let maybe_root_directory = easyenv::get_env_string_optional(
|
||||
"WEB_DOWNLOADER_MAYBE_ROOT_DIRECTORY");
|
||||
|
||||
let downloader_command= easyenv::get_env_string_or_default(
|
||||
"WEB_DOWNLOADER_COMMAND", // TODO: Was "DOWNLOAD_SCRIPT" in old apps
|
||||
"./download_internet_file.py");
|
||||
@@ -114,6 +117,7 @@ async fn main() -> AnyhowResult<()> {
|
||||
|
||||
GoogleDriveDownloadCommand::new(
|
||||
&downloader_command,
|
||||
maybe_root_directory.as_deref(),
|
||||
maybe_downloader_venv_script.as_deref(),
|
||||
docker_options,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user