2626)
2727from pydra .compose import base
2828from pydra .compose .base .field import RequirementSet
29+ from pydra .environments .base import Container
2930from pydra .compose .base .helpers import is_set
3031from . import field
3132from .templating import (
@@ -254,6 +255,11 @@ class ShellTask(base.Task[ShellOutputsType]):
254255
255256 def _run (self , job : "Job[ShellTask]" , rerun : bool = True ) -> None :
256257 """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+ )
257263 job .return_values = job .environment .execute (job )
258264
259265 @property
@@ -291,9 +297,9 @@ def _command_args(self, values: dict[str, ty.Any]) -> list[str]:
291297 del values ["executable" ]
292298 del values ["append_args" ]
293299 # 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 ) )
297303 positions_provided = [0 ]
298304 fields = {f .name : f for f in get_fields (self )}
299305 for field_name in values :
@@ -312,9 +318,9 @@ def _command_args(self, values: dict[str, ty.Any]) -> list[str]:
312318 command_args += self .append_args
313319 return command_args
314320
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 ]:
318324 """Returning position and value for executable Task input"""
319325 pos = 0 # executable should be the first el. of the command
320326 assert value
0 commit comments