Modules
Step
¶
Bases: BaseStep
Represents a step in the pipeline.
Source code in grpipe/step.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
__call__(*args, **kwargs)
¶
Execute the step with the given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments (not used). |
()
|
**kwargs
|
Any
|
Keyword arguments for the step. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The result of executing the step. |
Source code in grpipe/step.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
get_cache_key(kwargs)
¶
Generate a cache key based on the given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kwargs
|
dict[str, Any]
|
The keyword arguments. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
frozendict |
frozendict
|
A hashable cache key. |
Source code in grpipe/step.py
77 78 79 80 81 82 83 84 85 86 87 88 89 | |
is_cachable(bound_args, kwargs)
¶
Determine if the step's result can be cached based on the given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bound_args
|
dict[str, Any]
|
The bound arguments. |
required |
kwargs
|
dict[str, Any]
|
The keyword arguments. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the result can be cached, False otherwise. |
Source code in grpipe/step.py
64 65 66 67 68 69 70 71 72 73 74 75 | |
reset_cache()
¶
Clear the step's cache.
Source code in grpipe/step.py
143 144 145 146 | |
set_params(**kwargs)
¶
Set the parameters for the step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
The parameters to set. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Step |
Step
|
The updated step instance. |
Source code in grpipe/step.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
Bases: BaseStep, Generic[T]
Represents an argument that can be bound to a value and passed to a step.
Methods:
| Name | Description |
|---|---|
bind |
Bind the argument to a value |
unbind |
Unbind the argument |
bound |
Check if the argument is bound |
value |
Get the value of the argument |
Source code in grpipe/argument.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
__init__(name, *args, **kwargs)
¶
Abstract argument object.
This object is used to pass arguments to steps in a pipeline. It can be bound to a value and passed to a step as a parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the argument |
required |
Functions:
| Name | Description |
|---|---|
bind |
Bind the argument to a value |
unbind |
Unbind the argument |
bound |
Check if the argument is bound |
value |
Get the value of the argument |
Source code in grpipe/argument.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
bind(value)
¶
Bind the argument to a value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
T
|
The value to bind to the argument. |
required |
Returns:
| Type | Description |
|---|---|
Argument[T]
|
Argument[T]: The updated argument instance. |
Source code in grpipe/argument.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
unbind()
¶
Unbind the argument, clearing its value.
Returns:
| Type | Description |
|---|---|
Argument[T]
|
Argument[T]: The updated argument instance. |
Source code in grpipe/argument.py
53 54 55 56 57 58 59 60 61 62 63 | |
Bases: BaseStep
Represents a step in the pipeline.
Source code in grpipe/step.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
__call__(*args, **kwargs)
¶
Execute the step with the given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments (not used). |
()
|
**kwargs
|
Any
|
Keyword arguments for the step. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The result of executing the step. |
Source code in grpipe/step.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
get_cache_key(kwargs)
¶
Generate a cache key based on the given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kwargs
|
dict[str, Any]
|
The keyword arguments. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
frozendict |
frozendict
|
A hashable cache key. |
Source code in grpipe/step.py
77 78 79 80 81 82 83 84 85 86 87 88 89 | |
is_cachable(bound_args, kwargs)
¶
Determine if the step's result can be cached based on the given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bound_args
|
dict[str, Any]
|
The bound arguments. |
required |
kwargs
|
dict[str, Any]
|
The keyword arguments. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the result can be cached, False otherwise. |
Source code in grpipe/step.py
64 65 66 67 68 69 70 71 72 73 74 75 | |
reset_cache()
¶
Clear the step's cache.
Source code in grpipe/step.py
143 144 145 146 | |
set_params(**kwargs)
¶
Set the parameters for the step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
The parameters to set. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Step |
Step
|
The updated step instance. |
Source code in grpipe/step.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
Bases: BaseStep
Represents a pipeline of steps.
Source code in grpipe/pipeline.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
__build_graph(*steps)
¶
Build a graph representation of the pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*steps
|
Step | Argument
|
The steps in the pipeline. |
()
|
Returns:
| Type | Description |
|---|---|
tuple[DiGraph, list[str], list[str]]
|
tuple[nx.DiGraph, list[str], list[str]]: The graph, output nodes, and argument nodes. |
Source code in grpipe/pipeline.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
__call__(*args, **kwargs)
¶
Execute the pipeline with the given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments (not used). |
()
|
**kwargs
|
Any
|
Keyword arguments for the pipeline. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The result of executing the pipeline. |
Source code in grpipe/pipeline.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
bind(**kwargs)
¶
Bind values to arguments in the pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
The values to bind to arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Pipeline |
Pipeline
|
The updated pipeline instance. |
Source code in grpipe/pipeline.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
draw(params=False)
¶
Generate a flowchart of the pipeline using mermaid markdown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
bool
|
Whether to include parameters in the flowchart. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The mermaid markdown representation of the flowchart. |
Source code in grpipe/pipeline.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
set(verbose=None, cachable=False, intermediate=False)
¶
Set the verbose and cachable properties for all steps in the pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
Optional[bool]
|
If provided, sets the verbose property. |
None
|
cachable
|
Optional[bool]
|
If provided, sets the cachable property. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Pipeline |
Pipeline
|
The updated pipeline instance. |
Source code in grpipe/pipeline.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
set_params(**kwargs)
¶
Set parameters for steps in the pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
The parameters to set, in the format "step__param". |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Pipeline |
Pipeline
|
The updated pipeline instance. |
Source code in grpipe/pipeline.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
unbind(*args)
¶
Unbind values from arguments in the pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
str
|
The names of arguments to unbind. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
Pipeline |
Pipeline
|
The updated pipeline instance. |
Source code in grpipe/pipeline.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |