@@ -24,8 +24,11 @@ Example:
2424
2525 from pydra.environments import native, docker, singularity
2626 from pydra.compose import shell
27+
2728 # Define a simple shell task
28- shelly = shell.fuse(" echo hello" )
29+ Shelly = shell.define(" echo <text:str>" )
30+
31+ shelly = Shelly(text = " Hello, Pydra!" )
2932
3033 # Execute with a native environment
3134 outputs_native = shelly(environment = native.Environment())
@@ -34,7 +37,9 @@ Example:
3437 outputs_docker = shelly(environment = docker.Environment(image = " busybox" ))
3538
3639 # Execute with a Singularity environment (assuming an image is available)
37- outputs_singularity = shelly(environment = singularity.Environment(image = " /path/to/image.sif" ))
40+ outputs_singularity = shelly(
41+ environment = singularity.Environment(image = " /path/to/image.sif" )
42+ )
3843
3944 Alternatively, when using a `pydra.engine.submitter.Submitter `, the environment can be specified in the Submitter constructor:
4045
@@ -44,7 +49,8 @@ Alternatively, when using a `pydra.engine.submitter.Submitter`, the environment
4449 from pydra.environments import native
4550 from pydra.compose import shell
4651
47- shelly = shell.fuse(" echo hello" )
52+ Shelly = shell.define(" echo <text:str>" )
53+ shelly = Shelly(text = " Hello, Pydra!" )
4854 with Submitter(environment = native.Environment()) as sub:
4955 result = sub(shelly)
5056
@@ -63,9 +69,10 @@ Example:
6369 from pydra.compose import workflow, shell
6470 from fileformats.generic import File
6571
66- image = " /path/to/my_singularity_image.sif" # Replace with your Singularity image path
72+ image = " /path/to/my_singularity_image.sif" # Replace with your Singularity image path
73+
74+ Singu = shell.define(" cat <file>" )
6775
68- Singu = shell.define(" cat {file} " )
6976
7077 def MyWorkflow (file : File) -> str :
7178 singu_task = workflow.add(
@@ -87,25 +94,27 @@ Example (simplified custom environment):
8794
8895.. code-block :: python
8996
90- from pydra.environments import Environment as PydraEnvironment
97+ from pydra.environments.base import Environment as PydraEnvironment
98+ import typing as ty
99+
91100
92101 class MyCustomEnvironment (PydraEnvironment ):
93102 def __init__ (self , some_config : str ):
94103 super ().__init__ ()
95104 self .some_config = some_config
96105
97- def _setup (self ):
106+ def setup (self ):
98107 # Logic to set up the custom environment
99108 print (f " Setting up custom environment with config: { self .some_config} " )
100109
101- def _execute (self , command : list ) :
110+ def execute (self , job : " Job[shell.Task] " ) -> dict[ str , ty.Any] :
102111 # Logic to execute a command within the custom environment
103112 # This is where you would integrate with a custom execution system
104- print (f " Executing command: { ' ' .join(command) } in custom environment " )
113+ print (f " Executing command: ' { job.task.cmdline } ' in custom environment" )
105114 # For demonstration, just return a dummy result
106- return {" stdout" : " Custom environment output" , " return_code" : 0 }
115+ return {" stdout" : " Custom environment output" , " stderr " : " " , " return_code" : 0 }
107116
108- def _tear_down (self ):
117+ def teardown (self ):
109118 # Logic to tear down the custom environment
110119 print (" Tearing down custom environment" )
111120
@@ -114,8 +123,10 @@ Then, you can use your custom environment like any other built-in environment:
114123.. code-block :: python
115124
116125 from pydra.compose import shell
126+ from pydra.engine.job import Job
127+
117128 # Assume MyCustomEnvironment is defined as above
118- my_task = shell.fuse (" echo Hello from custom env" )
129+ my_task = shell.define (" echo <text:str> " )( text = " Hello from custom env" )
119130 outputs = my_task(environment = MyCustomEnvironment(some_config = " test" ))
120131 print (outputs.stdout)
121132
0 commit comments