1- from glob import glob
21import typing as ty
32import os
43import sys
76import re
87import stat
98from pydra .engine .submitter import Submitter
10- from pydra .design import shell , workflow
9+ from pydra .design import shell , workflow , python
1110from pydra .engine .specs import (
1211 ShellOutputs ,
1312 ShellDef ,
@@ -248,8 +247,14 @@ def test_wf_shell_cmd_1(plugin, tmp_path):
248247
249248 @workflow .define
250249 def Workflow (cmd1 , cmd2 ):
251- shelly_pwd = workflow .add (shell .define (cmd1 ))
252- shelly_ls = workflow .add (shell .define (cmd2 , additional_args = shelly_pwd .stdout ))
250+ shelly_pwd = workflow .add (shell .define (cmd1 )())
251+
252+ @python .define
253+ def StripAndListify (x : str ) -> list [str ]:
254+ return [x .strip ()]
255+
256+ listify = workflow .add (StripAndListify (x = shelly_pwd .stdout ))
257+ shelly_ls = workflow .add (shell .define (cmd2 )(additional_args = listify .out ))
253258 return shelly_ls .stdout
254259
255260 wf = Workflow (cmd1 = "pwd" , cmd2 = "ls" )
@@ -1591,30 +1596,32 @@ def test_wf_shell_cmd_2(plugin_dask_opt, tmp_path):
15911596 class Shelly (ShellDef ["Shelly.Outputs" ]):
15921597 executable = "touch"
15931598
1599+ arg : str = shell .arg ()
1600+
15941601 class Outputs (ShellOutputs ):
15951602 out1 : File = shell .outarg (
1596- path_template = "{args }" ,
1603+ path_template = "{arg }" ,
15971604 help = "output file" ,
15981605 )
15991606
1600- @workflow .define
1601- def Workflow (cmd , args ):
1607+ @workflow .define ( outputs = [ "out_f" , "stdout" ])
1608+ def Workflow (cmd , arg ):
16021609
16031610 shelly = workflow .add (
16041611 Shelly (
16051612 executable = cmd ,
1606- additional_args = args ,
1613+ arg = arg ,
16071614 )
16081615 )
16091616
16101617 return shelly .out1 , shelly .stdout
16111618
1612- wf = Workflow (cmd = "touch" , args = File . mock ( "newfile.txt" ) )
1619+ wf = Workflow (cmd = "touch" , arg = "newfile.txt" )
16131620
1614- with Submitter (plugin = plugin_dask_opt ) as sub :
1621+ with Submitter (plugin = plugin_dask_opt , cache_dir = tmp_path ) as sub :
16151622 res = sub (wf )
16161623
1617- assert res .outputs .out == ""
1624+ assert res .outputs .stdout == ""
16181625 assert res .outputs .out_f .fspath .exists ()
16191626 assert res .outputs .out_f .fspath .parent .parent == tmp_path
16201627
@@ -1628,25 +1635,27 @@ def test_wf_shell_cmd_2a(plugin, tmp_path):
16281635 class Shelly (ShellDef ["Shelly.Outputs" ]):
16291636 executable = "shelly"
16301637
1638+ arg : str = shell .arg ()
1639+
16311640 class Outputs (ShellOutputs ):
16321641 out1 : File = shell .outarg (
1633- path_template = "{args }" ,
1642+ path_template = "{arg }" ,
16341643 help = "output file" ,
16351644 )
16361645
1637- @workflow .define
1638- def Workflow (cmd , args ):
1646+ @workflow .define ( outputs = [ "out_f" , "out" ])
1647+ def Workflow (cmd , arg ):
16391648
16401649 shelly = workflow .add (
16411650 Shelly (
16421651 executable = cmd ,
1643- additional_args = args ,
1652+ arg = arg ,
16441653 )
16451654 )
16461655
16471656 return shelly .out1 , shelly .stdout
16481657
1649- wf = Workflow (cmd = "touch" , args = ( File . mock ( "newfile.txt" ),) )
1658+ wf = Workflow (cmd = "touch" , arg = "newfile.txt" )
16501659
16511660 with Submitter (plugin = "debug" ) as sub :
16521661 res = sub (wf )
@@ -1673,6 +1682,9 @@ class Outputs(ShellOutputs):
16731682
16741683 @shell .define
16751684 class Shelly2 (ShellDef ["Shelly2.Outputs" ]):
1685+
1686+ executable = "shelly2"
1687+
16761688 orig_file : File = shell .arg (
16771689 position = 1 ,
16781690 help = "output file" ,
@@ -2491,7 +2503,7 @@ def test_shell_cmd_outputspec_wf_1(plugin, tmp_path):
24912503 @shell .define
24922504 class Shelly (ShellDef ["Shelly.Outputs" ]):
24932505
2494- executable = "placeholder "
2506+ executable = "shelly "
24952507
24962508 class Outputs (ShellOutputs ):
24972509 newfile : File = shell .outarg (path_template = "newfile_tmp.txt" )
0 commit comments