dotflow 0.11.1.dev1__tar.gz → 0.12.0.dev2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/PKG-INFO +135 -27
- dotflow-0.12.0.dev2/README.md +360 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/__init__.py +1 -1
- dotflow-0.12.0.dev2/dotflow/abc/flow.py +42 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/cli/commands/start.py +18 -11
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/cli/setup.py +10 -8
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/context.py +1 -1
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/dotflow.py +10 -7
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/exception.py +1 -1
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/execution.py +8 -4
- dotflow-0.12.0.dev2/dotflow/core/serializers/task.py +47 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/serializers/workflow.py +4 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/task.py +57 -22
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/types/__init__.py +3 -1
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/types/execution.py +0 -1
- dotflow-0.12.0.dev2/dotflow/core/types/storage.py +15 -0
- dotflow-0.12.0.dev2/dotflow/core/workflow.py +333 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/pyproject.toml +2 -2
- dotflow-0.11.1.dev1/README.md +0 -252
- dotflow-0.11.1.dev1/dotflow/core/serializers/task.py +0 -25
- dotflow-0.11.1.dev1/dotflow/core/workflow.py +0 -123
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/LICENSE +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/abc/__init__.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/abc/file.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/abc/http.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/abc/storage.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/abc/tcp.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/cli/__init__.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/cli/command.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/cli/commands/__init__.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/cli/commands/init.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/cli/commands/log.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/cli/validators/__init__.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/cli/validators/start.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/__init__.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/action.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/config.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/decorators/__init__.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/decorators/time.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/module.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/serializers/__init__.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/serializers/transport.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/types/status.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/core/types/worflow.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/logging.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/main.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/providers/__init__.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/providers/storage_default.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/providers/storage_file.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/settings.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/storage.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/utils/__init__.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/utils/basic_functions.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/utils/error_handler.py +0 -0
- {dotflow-0.11.1.dev1 → dotflow-0.12.0.dev2}/dotflow/utils/tools.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: dotflow
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.12.0.dev2
|
|
4
4
|
Summary: 🎲 Dotflow turns an idea into flow!
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -217,7 +217,7 @@ workflow.task.add(step="module.task.my_task_x", callback=my_callback)
|
|
|
217
217
|
|
|
218
218
|
#### Start
|
|
219
219
|
|
|
220
|
-
Finally, just execute the workflow with the following code snippet. [More details](https://dotflow-io.github.io/dotflow/nav/reference/workflow/#dotflow.core.workflow.
|
|
220
|
+
Finally, just execute the workflow with the following code snippet. [More details](https://dotflow-io.github.io/dotflow/nav/reference/workflow/#dotflow.core.workflow.Manager)
|
|
221
221
|
|
|
222
222
|
```python
|
|
223
223
|
workflow.start()
|
|
@@ -253,33 +253,141 @@ dotflow start --step examples.cli_with_mode.simple_step --mode sequential
|
|
|
253
253
|
dotflow start --step examples.cli_with_mode.simple_step --mode background
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
+
```bash
|
|
257
|
+
dotflow start --step examples.cli_with_mode.simple_step --mode parallel
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Process Mode
|
|
261
|
+
|
|
262
|
+
#### Sequential
|
|
263
|
+
|
|
264
|
+
```python
|
|
265
|
+
workflow.task.add(step=task_foo)
|
|
266
|
+
workflow.task.add(step=task_bar)
|
|
267
|
+
|
|
268
|
+
workflow.start()
|
|
269
|
+
```
|
|
270
|
+
<details>
|
|
271
|
+
<summary>Click to see diagram</summary>
|
|
272
|
+
|
|
273
|
+
```mermaid
|
|
274
|
+
flowchart TD
|
|
275
|
+
A[Start] -->|run| B
|
|
276
|
+
B[task_foo] -->|response to| C
|
|
277
|
+
C[task_bar] -->|response| D
|
|
278
|
+
D[Finish]
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
</details>
|
|
282
|
+
|
|
283
|
+
#### Sequential with Groups
|
|
284
|
+
|
|
285
|
+
```python
|
|
286
|
+
workflow.task.add(step=task_foo, group_name="foo")
|
|
287
|
+
workflow.task.add(step=task_bar, group_name="bar")
|
|
288
|
+
|
|
289
|
+
workflow.start()
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
<details>
|
|
293
|
+
<summary>Click to see diagram</summary>
|
|
294
|
+
|
|
295
|
+
```mermaid
|
|
296
|
+
flowchart TD
|
|
297
|
+
A[Start] -->|run| C(Parallel Groups)
|
|
298
|
+
C -->|run| D[task_a]
|
|
299
|
+
C -->|run| E[task_c]
|
|
300
|
+
D -->|response| X[task_b]
|
|
301
|
+
X --> H[Finish]
|
|
302
|
+
E -->|response| Y[task_d]
|
|
303
|
+
Y --> H[Finish]
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
</details>
|
|
307
|
+
|
|
308
|
+
#### Background
|
|
309
|
+
|
|
310
|
+
```python
|
|
311
|
+
workflow.task.add(step=task_foo)
|
|
312
|
+
workflow.task.add(step=task_bar)
|
|
313
|
+
|
|
314
|
+
workflow.start(mode="background")
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
<details>
|
|
318
|
+
<summary>Click to see diagram</summary>
|
|
319
|
+
|
|
320
|
+
```mermaid
|
|
321
|
+
flowchart TD
|
|
322
|
+
A[Start] -->|run| B
|
|
323
|
+
B[task_foo] -->|response to| C
|
|
324
|
+
C[task_bar] -->|response| D
|
|
325
|
+
D[Finish]
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
</details>
|
|
329
|
+
|
|
330
|
+
#### Parallel
|
|
331
|
+
|
|
332
|
+
```python
|
|
333
|
+
workflow.task.add(step=task_a)
|
|
334
|
+
workflow.task.add(step=task_b)
|
|
335
|
+
workflow.task.add(step=task_c)
|
|
336
|
+
workflow.task.add(step=task_d)
|
|
337
|
+
|
|
338
|
+
workflow.start(mode="parallel")
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
<details>
|
|
342
|
+
<summary>Click to see diagram</summary>
|
|
343
|
+
|
|
344
|
+
```mermaid
|
|
345
|
+
flowchart TD
|
|
346
|
+
S[Start] -->|run| A[task_a]
|
|
347
|
+
S[Start] -->|run| B[task_b]
|
|
348
|
+
S[Start] -->|run| C[task_c]
|
|
349
|
+
S[Start] -->|run| D[task_d]
|
|
350
|
+
A --> H[Finish]
|
|
351
|
+
B --> H[Finish]
|
|
352
|
+
C --> H[Finish]
|
|
353
|
+
D --> H[Finish]
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
</details>
|
|
357
|
+
|
|
256
358
|
## More Examples
|
|
257
359
|
|
|
258
|
-
|
|
|
259
|
-
|
|
260
|
-
|
|
|
261
|
-
|
|
|
262
|
-
|
|
|
263
|
-
|
|
|
264
|
-
|
|
|
265
|
-
|
|
|
266
|
-
|
|
|
267
|
-
|
|
|
268
|
-
|
|
|
269
|
-
|
|
|
270
|
-
|
|
|
271
|
-
|
|
|
272
|
-
|
|
|
273
|
-
|
|
|
274
|
-
|
|
|
275
|
-
|
|
|
276
|
-
|
|
|
277
|
-
|
|
|
278
|
-
|
|
|
279
|
-
|
|
|
280
|
-
|
|
|
281
|
-
|
|
|
282
|
-
|
|
|
360
|
+
| Example | Command |
|
|
361
|
+
| -------------------------------------------------------------------------------------------------------------------------------- |----------------------------------------------------------------------------------------------------------------|
|
|
362
|
+
| [cli_with_callback](https://github.com/dotflow-io/examples/blob/master/cli_with_callback.py) | `dotflow start --step examples.cli_with_callback.simple_step --callback examples.cli_with_callback.callback` |
|
|
363
|
+
| [cli_with_initial_context](https://github.com/dotflow-io/examples/blob/master/cli_with_initial_context.py) | `dotflow start --step examples.cli_with_initial_context.simple_step --initial-context abc` |
|
|
364
|
+
| [cli_with_mode](https://github.com/dotflow-io/examples/blob/master/cli_with_mode.py) | `dotflow start --step examples.cli_with_mode.simple_step --mode sequential` |
|
|
365
|
+
| [cli_with_output_context](https://github.com/dotflow-io/examples/blob/master/cli_with_output_context.py) | `dotflow start --step examples.cli_with_output_context.simple_step --storage file` |
|
|
366
|
+
| [cli_with_path](https://github.com/dotflow-io/examples/blob/master/cli_with_path.py) | `dotflow start --step examples.cli_with_path.simple_step --path .storage --storage file` |
|
|
367
|
+
| [simple_cli](https://github.com/dotflow-io/examples/blob/master/simple_cli.py) | `dotflow start --step examples.simple_cli.simple_step` |
|
|
368
|
+
| [simple_class_workflow](https://github.com/dotflow-io/examples/blob/master/simple_class_workflow.py) | `python examples/simple_class_workflow.py` |
|
|
369
|
+
| [simple_function_workflow_with_error](https://github.com/dotflow-io/examples/blob/master/simple_function_workflow_with_error.py) | `python examples/simple_function_workflow_with_error.py` |
|
|
370
|
+
| [simple_function_workflow](https://github.com/dotflow-io/examples/blob/master/simple_function_workflow.py) | `python examples/simple_function_workflow.py` |
|
|
371
|
+
| [step_class_result_context](https://github.com/dotflow-io/examples/blob/master/step_class_result_context.py) | `python examples/step_class_result_context.py` |
|
|
372
|
+
| [step_class_result_storage](https://github.com/dotflow-io/examples/blob/master/step_class_result_storage.py) | `python examples/step_class_result_storage.py` |
|
|
373
|
+
| [step_class_result_task](https://github.com/dotflow-io/examples/blob/master/step_class_result_task.py) | `python examples/step_class_result_task.py` |
|
|
374
|
+
| [step_function_result_context](https://github.com/dotflow-io/examples/blob/master/step_function_result_context.py) | `python examples/step_function_result_context.py` |
|
|
375
|
+
| [step_function_result_storage](https://github.com/dotflow-io/examples/blob/master/step_function_result_storage.py) | `python examples/step_function_result_storage.py` |
|
|
376
|
+
| [step_function_result_task](https://github.com/dotflow-io/examples/blob/master/step_function_result_task.py) | `python examples/step_function_result_task.py` |
|
|
377
|
+
| [step_with_initial_context](https://github.com/dotflow-io/examples/blob/master/step_with_initial_context.py) | `python examples/step_with_initial_context.py` |
|
|
378
|
+
| [step_with_many_contexts](https://github.com/dotflow-io/examples/blob/master/step_with_many_contexts.py) | `python examples/step_with_many_contexts.py` |
|
|
379
|
+
| [step_with_previous_context](https://github.com/dotflow-io/examples/blob/master/step_with_previous_context.py) | `python examples/step_with_previous_context.py` |
|
|
380
|
+
| [workflow_keep_going_true](https://github.com/dotflow-io/examples/blob/master/workflow_keep_going_true.py) | `python examples/workflow_keep_going_true.py` |
|
|
381
|
+
| [workflow_step_callback](https://github.com/dotflow-io/examples/blob/master/workflow_step_callback.py) | `python examples/workflow_step_callback.py` |
|
|
382
|
+
| [workflow_with_callback_failure](https://github.com/dotflow-io/examples/blob/master/workflow_with_callback_failure.py) | `python examples/workflow_with_callback_failure.py` |
|
|
383
|
+
| [workflow_with_callback_success](https://github.com/dotflow-io/examples/blob/master/workflow_with_callback_success.py) | `python examples/workflow_with_callback_success.py` |
|
|
384
|
+
| [workflow_with_retry](https://github.com/dotflow-io/examples/blob/master/workflow_with_retry.py) | `python examples/workflow_with_retry.py` |
|
|
385
|
+
| [step_with_groups](https://github.com/dotflow-io/examples/blob/master/step_with_groups.py) | `python examples/step_with_groups.py` |
|
|
386
|
+
| [workflow_background_mode](https://github.com/dotflow-io/examples/blob/master/workflow_background_mode.py) | `python examples/workflow_background_mode.py` |
|
|
387
|
+
| [workflow_parallel_mode](https://github.com/dotflow-io/examples/blob/master/workflow_parallel_mode.py) | `python examples/workflow_parallel_mode.py` |
|
|
388
|
+
| [workflow_sequential_group_mode](https://github.com/dotflow-io/examples/blob/master/workflow_sequential_group_mode.py) | `python examples/workflow_sequential_group_mode.py` |
|
|
389
|
+
| [workflow_sequential_mode](https://github.com/dotflow-io/examples/blob/master/workflow_sequential_mode.py) | `python examples/workflow_sequential_mode.py` |
|
|
390
|
+
|
|
283
391
|
|
|
284
392
|
## Commit Style
|
|
285
393
|
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a aria-label="Serverless.com" href="https://dotflow.io">Website</a>
|
|
3
|
+
•
|
|
4
|
+
<a aria-label="Dotglow Documentation" href="https://dotflow-io.github.io/dotflow/">Documentation</a>
|
|
5
|
+
•
|
|
6
|
+
<a aria-label="Pypi" href="https://pypi.org/project/dotflow/">Pypi</a>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<br/>
|
|
10
|
+
|
|
11
|
+
<div align="center">
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+

|
|
16
|
+

|
|
17
|
+

|
|
18
|
+

|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
# Welcome to dotflow
|
|
24
|
+
|
|
25
|
+
With Dotflow, you get a powerful and easy-to-use library designed to create execution pipelines without complication. Add tasks intuitively and control the entire process with just a few commands.
|
|
26
|
+
|
|
27
|
+
Our goal is to make task management faster and more secure, without overwhelming you with complexity. Simply instantiate the DotFlow class, add your tasks with the `add` method, and start execution with the `start` method.
|
|
28
|
+
|
|
29
|
+
Start with the basics [here](https://dotflow-io.github.io/dotflow/nav/getting-started/).
|
|
30
|
+
|
|
31
|
+
## Table of Contents
|
|
32
|
+
|
|
33
|
+
<details>
|
|
34
|
+
<summary>Click to expand</summary>
|
|
35
|
+
|
|
36
|
+
- [Getting Help](#getting-help)
|
|
37
|
+
- [Getting Started](#getting-started)
|
|
38
|
+
- [Install](#install)
|
|
39
|
+
- [A Simple Example](#a-simple-example)
|
|
40
|
+
- [First Steps](#first-steps)
|
|
41
|
+
- [Import](#import)
|
|
42
|
+
- [Callback function](#callback-function)
|
|
43
|
+
- [Task function](#task-function)
|
|
44
|
+
- [DotFlow Class](#dotflow-class)
|
|
45
|
+
- [Add Task](#add-task)
|
|
46
|
+
- [Start](#start)
|
|
47
|
+
- [CLI](#cli)
|
|
48
|
+
- [Simple Start](#simple-start)
|
|
49
|
+
- [With Initial Context](#with-initial-context)
|
|
50
|
+
- [With Callback](#with-callback)
|
|
51
|
+
- [With Mode](#with-mode)
|
|
52
|
+
- [More Examples](#more-examples)
|
|
53
|
+
- [Commit Style](#commit-style)
|
|
54
|
+
- [License](#license)
|
|
55
|
+
|
|
56
|
+
</details>
|
|
57
|
+
|
|
58
|
+
## Getting Help
|
|
59
|
+
|
|
60
|
+
We use GitHub issues for tracking bugs and feature requests and have limited bandwidth to address them. If you need anything, I ask you to please follow our templates for opening issues or discussions.
|
|
61
|
+
|
|
62
|
+
- 🐛 [Bug Report](https://github.com/dotflow-io/dotflow/issues/new/choose)
|
|
63
|
+
- 📕 [Documentation Issue](https://github.com/dotflow-io/dotflow/issues/new/choose)
|
|
64
|
+
- 🚀 [Feature Request](https://github.com/dotflow-io/dotflow/issues/new/choose)
|
|
65
|
+
- 💬 [General Question](https://github.com/dotflow-io/dotflow/issues/new/choose)
|
|
66
|
+
|
|
67
|
+
## Getting Started
|
|
68
|
+
|
|
69
|
+
### Install
|
|
70
|
+
|
|
71
|
+
To install `Dotflow`, run the following command from the command line:
|
|
72
|
+
|
|
73
|
+
**With Pip**
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install dotflow
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**With Poetry**
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
poetry add dotflow
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## A Simple Example
|
|
86
|
+
|
|
87
|
+
The simplest file could look like this:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from dotflow import DotFlow, action
|
|
91
|
+
|
|
92
|
+
def my_callback(*args, **kwargs):
|
|
93
|
+
print(args, kwargs)
|
|
94
|
+
|
|
95
|
+
@action
|
|
96
|
+
def my_task_x():
|
|
97
|
+
print("task")
|
|
98
|
+
|
|
99
|
+
@action(retry=5)
|
|
100
|
+
def my_task_y():
|
|
101
|
+
print("task")
|
|
102
|
+
|
|
103
|
+
workflow = DotFlow()
|
|
104
|
+
|
|
105
|
+
workflow.task.add(step=my_task_x, callback=my_callback)
|
|
106
|
+
workflow.task.add(step=my_task_y, callback=my_callback)
|
|
107
|
+
|
|
108
|
+
workflow.start()
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## First Steps
|
|
112
|
+
|
|
113
|
+
#### Import
|
|
114
|
+
|
|
115
|
+
Start with the basics, which is importing the necessary classes and methods. ([DotFlow](https://dotflow-io.github.io/dotflow/nav/reference/dotflow/), [action](https://dotflow-io.github.io/dotflow/nav/reference/action/))
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from dotflow import DotFlow, action
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### Callback function
|
|
122
|
+
|
|
123
|
+
Create a `my_callback` function to receive execution information of a task. `It is not necessary` to include this function, as you will still have a report at the end of the execution in the instantiated object of the `DotFlow` class. This `my_callback` function is only needed if you need to do something after the execution of the task, for example: sending a message to someone, making a phone call, or sending a letter. [More details](https://dotflow-io.github.io/dotflow/nav/reference/utils/#dotflow.utils.basic_functions.basic_callback)
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
def my_callback(*args, **kwargs):
|
|
127
|
+
print(args, kwargs)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### Task function
|
|
131
|
+
|
|
132
|
+
Now, create the function responsible for executing your task. It's very simple; just use the [action](https://dotflow-io.github.io/dotflow/nav/reference/action/) decorator above the function, and that's it—you've created a task. If necessary, you can also add the parameter called `retry` to set the maximum number of execution attempts if the function fails. [More details](https://dotflow-io.github.io/dotflow/nav/reference/utils/#dotflow.utils.basic_functions.basic_function)
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
@action(retry=5)
|
|
136
|
+
def my_task_x():
|
|
137
|
+
print("task")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### DotFlow Class
|
|
141
|
+
|
|
142
|
+
Instantiate the DotFlow class in a `workflow` variable to be used in the following steps. [More details](https://dotflow-io.github.io/dotflow/nav/reference/dotflow/).
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
workflow = DotFlow()
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### Add Task
|
|
149
|
+
|
|
150
|
+
Now, simply add the `my_task_x` and `my_callback` functions you created earlier to the workflow using the code below. This process is necessary to define which tasks will be executed and the order in which they will run. The execution order follows the sequence in which they were added to the workflow. [More details](https://dotflow-io.github.io/dotflow/nav/reference/task-builder/#dotflow.core.task.TaskBuilder.add)
|
|
151
|
+
|
|
152
|
+
- Adding one step at a time:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
workflow.task.add(step=my_task_x, callback=my_callback)
|
|
156
|
+
workflow.task.add(step=my_task_y, callback=my_callback)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
- Adding multiple steps at the same time:
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
workflow.task.add(step=[my_task_x, my_task_y], callback=my_callback)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
- Adding a step with the module path:
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
workflow.task.add(step="module.task.my_task_x", callback=my_callback)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### Start
|
|
172
|
+
|
|
173
|
+
Finally, just execute the workflow with the following code snippet. [More details](https://dotflow-io.github.io/dotflow/nav/reference/workflow/#dotflow.core.workflow.Manager)
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
workflow.start()
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## CLI
|
|
180
|
+
|
|
181
|
+
#### Simple Start
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
dotflow start --step examples.cli_with_mode.simple_step
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### With Initial Context
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
dotflow start --step examples.cli_with_initial_context.simple_step --initial-context abc
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### With Callback
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
dotflow start --step examples.cli_with_callback.simple_step --callback examples.cli_with_callback.callback
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### With Mode
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
dotflow start --step examples.cli_with_mode.simple_step --mode sequential
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
dotflow start --step examples.cli_with_mode.simple_step --mode background
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
dotflow start --step examples.cli_with_mode.simple_step --mode parallel
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Process Mode
|
|
214
|
+
|
|
215
|
+
#### Sequential
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
workflow.task.add(step=task_foo)
|
|
219
|
+
workflow.task.add(step=task_bar)
|
|
220
|
+
|
|
221
|
+
workflow.start()
|
|
222
|
+
```
|
|
223
|
+
<details>
|
|
224
|
+
<summary>Click to see diagram</summary>
|
|
225
|
+
|
|
226
|
+
```mermaid
|
|
227
|
+
flowchart TD
|
|
228
|
+
A[Start] -->|run| B
|
|
229
|
+
B[task_foo] -->|response to| C
|
|
230
|
+
C[task_bar] -->|response| D
|
|
231
|
+
D[Finish]
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
</details>
|
|
235
|
+
|
|
236
|
+
#### Sequential with Groups
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
workflow.task.add(step=task_foo, group_name="foo")
|
|
240
|
+
workflow.task.add(step=task_bar, group_name="bar")
|
|
241
|
+
|
|
242
|
+
workflow.start()
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
<details>
|
|
246
|
+
<summary>Click to see diagram</summary>
|
|
247
|
+
|
|
248
|
+
```mermaid
|
|
249
|
+
flowchart TD
|
|
250
|
+
A[Start] -->|run| C(Parallel Groups)
|
|
251
|
+
C -->|run| D[task_a]
|
|
252
|
+
C -->|run| E[task_c]
|
|
253
|
+
D -->|response| X[task_b]
|
|
254
|
+
X --> H[Finish]
|
|
255
|
+
E -->|response| Y[task_d]
|
|
256
|
+
Y --> H[Finish]
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
</details>
|
|
260
|
+
|
|
261
|
+
#### Background
|
|
262
|
+
|
|
263
|
+
```python
|
|
264
|
+
workflow.task.add(step=task_foo)
|
|
265
|
+
workflow.task.add(step=task_bar)
|
|
266
|
+
|
|
267
|
+
workflow.start(mode="background")
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
<details>
|
|
271
|
+
<summary>Click to see diagram</summary>
|
|
272
|
+
|
|
273
|
+
```mermaid
|
|
274
|
+
flowchart TD
|
|
275
|
+
A[Start] -->|run| B
|
|
276
|
+
B[task_foo] -->|response to| C
|
|
277
|
+
C[task_bar] -->|response| D
|
|
278
|
+
D[Finish]
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
</details>
|
|
282
|
+
|
|
283
|
+
#### Parallel
|
|
284
|
+
|
|
285
|
+
```python
|
|
286
|
+
workflow.task.add(step=task_a)
|
|
287
|
+
workflow.task.add(step=task_b)
|
|
288
|
+
workflow.task.add(step=task_c)
|
|
289
|
+
workflow.task.add(step=task_d)
|
|
290
|
+
|
|
291
|
+
workflow.start(mode="parallel")
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
<details>
|
|
295
|
+
<summary>Click to see diagram</summary>
|
|
296
|
+
|
|
297
|
+
```mermaid
|
|
298
|
+
flowchart TD
|
|
299
|
+
S[Start] -->|run| A[task_a]
|
|
300
|
+
S[Start] -->|run| B[task_b]
|
|
301
|
+
S[Start] -->|run| C[task_c]
|
|
302
|
+
S[Start] -->|run| D[task_d]
|
|
303
|
+
A --> H[Finish]
|
|
304
|
+
B --> H[Finish]
|
|
305
|
+
C --> H[Finish]
|
|
306
|
+
D --> H[Finish]
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
</details>
|
|
310
|
+
|
|
311
|
+
## More Examples
|
|
312
|
+
|
|
313
|
+
| Example | Command |
|
|
314
|
+
| -------------------------------------------------------------------------------------------------------------------------------- |----------------------------------------------------------------------------------------------------------------|
|
|
315
|
+
| [cli_with_callback](https://github.com/dotflow-io/examples/blob/master/cli_with_callback.py) | `dotflow start --step examples.cli_with_callback.simple_step --callback examples.cli_with_callback.callback` |
|
|
316
|
+
| [cli_with_initial_context](https://github.com/dotflow-io/examples/blob/master/cli_with_initial_context.py) | `dotflow start --step examples.cli_with_initial_context.simple_step --initial-context abc` |
|
|
317
|
+
| [cli_with_mode](https://github.com/dotflow-io/examples/blob/master/cli_with_mode.py) | `dotflow start --step examples.cli_with_mode.simple_step --mode sequential` |
|
|
318
|
+
| [cli_with_output_context](https://github.com/dotflow-io/examples/blob/master/cli_with_output_context.py) | `dotflow start --step examples.cli_with_output_context.simple_step --storage file` |
|
|
319
|
+
| [cli_with_path](https://github.com/dotflow-io/examples/blob/master/cli_with_path.py) | `dotflow start --step examples.cli_with_path.simple_step --path .storage --storage file` |
|
|
320
|
+
| [simple_cli](https://github.com/dotflow-io/examples/blob/master/simple_cli.py) | `dotflow start --step examples.simple_cli.simple_step` |
|
|
321
|
+
| [simple_class_workflow](https://github.com/dotflow-io/examples/blob/master/simple_class_workflow.py) | `python examples/simple_class_workflow.py` |
|
|
322
|
+
| [simple_function_workflow_with_error](https://github.com/dotflow-io/examples/blob/master/simple_function_workflow_with_error.py) | `python examples/simple_function_workflow_with_error.py` |
|
|
323
|
+
| [simple_function_workflow](https://github.com/dotflow-io/examples/blob/master/simple_function_workflow.py) | `python examples/simple_function_workflow.py` |
|
|
324
|
+
| [step_class_result_context](https://github.com/dotflow-io/examples/blob/master/step_class_result_context.py) | `python examples/step_class_result_context.py` |
|
|
325
|
+
| [step_class_result_storage](https://github.com/dotflow-io/examples/blob/master/step_class_result_storage.py) | `python examples/step_class_result_storage.py` |
|
|
326
|
+
| [step_class_result_task](https://github.com/dotflow-io/examples/blob/master/step_class_result_task.py) | `python examples/step_class_result_task.py` |
|
|
327
|
+
| [step_function_result_context](https://github.com/dotflow-io/examples/blob/master/step_function_result_context.py) | `python examples/step_function_result_context.py` |
|
|
328
|
+
| [step_function_result_storage](https://github.com/dotflow-io/examples/blob/master/step_function_result_storage.py) | `python examples/step_function_result_storage.py` |
|
|
329
|
+
| [step_function_result_task](https://github.com/dotflow-io/examples/blob/master/step_function_result_task.py) | `python examples/step_function_result_task.py` |
|
|
330
|
+
| [step_with_initial_context](https://github.com/dotflow-io/examples/blob/master/step_with_initial_context.py) | `python examples/step_with_initial_context.py` |
|
|
331
|
+
| [step_with_many_contexts](https://github.com/dotflow-io/examples/blob/master/step_with_many_contexts.py) | `python examples/step_with_many_contexts.py` |
|
|
332
|
+
| [step_with_previous_context](https://github.com/dotflow-io/examples/blob/master/step_with_previous_context.py) | `python examples/step_with_previous_context.py` |
|
|
333
|
+
| [workflow_keep_going_true](https://github.com/dotflow-io/examples/blob/master/workflow_keep_going_true.py) | `python examples/workflow_keep_going_true.py` |
|
|
334
|
+
| [workflow_step_callback](https://github.com/dotflow-io/examples/blob/master/workflow_step_callback.py) | `python examples/workflow_step_callback.py` |
|
|
335
|
+
| [workflow_with_callback_failure](https://github.com/dotflow-io/examples/blob/master/workflow_with_callback_failure.py) | `python examples/workflow_with_callback_failure.py` |
|
|
336
|
+
| [workflow_with_callback_success](https://github.com/dotflow-io/examples/blob/master/workflow_with_callback_success.py) | `python examples/workflow_with_callback_success.py` |
|
|
337
|
+
| [workflow_with_retry](https://github.com/dotflow-io/examples/blob/master/workflow_with_retry.py) | `python examples/workflow_with_retry.py` |
|
|
338
|
+
| [step_with_groups](https://github.com/dotflow-io/examples/blob/master/step_with_groups.py) | `python examples/step_with_groups.py` |
|
|
339
|
+
| [workflow_background_mode](https://github.com/dotflow-io/examples/blob/master/workflow_background_mode.py) | `python examples/workflow_background_mode.py` |
|
|
340
|
+
| [workflow_parallel_mode](https://github.com/dotflow-io/examples/blob/master/workflow_parallel_mode.py) | `python examples/workflow_parallel_mode.py` |
|
|
341
|
+
| [workflow_sequential_group_mode](https://github.com/dotflow-io/examples/blob/master/workflow_sequential_group_mode.py) | `python examples/workflow_sequential_group_mode.py` |
|
|
342
|
+
| [workflow_sequential_mode](https://github.com/dotflow-io/examples/blob/master/workflow_sequential_mode.py) | `python examples/workflow_sequential_mode.py` |
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
## Commit Style
|
|
346
|
+
|
|
347
|
+
- ⚙️ FEATURE
|
|
348
|
+
- 📝 PEP8
|
|
349
|
+
- 📌 ISSUE
|
|
350
|
+
- 🪲 BUG
|
|
351
|
+
- 📘 DOCS
|
|
352
|
+
- 📦 PyPI
|
|
353
|
+
- ❤️️ TEST
|
|
354
|
+
- ⬆️ CI/CD
|
|
355
|
+
- ⚠️ SECURITY
|
|
356
|
+
|
|
357
|
+
## License
|
|
358
|
+

|
|
359
|
+
|
|
360
|
+
This project is licensed under the terms of the MIT License.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Flow ABC"""
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from uuid import UUID
|
|
5
|
+
from typing import Dict, List
|
|
6
|
+
|
|
7
|
+
from dotflow.core.task import Task
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Flow(ABC):
|
|
11
|
+
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
tasks: List[Task],
|
|
15
|
+
workflow_id: UUID,
|
|
16
|
+
ignore: bool,
|
|
17
|
+
groups: Dict[str, List[Task]]
|
|
18
|
+
) -> None:
|
|
19
|
+
self.queue = None
|
|
20
|
+
self.tasks = tasks
|
|
21
|
+
self.workflow_id = workflow_id
|
|
22
|
+
self.ignore = ignore
|
|
23
|
+
self.groups = groups
|
|
24
|
+
|
|
25
|
+
self.setup_queue()
|
|
26
|
+
self.run()
|
|
27
|
+
|
|
28
|
+
@abstractmethod
|
|
29
|
+
def setup_queue(self) -> None:
|
|
30
|
+
self.queue = []
|
|
31
|
+
|
|
32
|
+
@abstractmethod
|
|
33
|
+
def get_tasks(self) -> List[Task]:
|
|
34
|
+
return self.queue
|
|
35
|
+
|
|
36
|
+
@abstractmethod
|
|
37
|
+
def _internal_callback(self, task: Task) -> None:
|
|
38
|
+
self.queue.append(task)
|
|
39
|
+
|
|
40
|
+
@abstractmethod
|
|
41
|
+
def run(self) -> None:
|
|
42
|
+
return None
|
|
@@ -11,17 +11,7 @@ from dotflow.cli.command import Command
|
|
|
11
11
|
class StartCommand(Command):
|
|
12
12
|
|
|
13
13
|
def setup(self):
|
|
14
|
-
workflow =
|
|
15
|
-
|
|
16
|
-
if self.params.storage:
|
|
17
|
-
storage = {"default": StorageDefault, "file": StorageFile}
|
|
18
|
-
|
|
19
|
-
config = Config(
|
|
20
|
-
storage=storage.get(self.params.storage)(
|
|
21
|
-
path=self.params.path,
|
|
22
|
-
)
|
|
23
|
-
)
|
|
24
|
-
workflow = DotFlow(config=config)
|
|
14
|
+
workflow = self._new_workflow()
|
|
25
15
|
|
|
26
16
|
workflow.task.add(
|
|
27
17
|
step=self.params.step,
|
|
@@ -33,3 +23,20 @@ class StartCommand(Command):
|
|
|
33
23
|
|
|
34
24
|
if self.params.mode == TypeExecution.BACKGROUND:
|
|
35
25
|
system("/bin/bash")
|
|
26
|
+
|
|
27
|
+
def _new_workflow(self):
|
|
28
|
+
if not self.params.storage:
|
|
29
|
+
return DotFlow()
|
|
30
|
+
|
|
31
|
+
storage_classes = {
|
|
32
|
+
"default": StorageDefault,
|
|
33
|
+
"file": StorageFile
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
config = Config(
|
|
37
|
+
storage=storage_classes.get(self.params.storage)(
|
|
38
|
+
path=self.params.path,
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
return DotFlow(config=config)
|