Skip to content

Commit c1a48d5

Browse files
committed
expression in sec-files
1 parent fece38e commit c1a48d5

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- fixed a bug with Dockerfile path resolution
1010
- handle NetworkAccess Requirment in runner
1111
- inherit parents requirements correclty
12-
- ramping up runner conformance from 160/378 to 197/378
12+
- ramping up runner conformance from 160/378 to 198/378
1313

1414
# v0.5.2
1515
## 🐛 Bugfixes

crates/cwl-execution/src/expression.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ pub(crate) fn evaluate_expression(input: &str) -> Result<Value, Box<dyn Error>>
7676
}
7777

7878
pub(crate) fn evaluate_condition(input: &str, inputs: &HashMap<String, DefaultValue>) -> Result<bool, Box<dyn Error>> {
79-
prepare_expression_engine(&RuntimeEnvironment { inputs: inputs.clone(), ..Default::default() })?;
79+
prepare_expression_engine(&RuntimeEnvironment {
80+
inputs: inputs.clone(),
81+
..Default::default()
82+
})?;
8083
let result = evaluate_expression(input)?.as_bool().unwrap_or(false);
8184
reset_expression_engine()?;
8285
Ok(result)
@@ -209,6 +212,20 @@ pub(crate) fn process_expressions(tool: &mut CWLDocument, input_values: &mut Inp
209212
}
210213
}
211214
}
215+
for input in &mut tool.inputs {
216+
let tmp = input.id.clone();
217+
if input.secondary_files.is_empty() {
218+
continue;
219+
}
220+
221+
if let DefaultValue::File(file) = &input_values.inputs[&tmp] {
222+
set_self(&file.snapshot())?;
223+
for sec_file in &mut input.secondary_files {
224+
sec_file.pattern = replace_expressions(&sec_file.pattern)?;
225+
}
226+
unset_self()?;
227+
}
228+
}
212229
if let CWLDocument::CommandLineTool(clt) = tool {
213230
clt.base_command = match std::mem::take(&mut clt.base_command) {
214231
Command::Single(cmd) => Command::Single(replace_expressions(&cmd)?),

crates/cwl-execution/src/staging.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,14 @@ fn stage_secondary_inputs(incoming_data: &DefaultValue, path: &Path, input: &Com
245245
};
246246
for item in &input.secondary_files {
247247
let mut matched = false;
248-
let pattern = file_dir.join(format!("*{}", item.pattern));
249-
for res in glob(&pattern.to_string_lossy())? {
248+
let pattern = if item.pattern.starts_with(file_dir.to_string_lossy().as_ref()) {
249+
&item.pattern
250+
} else {
251+
&file_dir.join(format!("*{}", item.pattern)).to_string_lossy().into_owned()
252+
};
253+
let pattern = pattern.trim();
254+
255+
for res in glob(pattern)? {
250256
let res = res?;
251257
let dest = path.join(&res);
252258
copy_file(&res, &dest).map_err(|e| format!("Failed to copy file from {:?} to {:?}: {}", res, dest, e))?;

0 commit comments

Comments
 (0)