Skip to content

Commit

Permalink
Fix path checks for nodes on remote machines
Browse files Browse the repository at this point in the history
- don't check paths for remote nodes
- ensure that paths of of remote nodes are absolute
  • Loading branch information
phil-opp committed Jun 5, 2024
1 parent d4ff586 commit 60e4d7d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
17 changes: 11 additions & 6 deletions libraries/core/src/descriptor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,7 @@ pub fn source_is_url(source: &str) -> bool {
}

pub fn resolve_path(source: &str, working_dir: &Path) -> Result<PathBuf> {
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() {
Expand All @@ -435,6 +430,16 @@ pub fn resolve_path(source: &str, working_dir: &Path) -> Result<PathBuf> {
}
}

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

Check warning on line 440 in libraries/core/src/descriptor/mod.rs

View workflow job for this annotation

GitHub Actions / Clippy

returning the result of a `let` binding from a block
}

#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct PythonOperatorConfig {
Expand Down
17 changes: 13 additions & 4 deletions libraries/core/src/descriptor/validate.rs
Original file line number Diff line number Diff line change
@@ -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,
};

Expand All @@ -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) => {
Expand Down

0 comments on commit 60e4d7d

Please sign in to comment.