Skip to content

Commit ba08ee9

Browse files
committed
renamed additional_args to append_args
1 parent 89a474a commit ba08ee9

File tree

6 files changed

+45
-49
lines changed

6 files changed

+45
-49
lines changed

pydra/compose/shell/builder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def make(
210210
# Set positions for the remaining inputs that don't have an explicit position
211211
position_stack = remaining_positions(list(parsed_inputs.values()))
212212
for inpt in parsed_inputs.values():
213-
if inpt.name == "additional_args":
213+
if inpt.name == "append_args":
214214
continue
215215
if inpt.position is None:
216216
inpt.position = position_stack.pop(0)
@@ -544,11 +544,11 @@ def remaining_positions(
544544
If multiple fields have the same position
545545
"""
546546
if num_args is None:
547-
num_args = len(args) - 1 # Subtract 1 for the 'additional_args' field
547+
num_args = len(args) - 1 # Subtract 1 for the 'append_args' field
548548
# Check for multiple positions
549549
positions = defaultdict(list)
550550
for arg in args:
551-
if arg.name == "additional_args":
551+
if arg.name == "append_args":
552552
continue
553553
if arg.position is not None:
554554
if arg.position >= 0:

pydra/compose/shell/task.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def _resolve_value(
220220

221221

222222
@state_array_support
223-
def additional_args_converter(value: ty.Any) -> list[str]:
223+
def append_args_converter(value: ty.Any) -> list[str]:
224224
"""Convert additional arguments to a list of strings."""
225225
if isinstance(value, str):
226226
return shlex.split(value)
@@ -234,17 +234,17 @@ class ShellTask(base.Task[ShellOutputsType]):
234234

235235
_task_type = "shell"
236236

237-
BASE_NAMES = ["additional_args"]
237+
BASE_NAMES = ["append_args"]
238238

239239
EXECUTABLE_HELP = (
240240
"the first part of the command, can be a string, "
241241
"e.g. 'ls', or a list, e.g. ['ls', '-l', 'dirname']"
242242
)
243243

244-
additional_args: list[str | File] = field.arg(
245-
name="additional_args",
244+
append_args: list[str | File] = field.arg(
245+
name="append_args",
246246
default=attrs.Factory(list),
247-
converter=additional_args_converter,
247+
converter=append_args_converter,
248248
type=list[str | File],
249249
sep=" ",
250250
help="Additional free-form arguments to append to the end of the command.",
@@ -289,7 +289,7 @@ def _command_args(self, values: dict[str, ty.Any]) -> list[str]:
289289
del values[fld.name]
290290
# Drop special fields that are added separately
291291
del values["executable"]
292-
del values["additional_args"]
292+
del values["append_args"]
293293
# Add executable
294294
pos_args = [
295295
self._command_shelltask_executable(fld, self.executable),
@@ -309,7 +309,7 @@ def _command_args(self, values: dict[str, ty.Any]) -> list[str]:
309309
# pos_args values are each a list of arguments, so concatenate lists after sorting
310310
command_args = sum(cmd_args, [])
311311
# Append additional arguments to the end of the command
312-
command_args += self.additional_args
312+
command_args += self.append_args
313313
return command_args
314314

315315
def _command_shelltask_executable(

pydra/compose/shell/tests/test_shell_cmdline.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Outputs(shell.Outputs):
3434
inpA: str = shell.arg(position=1, help="inp1", argstr="")
3535

3636
shelly = Shelly(
37-
additional_args=["arg"],
37+
append_args=["arg"],
3838
inpA="inp1",
3939
)
4040
assert shelly.cmdline == "executable inp1 arg"
@@ -52,7 +52,7 @@ class Outputs(shell.Outputs):
5252
inpA: str = shell.arg(help="inpA", argstr="")
5353

5454
shelly = Shelly(
55-
additional_args=["arg"],
55+
append_args=["arg"],
5656
inpA="inpNone1",
5757
)
5858
# inp1 should be the first one after executable
@@ -72,7 +72,7 @@ class Outputs(shell.Outputs):
7272

7373
# separate command into exec + args
7474
shelly = Shelly(
75-
additional_args=["arg"],
75+
append_args=["arg"],
7676
inpA="inp-1",
7777
)
7878
# inp1 should be last before arg
@@ -194,7 +194,7 @@ class Outputs(shell.Outputs):
194194
inpA: bool = shell.arg(position=1, help="inpA", argstr="-v")
195195

196196
# separate command into exec + args
197-
shelly = Shelly(additional_args=["arg"], inpA=True)
197+
shelly = Shelly(append_args=["arg"], inpA=True)
198198
# a flag is used without any additional argument
199199
assert shelly.cmdline == "executable -v arg"
200200

pydra/compose/shell/tests/test_shell_fields.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_interface_template():
3434
),
3535
shell.arg(name="in_path", type=FsObject, position=1),
3636
output,
37-
shell.Task.additional_args,
37+
shell.Task.append_args,
3838
]
3939
assert sorted_fields(Cp.Outputs) == [
4040
output,
@@ -89,7 +89,7 @@ def test_interface_template_w_types_and_path_template_ext():
8989
),
9090
shell.arg(name="in_image", type=image.Png, position=1),
9191
output,
92-
shell.Task.additional_args,
92+
shell.Task.append_args,
9393
]
9494
assert sorted_fields(TrimPng.Outputs) == [
9595
output,
@@ -131,7 +131,7 @@ def test_interface_template_w_modify():
131131
shell.arg(
132132
name="image", type=image.Png, position=1, copy_mode=File.CopyMode.copy
133133
),
134-
shell.Task.additional_args,
134+
shell.Task.append_args,
135135
]
136136
assert sorted_fields(TrimPng.Outputs) == [
137137
shell.out(
@@ -216,7 +216,7 @@ def test_interface_template_more_complex():
216216
default=None,
217217
position=6,
218218
),
219-
shell.Task.additional_args,
219+
shell.Task.append_args,
220220
]
221221
assert sorted_fields(Cp.Outputs) == [
222222
output,
@@ -311,7 +311,7 @@ def test_interface_template_with_overrides_and_optionals():
311311
sep=" ",
312312
position=5,
313313
),
314-
] + outargs + [shell.Task.additional_args]
314+
] + outargs + [shell.Task.append_args]
315315
assert sorted_fields(Cp.Outputs) == outargs + [
316316
shell.out(
317317
name="return_code",
@@ -374,7 +374,7 @@ def test_interface_template_with_defaults():
374374
position=6,
375375
sep=" ",
376376
),
377-
shell.Task.additional_args,
377+
shell.Task.append_args,
378378
]
379379
assert sorted_fields(Cp.Outputs) == [
380380
output,
@@ -444,7 +444,7 @@ def test_interface_template_with_type_overrides():
444444
position=6,
445445
sep=" ",
446446
),
447-
shell.Task.additional_args,
447+
shell.Task.append_args,
448448
]
449449
assert sorted_fields(Cp.Outputs) == [
450450
output,
@@ -584,7 +584,7 @@ class Outputs(shell.Outputs):
584584
def test_shell_fields(Ls):
585585
assert sorted([a.name for a in sorted_fields(Ls)]) == sorted(
586586
[
587-
"additional_args",
587+
"append_args",
588588
"executable",
589589
"directory",
590590
"hidden",
@@ -714,7 +714,7 @@ class Outputs(shell.Outputs):
714714
)
715715

716716
assert sorted([a.name for a in attrs.fields(A) if not a.name.startswith("_")]) == [
717-
"additional_args",
717+
"append_args",
718718
"executable",
719719
"x",
720720
"y",
@@ -753,7 +753,7 @@ class Outputs(shell.Outputs):
753753
position=1,
754754
),
755755
output,
756-
shell.Task.additional_args,
756+
shell.Task.append_args,
757757
]
758758
assert sorted_fields(A.Outputs) == [
759759
output,
@@ -1011,7 +1011,7 @@ def test_shell_help1():
10111011
).split(
10121012
"\n"
10131013
) + [
1014-
"- additional_args: list[str | generic/file]; default-factory = list()",
1014+
"- append_args: list[str | generic/file]; default-factory = list()",
10151015
" Additional free-form arguments to append to the end of the command.",
10161016
"",
10171017
"Outputs:",
@@ -1036,7 +1036,7 @@ def sorted_fields(interface):
10361036
length = len(fields) - 1
10371037

10381038
def pos_key(out: shell.out) -> int:
1039-
if out.name == "additional_args":
1039+
if out.name == "append_args":
10401040
return (length + 1, out.name)
10411041
try:
10421042
pos = out.position

pydra/compose/shell/tests/test_shell_run.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def test_shell_cmd_2a(worker, results_function, tmp_path):
7878
cmd_exec = "echo"
7979
cmd_args = ["hail", "pydra"]
8080
# separate command into exec + args
81-
shelly = shell.define(cmd_exec)(additional_args=cmd_args)
81+
shelly = shell.define(cmd_exec)(append_args=cmd_args)
8282

8383
assert shelly.executable == "echo"
8484
assert shelly.cmdline == "echo " + " ".join(cmd_args)
@@ -95,7 +95,7 @@ def test_shell_cmd_2b(worker, results_function, tmp_path):
9595
cmd_exec = "echo"
9696
cmd_args = ["pydra"]
9797
# separate command into exec + args
98-
shelly = shell.define(cmd_exec)(additional_args=cmd_args)
98+
shelly = shell.define(cmd_exec)(append_args=cmd_args)
9999

100100
assert shelly.executable == "echo"
101101
assert shelly.cmdline == "echo pydra"
@@ -138,10 +138,10 @@ def test_shell_cmd_4(worker, tmp_path):
138138
cmd_exec = "echo"
139139
cmd_args = [["nipype"], ["pydra"]]
140140
# separate command into exec + args
141-
shelly = shell.define(cmd_exec)().split(additional_args=cmd_args)
141+
shelly = shell.define(cmd_exec)().split(append_args=cmd_args)
142142

143143
assert shelly.executable == "echo"
144-
assert shelly.additional_args == StateArray([["nipype"], ["pydra"]])
144+
assert shelly.append_args == StateArray([["nipype"], ["pydra"]])
145145
# assert shelly.cmdline == ["echo nipype", "echo pydra"]
146146
outputs = shelly(worker=worker)
147147

@@ -159,14 +159,10 @@ def test_shell_cmd_5(worker, tmp_path):
159159
cmd_exec = "echo"
160160
cmd_args = [["nipype"], ["pydra"]]
161161
# separate command into exec + args
162-
shelly = (
163-
shell.define(cmd_exec)()
164-
.split(additional_args=cmd_args)
165-
.combine("additional_args")
166-
)
162+
shelly = shell.define(cmd_exec)().split(append_args=cmd_args).combine("append_args")
167163

168164
assert shelly.executable == "echo"
169-
assert shelly.additional_args == StateArray([["nipype"], ["pydra"]])
165+
assert shelly.append_args == StateArray([["nipype"], ["pydra"]])
170166
# assert shelly.cmdline == ["echo nipype", "echo pydra"]
171167
outputs = shelly(worker=worker)
172168

@@ -182,11 +178,11 @@ def test_shell_cmd_6(worker, tmp_path):
182178
cmd_args = [["nipype"], ["pydra"]]
183179
# separate command into exec + args
184180
shelly = shell.define("shelly")().split(
185-
["executable", "additional_args"], executable=cmd_exec, additional_args=cmd_args
181+
["executable", "append_args"], executable=cmd_exec, append_args=cmd_args
186182
)
187183

188184
assert shelly.executable == ["echo", ["echo", "-n"]]
189-
assert shelly.additional_args == StateArray([["nipype"], ["pydra"]])
185+
assert shelly.append_args == StateArray([["nipype"], ["pydra"]])
190186
outputs = shelly(cache_root=tmp_path, worker=worker)
191187

192188
assert outputs.stdout == ["nipype\n", "pydra\n", "nipype", "pydra"]
@@ -217,15 +213,15 @@ def test_shell_cmd_7(worker, tmp_path):
217213
shelly = (
218214
shell.define("shelly")()
219215
.split(
220-
["executable", "additional_args"],
216+
["executable", "append_args"],
221217
executable=cmd_exec,
222-
additional_args=cmd_args,
218+
append_args=cmd_args,
223219
)
224-
.combine("additional_args")
220+
.combine("append_args")
225221
)
226222

227223
assert shelly.executable == ["echo", ["echo", "-n"]]
228-
assert shelly.additional_args == StateArray([["nipype"], ["pydra"]])
224+
assert shelly.append_args == StateArray([["nipype"], ["pydra"]])
229225

230226
outputs = shelly(worker=worker)
231227

@@ -247,7 +243,7 @@ def StripAndListify(x: str) -> list[str]:
247243
return [x.strip()]
248244

249245
listify = workflow.add(StripAndListify(x=shelly_pwd.stdout))
250-
shelly_ls = workflow.add(shell.define(cmd2)(additional_args=listify.out))
246+
shelly_ls = workflow.add(shell.define(cmd2)(append_args=listify.out))
251247
return shelly_ls.stdout
252248

253249
wf = Workflow(cmd1="pwd", cmd2="ls")
@@ -285,9 +281,9 @@ class Outputs(shell.Outputs):
285281
pass
286282

287283
# separate command into exec + args
288-
shelly = Shelly(additional_args=cmd_args, opt_n=cmd_opt)
284+
shelly = Shelly(append_args=cmd_args, opt_n=cmd_opt)
289285
assert shelly.executable == cmd_exec
290-
assert shelly.additional_args == cmd_args
286+
assert shelly.append_args == cmd_args
291287
assert shelly.cmdline == "echo -n 'hello from pydra'"
292288

293289
outputs = results_function(shelly, worker=worker, cache_root=tmp_path)
@@ -323,9 +319,9 @@ class Outputs(shell.Outputs):
323319
pass
324320

325321
# separate command into exec + args
326-
shelly = Shelly(additional_args=cmd_args, opt_n=cmd_opt, opt_hello=cmd_opt_hello)
322+
shelly = Shelly(append_args=cmd_args, opt_n=cmd_opt, opt_hello=cmd_opt_hello)
327323
assert shelly.executable == cmd_exec
328-
assert shelly.additional_args == cmd_args
324+
assert shelly.append_args == cmd_args
329325
assert shelly.cmdline == "echo -n HELLO 'from pydra'"
330326
outputs = results_function(shelly, worker=worker, cache_root=tmp_path)
331327
assert outputs.stdout == "HELLO from pydra"
@@ -2389,7 +2385,7 @@ class Outputs(shell.Outputs):
23892385
callable=get_stderr,
23902386
)
23912387

2392-
shelly = Shelly().split(additional_args=args)
2388+
shelly = Shelly().split(append_args=args)
23932389

23942390
outputs = results_function(shelly, worker=worker, cache_root=tmp_path)
23952391
for index in range(2):

pydra/environments/tests/test_singularity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_singularity_2a(worker, tmp_path):
7373
# separate command into exec + args
7474
image = "docker://alpine"
7575
Singu = shell.define(cmd_exec)
76-
singu = Singu(additional_args=cmd_args)
76+
singu = Singu(append_args=cmd_args)
7777
assert singu.cmdline == f"{cmd_exec} {' '.join(cmd_args)}"
7878

7979
with Submitter(

0 commit comments

Comments
 (0)