Skip to content

Commit 151df98

Browse files
committed
fix resolution of subworkflows
1 parent 37f4dc2 commit 151df98

4 files changed

Lines changed: 18 additions & 25 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- fixed a bug with Dockerfile path resolution
99
- handle NetworkAccess Requirment in runner
1010
- inherit parents requirements correclty
11-
- ramping up runner conformance from 160/378 to 188/378
11+
- ramping up runner conformance from 160/378 to 192/378
1212

1313
# v0.5.2
1414
## 🐛 Bugfixes

crates/cwl-execution/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ pub fn execute(
108108
CWLDocument::CommandLineTool(_) | CWLDocument::ExpressionTool(_) => run_tool(
109109
&mut doc,
110110
input_values,
111-
Some(&cwlfile.as_ref().to_path_buf()),
111+
&cwlfile.as_ref().to_path_buf(),
112112
outdir.map(|d| d.as_ref().to_string_lossy().into_owned()),
113113
),
114114
CWLDocument::Workflow(mut workflow) => run_workflow(
115115
&mut workflow,
116116
input_values,
117-
Some(&cwlfile.as_ref().to_path_buf()),
117+
&cwlfile.as_ref().to_path_buf(),
118118
outdir.map(|d| d.as_ref().to_string_lossy().into_owned()),
119119
),
120120
}

crates/cwl-execution/src/runner.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use wait_timeout::ChildExt;
4242
pub fn run_workflow(
4343
workflow: &mut Workflow,
4444
input_values: &InputObject,
45-
cwl_path: Option<&PathBuf>,
45+
cwl_path: &PathBuf,
4646
out_dir: Option<String>,
4747
) -> Result<HashMap<String, DefaultValue>, Box<dyn Error>> {
4848
let clock = Instant::now();
@@ -58,7 +58,12 @@ pub fn run_workflow(
5858
current.to_string_lossy().into_owned()
5959
};
6060

61-
let workflow_folder = cwl_path.unwrap().parent().unwrap_or(Path::new("."));
61+
let workflow_folder = if cwl_path.is_file() {
62+
cwl_path.parent().unwrap_or(Path::new("."))
63+
} else {
64+
cwl_path
65+
};
66+
6267
let input_values = input_values.handle_requirements(&workflow.requirements, &workflow.hints);
6368

6469
//prevent tool from outputting
@@ -187,24 +192,20 @@ pub fn run_workflow(
187192
}
188193
}
189194

190-
info!(
191-
"✔️ Workflow {:?} executed successfully in {:.0?}!",
192-
&cwl_path.unwrap_or(&PathBuf::default()),
193-
clock.elapsed()
194-
);
195+
info!("✔️ Workflow {:?} executed successfully in {:.0?}!", &cwl_path, clock.elapsed());
195196
Ok(output_values.into_iter().map(|(k, v)| (k.clone(), v)).collect())
196197
}
197198

198199
pub fn run_tool(
199200
tool: &mut CWLDocument,
200201
input_values: &InputObject,
201-
cwl_path: Option<&PathBuf>,
202+
cwl_path: &PathBuf,
202203
out_dir: Option<String>,
203204
) -> Result<HashMap<String, DefaultValue>, Box<dyn Error>> {
204205
//measure performance
205206
let clock = Instant::now();
206207
if !print_output() {
207-
info!("🚲 Executing Tool {:?} ...", cwl_path.unwrap_or(&PathBuf::default()));
208+
info!("🚲 Executing Tool {:?} ...", cwl_path);
208209
}
209210
//create staging directory
210211
let dir = tempdir()?;
@@ -215,11 +216,7 @@ pub fn run_tool(
215216
let output_directory = if let Some(out) = out_dir { &PathBuf::from(out) } else { &current };
216217

217218
//set tool path. all paths are given relative to the tool
218-
let tool_path = if let Some(file) = cwl_path.as_ref() {
219-
file.parent().unwrap()
220-
} else {
221-
Path::new(".")
222-
};
219+
let tool_path = cwl_path.parent().unwrap_or(Path::new("."));
223220

224221
//create runtime tmpdir
225222
let tmp_dir = tempdir()?;
@@ -295,11 +292,7 @@ pub fn run_tool(
295292
//come back to original directory
296293
env::set_current_dir(current)?;
297294

298-
info!(
299-
"✔️ Tool {:?} executed successfully in {:.0?}!",
300-
&cwl_path.unwrap_or(&PathBuf::default()),
301-
clock.elapsed()
302-
);
295+
info!("✔️ Tool {:?} executed successfully in {:.0?}!", &cwl_path, clock.elapsed());
303296
Ok(outputs)
304297
}
305298

tests/runner_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use cwl_execution::{
77
};
88
use s4n::parser::parse_command_line;
99
use serial_test::serial;
10-
use std::{collections::HashMap, fs, path::Path};
10+
use std::{collections::HashMap, fs, path::{Path, PathBuf}};
1111
use tempfile::tempdir;
1212

1313
#[test]
@@ -188,7 +188,7 @@ baseCommand:
188188
";
189189

190190
let mut tool: CWLDocument = serde_yaml::from_str(cwl).expect("Tool parsing failed");
191-
let result = run_tool(&mut tool, &Default::default(), None, None);
191+
let result = run_tool(&mut tool, &Default::default(), &PathBuf::default(), None);
192192
assert!(result.is_ok());
193193
//delete results.txt
194194
let _ = fs::remove_file("results.txt");
@@ -203,6 +203,6 @@ baseCommand:
203203
pub fn test_run_commandlinetool_array_glob() {
204204
let dir = tempdir().unwrap();
205205
let mut tool = CWLDocument::CommandLineTool(load_tool("tests/test_data/array_test.cwl").expect("Tool parsing failed"));
206-
let result = run_tool(&mut tool, &Default::default(), None, Some(dir.path().to_string_lossy().into_owned()));
206+
let result = run_tool(&mut tool, &Default::default(), &PathBuf::default(), Some(dir.path().to_string_lossy().into_owned()));
207207
assert!(result.is_ok(), "{result:?}");
208208
}

0 commit comments

Comments
 (0)