|
1 | 1 | use crate::{get_available_disk_space, get_available_ram, get_processor_count, util::evaluate_input, validate::set_placeholder_values_in_string}; |
2 | 2 | use cwl::{ |
3 | 3 | inputs::CommandInputParameter, |
4 | | - requirements::{check_timelimit, NetworkAccess, Requirement, ResourceRequirement}, |
| 4 | + requirements::{check_timelimit, EnvVarRequirement, NetworkAccess, ResourceRequirement}, |
5 | 5 | types::{DefaultValue, EnviromentDefs}, |
6 | 6 | CWLDocument, StringOrNumber, |
7 | 7 | }; |
@@ -122,22 +122,14 @@ fn evaluate(val: &StringOrNumber, runtime: &RuntimeEnvironment, inputs: &[Comman |
122 | 122 | } |
123 | 123 |
|
124 | 124 | pub(crate) fn collect_environment(tool: &CWLDocument) -> HashMap<String, String> { |
125 | | - tool.hints |
126 | | - .iter() |
127 | | - .chain(tool.requirements.iter()) |
128 | | - .flatten() |
129 | | - .filter_map(|req| { |
130 | | - if let Requirement::EnvVarRequirement(env) = req { |
131 | | - match &env.env_def { |
132 | | - EnviromentDefs::Vec(vec) => Some(vec.iter().map(|i| (i.env_name.clone(), i.env_value.clone())).collect::<HashMap<_, _>>()), |
133 | | - EnviromentDefs::Map(map) => Some(map.clone()), |
134 | | - } |
135 | | - } else { |
136 | | - None |
137 | | - } |
138 | | - }) |
139 | | - .flatten() |
140 | | - .collect() |
| 125 | + if let Some(env) = tool.get_requirement::<EnvVarRequirement>() { |
| 126 | + match &env.env_def { |
| 127 | + EnviromentDefs::Vec(vec) => vec.iter().map(|i| (i.env_name.clone(), i.env_value.clone())).collect::<HashMap<_, _>>(), |
| 128 | + EnviromentDefs::Map(map) => map.clone(), |
| 129 | + } |
| 130 | + } else { |
| 131 | + HashMap::new() |
| 132 | + } |
141 | 133 | } |
142 | 134 |
|
143 | 135 | pub(crate) fn collect_inputs( |
@@ -165,7 +157,7 @@ pub(crate) fn collect_inputs( |
165 | 157 | #[cfg(test)] |
166 | 158 | mod tests { |
167 | 159 | use super::*; |
168 | | - use cwl::{clt::CommandLineTool, requirements::EnvVarRequirement}; |
| 160 | + use cwl::{clt::CommandLineTool, requirements::{EnvVarRequirement, Requirement}}; |
169 | 161 |
|
170 | 162 | #[test] |
171 | 163 | fn test_requirements_overwrite_hints() { |
|
0 commit comments