26
26
)
27
27
from pydra .compose import base
28
28
from pydra .compose .base .field import RequirementSet
29
+ from pydra .environments .base import Container
29
30
from pydra .compose .base .helpers import is_set
30
31
from . import field
31
32
from .templating import (
@@ -254,6 +255,11 @@ class ShellTask(base.Task[ShellOutputsType]):
254
255
255
256
def _run (self , job : "Job[ShellTask]" , rerun : bool = True ) -> None :
256
257
"""Run the shell command."""
258
+ if self .executable is None and not isinstance (job .environment , Container ):
259
+ raise ValueError (
260
+ "executable is not set, and the environment is not a container "
261
+ f"({ job .environment } ) with an entrypoint"
262
+ )
257
263
job .return_values = job .environment .execute (job )
258
264
259
265
@property
@@ -291,9 +297,9 @@ def _command_args(self, values: dict[str, ty.Any]) -> list[str]:
291
297
del values ["executable" ]
292
298
del values ["append_args" ]
293
299
# Add executable
294
- pos_args = [
295
- self ._command_shelltask_executable ( fld , self . executable ),
296
- ] # list for (position, command arg )
300
+ pos_args = []
301
+ if self .executable is not None :
302
+ pos_args . append ( self . _executable_pos_arg ( fld , self . executable ) )
297
303
positions_provided = [0 ]
298
304
fields = {f .name : f for f in get_fields (self )}
299
305
for field_name in values :
@@ -312,9 +318,9 @@ def _command_args(self, values: dict[str, ty.Any]) -> list[str]:
312
318
command_args += self .append_args
313
319
return command_args
314
320
315
- def _command_shelltask_executable (
316
- self , fld : field .arg , value : ty . Any
317
- ) -> tuple [int , ty . Any ]:
321
+ def _executable_pos_arg (
322
+ self , fld : field .arg , value : str | list [ str ] | None
323
+ ) -> tuple [int , str | list [ str ] | None ]:
318
324
"""Returning position and value for executable Task input"""
319
325
pos = 0 # executable should be the first el. of the command
320
326
assert value
0 commit comments