@@ -24,8 +24,11 @@ Example:
24
24
25
25
from pydra.environments import native, docker, singularity
26
26
from pydra.compose import shell
27
+
27
28
# 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!" )
29
32
30
33
# Execute with a native environment
31
34
outputs_native = shelly(environment = native.Environment())
@@ -34,7 +37,9 @@ Example:
34
37
outputs_docker = shelly(environment = docker.Environment(image = " busybox" ))
35
38
36
39
# 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
+ )
38
43
39
44
Alternatively, when using a `pydra.engine.submitter.Submitter `, the environment can be specified in the Submitter constructor:
40
45
@@ -44,7 +49,8 @@ Alternatively, when using a `pydra.engine.submitter.Submitter`, the environment
44
49
from pydra.environments import native
45
50
from pydra.compose import shell
46
51
47
- shelly = shell.fuse(" echo hello" )
52
+ Shelly = shell.define(" echo <text:str>" )
53
+ shelly = Shelly(text = " Hello, Pydra!" )
48
54
with Submitter(environment = native.Environment()) as sub:
49
55
result = sub(shelly)
50
56
@@ -63,9 +69,10 @@ Example:
63
69
from pydra.compose import workflow, shell
64
70
from fileformats.generic import File
65
71
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>" )
67
75
68
- Singu = shell.define(" cat {file} " )
69
76
70
77
def MyWorkflow (file : File) -> str :
71
78
singu_task = workflow.add(
@@ -87,25 +94,27 @@ Example (simplified custom environment):
87
94
88
95
.. code-block :: python
89
96
90
- from pydra.environments import Environment as PydraEnvironment
97
+ from pydra.environments.base import Environment as PydraEnvironment
98
+ import typing as ty
99
+
91
100
92
101
class MyCustomEnvironment (PydraEnvironment ):
93
102
def __init__ (self , some_config : str ):
94
103
super ().__init__ ()
95
104
self .some_config = some_config
96
105
97
- def _setup (self ):
106
+ def setup (self ):
98
107
# Logic to set up the custom environment
99
108
print (f " Setting up custom environment with config: { self .some_config} " )
100
109
101
- def _execute (self , command : list ) :
110
+ def execute (self , job : " Job[shell.Task] " ) -> dict[ str , ty.Any] :
102
111
# Logic to execute a command within the custom environment
103
112
# 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" )
105
114
# 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 }
107
116
108
- def _tear_down (self ):
117
+ def teardown (self ):
109
118
# Logic to tear down the custom environment
110
119
print (" Tearing down custom environment" )
111
120
@@ -114,8 +123,10 @@ Then, you can use your custom environment like any other built-in environment:
114
123
.. code-block :: python
115
124
116
125
from pydra.compose import shell
126
+ from pydra.engine.job import Job
127
+
117
128
# 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" )
119
130
outputs = my_task(environment = MyCustomEnvironment(some_config = " test" ))
120
131
print (outputs.stdout)
121
132
0 commit comments