@@ -42,7 +42,7 @@ use wait_timeout::ChildExt;
4242pub 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
198199pub 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
0 commit comments