diff --git a/libraries/core/src/descriptor/mod.rs b/libraries/core/src/descriptor/mod.rs index fc836412a..f764de614 100644 --- a/libraries/core/src/descriptor/mod.rs +++ b/libraries/core/src/descriptor/mod.rs @@ -417,12 +417,7 @@ pub fn source_is_url(source: &str) -> bool { } pub fn resolve_path(source: &str, working_dir: &Path) -> Result { - let path = Path::new(&source); - let path = if path.extension().is_none() { - path.with_extension(EXE_EXTENSION) - } else { - path.to_owned() - }; + let path = source_to_path(source); // Search path within current working directory if let Ok(abs_path) = working_dir.join(&path).canonicalize() { @@ -435,6 +430,16 @@ pub fn resolve_path(source: &str, working_dir: &Path) -> Result { } } +fn source_to_path(source: &str) -> PathBuf { + let path = Path::new(&source); + let path = if path.extension().is_none() { + path.with_extension(EXE_EXTENSION) + } else { + path.to_owned() + }; + path +} + #[derive(Debug, Serialize, Deserialize, Clone)] #[serde(deny_unknown_fields)] pub struct PythonOperatorConfig { diff --git a/libraries/core/src/descriptor/validate.rs b/libraries/core/src/descriptor/validate.rs index fe5580967..fe373cb93 100644 --- a/libraries/core/src/descriptor/validate.rs +++ b/libraries/core/src/descriptor/validate.rs @@ -1,7 +1,7 @@ use crate::{ adjust_shared_library_path, config::{DataId, Input, InputMapping, OperatorId, UserInputMapping}, - descriptor::{self, source_is_url, CoreNodeKind, OperatorSource}, + descriptor::{self, source_is_url, source_to_path, CoreNodeKind, OperatorSource}, get_python_path, }; @@ -19,15 +19,24 @@ pub fn check_dataflow(dataflow: &Descriptor, working_dir: &Path) -> eyre::Result // check that nodes and operators exist for node in &nodes { match &node.kind { - descriptor::CoreNodeKind::Custom(node) => match node.source.as_str() { + descriptor::CoreNodeKind::Custom(custom) => match custom.source.as_str() { SHELL_SOURCE => (), source => { if source_is_url(source) { info!("{source} is a URL."); // TODO: Implement url check. - } else { + } else if node.deploy.machine.is_empty() { resolve_path(source, working_dir) .wrap_err_with(|| format!("Could not find source path `{}`", source))?; - }; + } else { + let path = source_to_path(source); + if path.is_relative() { + eyre::bail!( + "paths of remote nodes must be absolute (node `{}`)", + node.id + ); + } + info!("skipping path check for remote node `{}`", node.id); + } } }, descriptor::CoreNodeKind::Runtime(node) => {