Skip to content

Commit a2b2bd5

Browse files
committed
minor
1 parent 99222bb commit a2b2bd5

2 files changed

Lines changed: 2 additions & 117 deletions

File tree

crates/cwl-execution/src/runner.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
},
99
format_command,
1010
io::{copy_dir, copy_file, create_and_write_file_forced, get_random_filename, get_shell_command, print_output, set_print_output},
11-
staging::{stage_required_files, unstage_files},
11+
staging::stage_required_files,
1212
util::{
1313
copy_output_dir, evaluate_command_outputs, evaluate_expression_outputs, evaluate_input, evaluate_input_as_string, get_file_metadata,
1414
is_docker_installed,
@@ -254,7 +254,7 @@ pub fn run_tool(
254254
}
255255

256256
//stage files listed in input default values, input values or initial work dir requirements
257-
let staged_files = stage_required_files(tool, &input_values, &mut runtime, tool_path, dir.path(), output_directory)?;
257+
stage_required_files(tool, &input_values, &mut runtime, tool_path, dir.path(), output_directory)?;
258258

259259
//change working directory to tmp folder, we will execute tool from root here
260260
env::set_current_dir(dir.path())?;
@@ -273,14 +273,6 @@ pub fn run_tool(
273273
reset_expression_engine()?;
274274
}
275275

276-
//remove staged files
277-
let outputs = match &tool {
278-
CWLDocument::CommandLineTool(clt) => &clt.outputs,
279-
CWLDocument::ExpressionTool(et) => &et.outputs,
280-
CWLDocument::Workflow(_) => unreachable!(),
281-
};
282-
unstage_files(&staged_files, dir.path(), outputs)?;
283-
284276
//evaluate output files
285277
prepare_expression_engine(&runtime)?;
286278
let outputs = if let CWLDocument::CommandLineTool(clt) = &tool {

crates/cwl-execution/src/staging.rs

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::{
55
};
66
use cwl::{
77
inputs::CommandInputParameter,
8-
outputs::CommandOutputParameter,
98
requirements::{Requirement, WorkDirItem},
109
types::{CWLType, DefaultValue, Directory, Entry, File, PathItem},
1110
CWLDocument,
@@ -48,34 +47,6 @@ pub(crate) fn stage_required_files<P: AsRef<Path>, Q: AsRef<Path>, R: AsRef<Path
4847
Ok(staged_files)
4948
}
5049

51-
pub(crate) fn unstage_files(staged_files: &[String], tmp_dir: &Path, outputs: &[CommandOutputParameter]) -> Result<(), Box<dyn Error>> {
52-
for file in staged_files {
53-
let mut should_remove = true;
54-
55-
for output in outputs {
56-
if let Some(binding) = &output.output_binding {
57-
if let Some(glob) = &binding.glob {
58-
let binding_path = tmp_dir.join(glob);
59-
if binding_path.to_str().unwrap().matches(file).next().is_some() {
60-
should_remove = false;
61-
break;
62-
}
63-
}
64-
}
65-
}
66-
67-
if should_remove {
68-
let path = Path::new(file);
69-
if path.is_dir() {
70-
fs::remove_dir_all(file).map_err(|e| format!("Could not remove staged dir {}: {}", file, e))?;
71-
} else {
72-
fs::remove_file(file).map_err(|e| format!("Could not remove staged file {}: {}", file, e))?;
73-
}
74-
}
75-
}
76-
Ok(())
77-
}
78-
7950
fn stage_requirements(requirements: &[Requirement], tool_path: &Path, path: &Path) -> Result<Vec<String>, Box<dyn Error>> {
8051
let mut staged_files = vec![];
8152

@@ -321,7 +292,6 @@ fn handle_filename(value: &DefaultValue) -> String {
321292
mod tests {
322293
use super::*;
323294
use cwl::{
324-
outputs::CommandOutputBinding,
325295
requirements::InitialWorkDirRequirement,
326296
types::{Directory, File},
327297
StringOrNumber,
@@ -419,83 +389,6 @@ mod tests {
419389
assert_eq!(list[0], expected_path.to_string_lossy().into_owned());
420390
}
421391

422-
#[test]
423-
#[serial]
424-
fn test_unstage_files() {
425-
let tmp_dir = tempdir().unwrap();
426-
427-
let test_dir = "tests/test_data/input.txt";
428-
429-
let input = CommandInputParameter::default().with_id("test").with_type(CWLType::File);
430-
let value = DefaultValue::File(File::from_location(test_dir));
431-
432-
let list = stage_input_files(
433-
&[input],
434-
&mut RuntimeEnvironment::default().with_inputs(HashMap::from([("test".to_string(), value)])),
435-
Path::new("../../"),
436-
tmp_dir.path(),
437-
&PathBuf::from(""),
438-
)
439-
.unwrap();
440-
441-
unstage_files(&list, tmp_dir.path(), &[]).unwrap();
442-
//file should be gone
443-
assert!(!Path::new(&list[0]).exists());
444-
}
445-
446-
#[test]
447-
#[serial]
448-
fn test_unstage_files_dir() {
449-
let tmp_dir = tempdir().unwrap();
450-
451-
let test_dir = "tests/test_data";
452-
453-
let input = CommandInputParameter::default().with_id("test").with_type(CWLType::Directory);
454-
let value = DefaultValue::Directory(Directory::from_location(test_dir));
455-
456-
let list = stage_input_files(
457-
&[input],
458-
&mut RuntimeEnvironment::default().with_inputs(HashMap::from([("test".to_string(), value)])),
459-
Path::new("../../"),
460-
tmp_dir.path(),
461-
&PathBuf::from(""),
462-
)
463-
.unwrap();
464-
465-
unstage_files(&list, tmp_dir.path(), &[]).unwrap();
466-
//file should be gone
467-
assert!(!Path::new(&list[0]).exists());
468-
}
469-
470-
#[test]
471-
#[serial]
472-
fn test_unstage_files_not_in_output() {
473-
let tmp_dir = tempdir().unwrap();
474-
475-
let test_file = "tests/test_data/input.txt";
476-
477-
let input = CommandInputParameter::default().with_id("test").with_type(CWLType::File);
478-
let value = DefaultValue::File(File::from_location(test_file));
479-
480-
let output = CommandOutputParameter::default().with_binding(CommandOutputBinding {
481-
glob: Some("tests/test_data/input.txt".to_string()),
482-
..Default::default()
483-
});
484-
485-
let list = stage_input_files(
486-
&[input],
487-
&mut RuntimeEnvironment::default().with_inputs(HashMap::from([("test".to_string(), value)])),
488-
Path::new("../../"),
489-
tmp_dir.path(),
490-
&PathBuf::from(""),
491-
)
492-
.unwrap();
493-
494-
unstage_files(&list, tmp_dir.path(), &[output]).unwrap();
495-
//file should still be there
496-
assert!(Path::new(&list[0]).exists());
497-
}
498-
499392
#[test]
500393
#[serial]
501394
fn test_stage_secondary_files() {

0 commit comments

Comments
 (0)