API Reference
Flow
Bases: StateModel
Flow class represents a sequence of jobs to be executed in a defined order.
| Attributes: |
|
|---|
Properties
jobs_count (int): Returns the number of jobs in the flow.
Methods:
| Name | Description |
|---|---|
next_job |
Yields the index and job for each job in the flow. |
execute |
Raises an exception if any job fails during execution. |
summary |
Prints a summary of the actions in each job of the flow. |
load |
str) -> dict: Loads flow data from a YAML string and returns a dictionary containing the parsed flow data. |
from_file |
str) -> "Flow": Creates a Flow instance from a file containing the flow data. |
from_string |
str) -> "Flow": Creates a Flow instance from a raw string containing the flow data. |
load_all_actions |
Loads all action modules from the 'actionflow.actions' package. |
Source code in actionflow/core.py
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 | |
execute()
Executes the flow by starting the machine, executing each job, and handling success or failure.
The method performs the following steps: 1. Starts the machine. 2. Prints a message indicating the start of execution. 3. Iterates over the jobs and executes each one. 4. Checks the state of each job's machine. If any job fails (state is not "success"), raises an exception. 5. If all jobs succeed, completes the machine.
If an exception occurs during execution: - Fails the machine. - Prints an error message with the exception details.
| Raises: |
|
|---|
Source code in actionflow/core.py
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 | |
from_file(filepath)
classmethod
Create a Flow instance from a file.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Source code in actionflow/core.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
from_string(raw)
classmethod
Create a Flow instance from a raw string.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in actionflow/core.py
198 199 200 201 202 203 204 205 206 207 208 209 210 | |
load(raw)
staticmethod
Load flow data from a YAML string.
This function takes a YAML string as input, parses it, and returns a dictionary containing the flow data. It processes the environment variables and jobs defined in the YAML string and structures them into a new dictionary format.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in actionflow/core.py
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 | |
Group
Bases: StateModel
A class representing a group of actions to be executed in parallel.
| Attributes: |
|
|---|
Methods:
| Name | Description |
|---|---|
next_action |
Yields the index and action for each action in the group. |
execute |
Executes all actions in the group in parallel. If any action fails, the group's state is set to 'fail'. If all actions succeed, the group's state is set to 'complete'. |
Source code in actionflow/jobs.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 | |
Job
Bases: StateModel
Represents a job consisting of a series of actions to be executed.
| Attributes: |
|
|---|
Methods:
| Name | Description |
|---|---|
preprocess_data |
Replaces steps with action instances created from the registry. |
length |
Returns the number of steps in the job. |
grouped |
Groups the steps by the "concurrency" attribute. |
set_indexes |
int) -> None: Sets unique indexes for each action in the job. |
next_group |
Yields the next group of actions to be executed. |
execute |
Executes the job by running all actions in sequence, handling state transitions and logging. |
Source code in actionflow/jobs.py
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 | |
preprocess_data(values)
Replace steps with action instances created from the registry
Source code in actionflow/jobs.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
Action
Bases: BaseAction, StateModel
Source code in actionflow/action.py
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 | |
execute()
Unified execution pipeline.
Source code in actionflow/action.py
96 97 98 99 100 101 102 103 | |
run()
Run the action with retry logic
Source code in actionflow/action.py
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 | |
summary()
Summary of the action
Source code in actionflow/action.py
105 106 107 108 109 110 111 | |
BaseAction
Bases: ABC
Source code in actionflow/action.py
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 | |
by_name(name, **kwargs)
classmethod
Get subclass by name
Source code in actionflow/action.py
21 22 23 24 25 26 27 | |
list()
classmethod
List subclasses
Source code in actionflow/action.py
16 17 18 19 | |
set_context(context)
Set context for the action
Source code in actionflow/action.py
29 30 31 | |
Actions
Pull
Bases: Action
Action to pull Docker images.
| Attributes: |
|
|---|
Methods:
| Name | Description |
|---|---|
_get_credentials |
Retrieves the credentials for Docker registry authentication. |
_check |
Checks if all specified images are already present in the local Docker client. |
_run |
Pulls the specified images from the Docker registry if they are not already present. |
Source code in actionflow/actions/container.py
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 | |