dotflow 0.7.0__tar.gz → 0.8.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.
Files changed (55) hide show
  1. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/PKG-INFO +29 -22
  2. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/README.md +25 -18
  3. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/__init__.py +3 -1
  4. dotflow-0.8.0.dev2/dotflow/cli/command.py +10 -0
  5. dotflow-0.8.0.dev2/dotflow/cli/commands/__init__.py +12 -0
  6. dotflow-0.8.0.dev2/dotflow/cli/commands/init.py +16 -0
  7. dotflow-0.8.0.dev2/dotflow/cli/commands/server.py +9 -0
  8. dotflow-0.8.0.dev2/dotflow/cli/commands/start.py +35 -0
  9. dotflow-0.8.0.dev2/dotflow/cli/setup.py +99 -0
  10. dotflow-0.8.0.dev2/dotflow/cli/validators/__init__.py +8 -0
  11. dotflow-0.8.0.dev2/dotflow/cli/validators/start.py +16 -0
  12. dotflow-0.8.0.dev2/dotflow/core/config.py +18 -0
  13. dotflow-0.8.0.dev2/dotflow/core/dotflow.py +37 -0
  14. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/exception.py +10 -0
  15. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/execution.py +9 -9
  16. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/models/__init__.py +2 -2
  17. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/models/status.py +2 -2
  18. dotflow-0.8.0.dev2/dotflow/core/models/worflow.py +8 -0
  19. dotflow-0.8.0.dev2/dotflow/core/module.py +41 -0
  20. dotflow-0.8.0.dev2/dotflow/core/task.py +193 -0
  21. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/utils/__init__.py +4 -1
  22. dotflow-0.8.0.dev2/dotflow/core/utils/tools.py +26 -0
  23. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/workflow.py +9 -6
  24. dotflow-0.8.0.dev2/dotflow/log.py +29 -0
  25. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/main.py +1 -1
  26. dotflow-0.8.0.dev2/dotflow/providers/zeromq.py +49 -0
  27. dotflow-0.8.0.dev2/dotflow/settings.py +9 -0
  28. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/pyproject.toml +9 -4
  29. dotflow-0.7.0/dotflow/cli/commands/__init__.py +0 -0
  30. dotflow-0.7.0/dotflow/cli/commands/server.py +0 -4
  31. dotflow-0.7.0/dotflow/cli/setup.py +0 -35
  32. dotflow-0.7.0/dotflow/core/dotflow.py +0 -22
  33. dotflow-0.7.0/dotflow/core/task.py +0 -98
  34. dotflow-0.7.0/dotflow/providers/zeromq.py +0 -49
  35. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/LICENSE +0 -0
  36. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/abc/__init__.py +0 -0
  37. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/abc/file.py +0 -0
  38. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/abc/http.py +0 -0
  39. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/abc/tcp.py +0 -0
  40. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/cli/__init__.py +0 -0
  41. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/__init__.py +0 -0
  42. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/action.py +0 -0
  43. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/context.py +0 -0
  44. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/decorators/__init__.py +0 -0
  45. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/decorators/action.py +0 -0
  46. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/decorators/retry.py +0 -0
  47. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/decorators/time.py +0 -0
  48. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/models/execution.py +0 -0
  49. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/serializers/__init__.py +0 -0
  50. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/serializers/task.py +0 -0
  51. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/serializers/transport.py +0 -0
  52. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/serializers/workflow.py +0 -0
  53. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/utils/basic_functions.py +0 -0
  54. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/core/utils/error_handler.py +0 -0
  55. {dotflow-0.7.0 → dotflow-0.8.0.dev2}/dotflow/providers/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dotflow
3
- Version: 0.7.0
3
+ Version: 0.8.0.dev2
4
4
  Summary: 🎲 Dotflow turns an idea into flow!
5
5
  License: MIT License
6
6
 
@@ -25,7 +25,7 @@ License: MIT License
25
25
  SOFTWARE.
26
26
  Author: Fernando Celmer
27
27
  Author-email: email@fernandocelmer.com
28
- Requires-Python: >=3.8
28
+ Requires-Python: >=3.9
29
29
  Classifier: Development Status :: 4 - Beta
30
30
  Classifier: Operating System :: OS Independent
31
31
  Classifier: Intended Audience :: Developers
@@ -34,8 +34,8 @@ Classifier: Programming Language :: Python :: 3.9
34
34
  Classifier: Programming Language :: Python :: 3.10
35
35
  Classifier: Programming Language :: Python :: 3.11
36
36
  Classifier: Programming Language :: Python :: 3.12
37
- Requires-Dist: pydantic (>=2.10.6,<3.0.0)
38
- Requires-Dist: pyzmq (>=26.2.1,<27.0.0)
37
+ Requires-Dist: pydantic
38
+ Requires-Dist: rich
39
39
  Project-URL: Documentation, https://github.com/dotflow-io/dotflow/blob/master/README.md
40
40
  Project-URL: Homepage, https://github.com/dotflow-io/dotflow
41
41
  Project-URL: Issues, https://github.com/dotflow-io/dotflow/issues
@@ -83,7 +83,7 @@ pip install dotflow
83
83
  poetry add dotflow
84
84
  ```
85
85
 
86
- ## First Steps
86
+ ## A Simple Example
87
87
 
88
88
  The simplest file could look like this:
89
89
 
@@ -102,6 +102,8 @@ workflow.task.add(step=my_task, callback=my_callback)
102
102
  workflow.start()
103
103
  ```
104
104
 
105
+ ## First Steps
106
+
105
107
  #### 1 - Import
106
108
 
107
109
  Start with the basics, which is importing the necessary classes and methods. ([DotFlow](https://dotflow-io.github.io/dotflow/nav/reference/dotflow-class/), [action](https://dotflow-io.github.io/dotflow/nav/reference/action-decorator/))
@@ -157,23 +159,28 @@ workflow.start()
157
159
 
158
160
  | | Example |
159
161
  |--| ---------------------------------------------------------------------------------------------------------------------------------------- |
160
- |01| [simple_class_workflow](https://github.com/dotflow-io/dotflow/blob/master/examples/simple_class_workflow.py) |
161
- |02| [simple_function_workflow_with_error](https://github.com/dotflow-io/dotflow/blob/master/examples/simple_function_workflow_with_error.py) |
162
- |03| [simple_function_workflow](https://github.com/dotflow-io/dotflow/blob/master/examples/simple_function_workflow.py) |
163
- |04| [step_class_result_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_class_result_context.py) |
164
- |05| [step_class_result_storage](https://github.com/dotflow-io/dotflow/blob/master/examples/step_class_result_storage.py) |
165
- |06| [step_class_result_task](https://github.com/dotflow-io/dotflow/blob/master/examples/step_class_result_task.py) |
166
- |07| [step_function_result_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_function_result_context.py) |
167
- |08| [step_function_result_storage](https://github.com/dotflow-io/dotflow/blob/master/examples/step_function_result_storage.py) |
168
- |09| [step_function_result_task](https://github.com/dotflow-io/dotflow/blob/master/examples/step_function_result_task.py) |
169
- |10| [step_with_initial_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_with_initial_context.py) |
170
- |11| [step_with_many_contexts](https://github.com/dotflow-io/dotflow/blob/master/examples/step_with_many_contexts.py) |
171
- |12| [step_with_previous_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_with_previous_context.py) |
172
- |13| [workflow_keep_going_true](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_keep_going_true.py) |
173
- |14| [workflow_step_callback](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_step_callback.py) |
174
- |15| [workflow_with_callback_failure](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_with_callback_failure.py) |
175
- |16| [workflow_with_callback_success](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_with_callback_success.py) |
176
- |17| [workflow_with_retry](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_with_retry.py) |
162
+ |01| [cli_with_callback](https://github.com/dotflow-io/dotflow/blob/master/examples/cli_with_callback.py) |
163
+ |02| [cli_with_initial_context](https://github.com/dotflow-io/dotflow/blob/master/examples/cli_with_initial_context.py) |
164
+ |03| [cli_with_output](https://github.com/dotflow-io/dotflow/blob/master/examples/cli_with_output.py) |
165
+ |04| [cli_with_path](https://github.com/dotflow-io/dotflow/blob/master/examples/cli_with_path.py) |
166
+ |05| [cli](https://github.com/dotflow-io/dotflow/blob/master/examples/cli.py) |
167
+ |06| [simple_class_workflow](https://github.com/dotflow-io/dotflow/blob/master/examples/simple_class_workflow.py) |
168
+ |07| [simple_function_workflow_with_error](https://github.com/dotflow-io/dotflow/blob/master/examples/simple_function_workflow_with_error.py) |
169
+ |08| [simple_function_workflow](https://github.com/dotflow-io/dotflow/blob/master/examples/simple_function_workflow.py) |
170
+ |09| [step_class_result_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_class_result_context.py) |
171
+ |10| [step_class_result_storage](https://github.com/dotflow-io/dotflow/blob/master/examples/step_class_result_storage.py) |
172
+ |11| [step_class_result_task](https://github.com/dotflow-io/dotflow/blob/master/examples/step_class_result_task.py) |
173
+ |12| [step_function_result_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_function_result_context.py) |
174
+ |13| [step_function_result_storage](https://github.com/dotflow-io/dotflow/blob/master/examples/step_function_result_storage.py) |
175
+ |14| [step_function_result_task](https://github.com/dotflow-io/dotflow/blob/master/examples/step_function_result_task.py) |
176
+ |15| [step_with_initial_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_with_initial_context.py) |
177
+ |16| [step_with_many_contexts](https://github.com/dotflow-io/dotflow/blob/master/examples/step_with_many_contexts.py) |
178
+ |17| [step_with_previous_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_with_previous_context.py) |
179
+ |18| [workflow_keep_going_true](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_keep_going_true.py) |
180
+ |19| [workflow_step_callback](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_step_callback.py) |
181
+ |20| [workflow_with_callback_failure](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_with_callback_failure.py) |
182
+ |21| [workflow_with_callback_success](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_with_callback_success.py) |
183
+ |22| [workflow_with_retry](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_with_retry.py) |
177
184
 
178
185
  ## Commit Style
179
186
 
@@ -39,7 +39,7 @@ pip install dotflow
39
39
  poetry add dotflow
40
40
  ```
41
41
 
42
- ## First Steps
42
+ ## A Simple Example
43
43
 
44
44
  The simplest file could look like this:
45
45
 
@@ -58,6 +58,8 @@ workflow.task.add(step=my_task, callback=my_callback)
58
58
  workflow.start()
59
59
  ```
60
60
 
61
+ ## First Steps
62
+
61
63
  #### 1 - Import
62
64
 
63
65
  Start with the basics, which is importing the necessary classes and methods. ([DotFlow](https://dotflow-io.github.io/dotflow/nav/reference/dotflow-class/), [action](https://dotflow-io.github.io/dotflow/nav/reference/action-decorator/))
@@ -113,23 +115,28 @@ workflow.start()
113
115
 
114
116
  | | Example |
115
117
  |--| ---------------------------------------------------------------------------------------------------------------------------------------- |
116
- |01| [simple_class_workflow](https://github.com/dotflow-io/dotflow/blob/master/examples/simple_class_workflow.py) |
117
- |02| [simple_function_workflow_with_error](https://github.com/dotflow-io/dotflow/blob/master/examples/simple_function_workflow_with_error.py) |
118
- |03| [simple_function_workflow](https://github.com/dotflow-io/dotflow/blob/master/examples/simple_function_workflow.py) |
119
- |04| [step_class_result_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_class_result_context.py) |
120
- |05| [step_class_result_storage](https://github.com/dotflow-io/dotflow/blob/master/examples/step_class_result_storage.py) |
121
- |06| [step_class_result_task](https://github.com/dotflow-io/dotflow/blob/master/examples/step_class_result_task.py) |
122
- |07| [step_function_result_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_function_result_context.py) |
123
- |08| [step_function_result_storage](https://github.com/dotflow-io/dotflow/blob/master/examples/step_function_result_storage.py) |
124
- |09| [step_function_result_task](https://github.com/dotflow-io/dotflow/blob/master/examples/step_function_result_task.py) |
125
- |10| [step_with_initial_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_with_initial_context.py) |
126
- |11| [step_with_many_contexts](https://github.com/dotflow-io/dotflow/blob/master/examples/step_with_many_contexts.py) |
127
- |12| [step_with_previous_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_with_previous_context.py) |
128
- |13| [workflow_keep_going_true](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_keep_going_true.py) |
129
- |14| [workflow_step_callback](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_step_callback.py) |
130
- |15| [workflow_with_callback_failure](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_with_callback_failure.py) |
131
- |16| [workflow_with_callback_success](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_with_callback_success.py) |
132
- |17| [workflow_with_retry](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_with_retry.py) |
118
+ |01| [cli_with_callback](https://github.com/dotflow-io/dotflow/blob/master/examples/cli_with_callback.py) |
119
+ |02| [cli_with_initial_context](https://github.com/dotflow-io/dotflow/blob/master/examples/cli_with_initial_context.py) |
120
+ |03| [cli_with_output](https://github.com/dotflow-io/dotflow/blob/master/examples/cli_with_output.py) |
121
+ |04| [cli_with_path](https://github.com/dotflow-io/dotflow/blob/master/examples/cli_with_path.py) |
122
+ |05| [cli](https://github.com/dotflow-io/dotflow/blob/master/examples/cli.py) |
123
+ |06| [simple_class_workflow](https://github.com/dotflow-io/dotflow/blob/master/examples/simple_class_workflow.py) |
124
+ |07| [simple_function_workflow_with_error](https://github.com/dotflow-io/dotflow/blob/master/examples/simple_function_workflow_with_error.py) |
125
+ |08| [simple_function_workflow](https://github.com/dotflow-io/dotflow/blob/master/examples/simple_function_workflow.py) |
126
+ |09| [step_class_result_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_class_result_context.py) |
127
+ |10| [step_class_result_storage](https://github.com/dotflow-io/dotflow/blob/master/examples/step_class_result_storage.py) |
128
+ |11| [step_class_result_task](https://github.com/dotflow-io/dotflow/blob/master/examples/step_class_result_task.py) |
129
+ |12| [step_function_result_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_function_result_context.py) |
130
+ |13| [step_function_result_storage](https://github.com/dotflow-io/dotflow/blob/master/examples/step_function_result_storage.py) |
131
+ |14| [step_function_result_task](https://github.com/dotflow-io/dotflow/blob/master/examples/step_function_result_task.py) |
132
+ |15| [step_with_initial_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_with_initial_context.py) |
133
+ |16| [step_with_many_contexts](https://github.com/dotflow-io/dotflow/blob/master/examples/step_with_many_contexts.py) |
134
+ |17| [step_with_previous_context](https://github.com/dotflow-io/dotflow/blob/master/examples/step_with_previous_context.py) |
135
+ |18| [workflow_keep_going_true](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_keep_going_true.py) |
136
+ |19| [workflow_step_callback](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_step_callback.py) |
137
+ |20| [workflow_with_callback_failure](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_with_callback_failure.py) |
138
+ |21| [workflow_with_callback_success](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_with_callback_success.py) |
139
+ |22| [workflow_with_retry](https://github.com/dotflow-io/dotflow/blob/master/examples/workflow_with_retry.py) |
133
140
 
134
141
  ## Commit Style
135
142
 
@@ -1,8 +1,9 @@
1
1
  """Dotflow __init__ module."""
2
2
 
3
- __version__ = "0.7.0"
3
+ __version__ = "0.8.0.dev2"
4
4
  __description__ = "🎲 Dotflow turns an idea into flow!"
5
5
 
6
+ from .core.config import Config
6
7
  from .core.action import Action as action
7
8
  from .core.context import Context
8
9
  from .core.dotflow import DotFlow
@@ -15,5 +16,6 @@ __all__ = [
15
16
  "retry",
16
17
  "DotFlow",
17
18
  "Context",
19
+ "Config",
18
20
  "Task"
19
21
  ]
@@ -0,0 +1,10 @@
1
+ """Command module"""
2
+
3
+
4
+ class Command:
5
+
6
+ def __init__(self, **kwargs):
7
+ self.params = kwargs.get("arguments")
8
+
9
+ if hasattr(self.params, "option"):
10
+ getattr(self, self.params.option)()
@@ -0,0 +1,12 @@
1
+ """Commands __init__ module."""
2
+
3
+ from dotflow.cli.commands.init import InitCommand
4
+ from dotflow.cli.commands.server import ServerCommand
5
+ from dotflow.cli.commands.start import StartCommand
6
+
7
+
8
+ __all__ = [
9
+ "InitCommand",
10
+ "ServerCommand",
11
+ "StartCommand"
12
+ ]
@@ -0,0 +1,16 @@
1
+ """Command init module"""
2
+
3
+ from os import system, path
4
+
5
+ from dotflow.cli.command import Command
6
+
7
+
8
+ class InitCommand(Command):
9
+
10
+ def __init__(self, **kwargs):
11
+ self.params = kwargs.get("arguments")
12
+ self.init()
13
+
14
+ def init(self):
15
+ if path.isfile(".gitignore"):
16
+ system("echo '\n\n# Dotflow\n.output' >> .gitignore")
@@ -0,0 +1,9 @@
1
+ """Command server module"""
2
+
3
+ from dotflow.cli.command import Command
4
+
5
+
6
+ class ServerCommand(Command):
7
+
8
+ def __init__(self, *args, **kwargs):
9
+ pass
@@ -0,0 +1,35 @@
1
+ """Command start module"""
2
+
3
+ from os import system
4
+
5
+ from dotflow import DotFlow, Config
6
+ from dotflow.core.models.execution import TypeExecution
7
+ from dotflow.cli.command import Command
8
+
9
+
10
+ class StartCommand(Command):
11
+
12
+ def __init__(self, **kwargs):
13
+ self.params = kwargs.get("arguments")
14
+ self.start()
15
+
16
+ def start(self):
17
+ workflow = DotFlow(
18
+ config=Config(
19
+ path=self.params.path,
20
+ output=self.params.output_context
21
+ )
22
+ )
23
+
24
+ workflow.task.add(
25
+ step=self.params.step,
26
+ callback=self.params.callback,
27
+ initial_context=self.params.initial_context
28
+ )
29
+
30
+ workflow.start(
31
+ mode=self.params.mode
32
+ )
33
+
34
+ if self.params.mode == TypeExecution.BACKGROUND:
35
+ system("/bin/bash")
@@ -0,0 +1,99 @@
1
+ """Setup module"""
2
+
3
+ from rich import print # type: ignore
4
+
5
+ from dotflow import __version__, __description__
6
+ from dotflow.log import logger
7
+ from dotflow.settings import Settings as settings
8
+ from dotflow.core.utils.basic_functions import basic_callback
9
+ from dotflow.core.models.execution import TypeExecution
10
+ from dotflow.core.exception import (
11
+ MissingActionDecorator,
12
+ ExecutionModeNotExist,
13
+ StepMissingInit,
14
+ ModuleNotFound,
15
+ MESSAGE_UNKNOWN_ERROR,
16
+ )
17
+ from dotflow.cli.commands import InitCommand, ServerCommand, StartCommand
18
+
19
+
20
+ class Command:
21
+
22
+ def __init__(self, parser):
23
+ self.parser = parser
24
+ self.subparsers = self.parser.add_subparsers()
25
+ self.parser._positionals.title = "Commands"
26
+ self.parser._optionals.title = "Default Options"
27
+ self.parser.add_argument(
28
+ "-v",
29
+ "--version",
30
+ action="version",
31
+ version=f"dotflow=={__version__}",
32
+ help="Show program's version number and exit.",
33
+ )
34
+
35
+ self.setup_init()
36
+ self.setup_start()
37
+ self.command()
38
+
39
+ def setup_server(self):
40
+ self.cmd_server = self.subparsers.add_parser("server", help="Server")
41
+ self.cmd_server = self.cmd_server.add_argument_group(
42
+ "Usage: dotflow server [OPTIONS]"
43
+ )
44
+ self.cmd_server.set_defaults(exec=ServerCommand)
45
+
46
+ def setup_init(self):
47
+ self.cmd_init = self.subparsers.add_parser("init", help="Init")
48
+ self.cmd_init = self.cmd_init.add_argument_group(
49
+ "Usage: dotflow init [OPTIONS]"
50
+ )
51
+ self.cmd_init.set_defaults(exec=InitCommand)
52
+
53
+ def setup_start(self):
54
+ self.cmd_start = self.subparsers.add_parser("start", help="Start")
55
+ self.cmd_start = self.cmd_start.add_argument_group(
56
+ "Usage: dotflow start [OPTIONS]"
57
+ )
58
+
59
+ self.cmd_start.add_argument("-s", "--step", required=True)
60
+ self.cmd_start.add_argument("-c", "--callback", default=basic_callback)
61
+ self.cmd_start.add_argument("-i", "--initial-context")
62
+ self.cmd_start.add_argument(
63
+ "-o", "--output-context", default=False, action="store_true"
64
+ )
65
+ self.cmd_start.add_argument("-p", "--path", default=settings.INITIAL_PATH)
66
+ self.cmd_start.add_argument(
67
+ "-m",
68
+ "--mode",
69
+ default=TypeExecution.SEQUENTIAL,
70
+ choices=[TypeExecution.SEQUENTIAL, TypeExecution.BACKGROUND],
71
+ )
72
+
73
+ self.cmd_start.set_defaults(exec=StartCommand)
74
+
75
+ def command(self):
76
+ message_icon = ":game_die:"
77
+ message_error = "[bold red]Error:[/bold red]"
78
+
79
+ try:
80
+ arguments = self.parser.parse_args()
81
+ if hasattr(arguments, "exec"):
82
+ arguments.exec(parser=self.parser, arguments=arguments)
83
+ else:
84
+ print(__description__)
85
+ except MissingActionDecorator as err:
86
+ print(message_icon, message_error, err)
87
+
88
+ except ExecutionModeNotExist as err:
89
+ print(message_icon, message_error, err)
90
+
91
+ except StepMissingInit as err:
92
+ print(message_icon, message_error, err)
93
+
94
+ except ModuleNotFound as err:
95
+ print(message_icon, message_error, err)
96
+
97
+ except Exception as err:
98
+ print(message_icon, message_error, MESSAGE_UNKNOWN_ERROR)
99
+ logger.error(err)
@@ -0,0 +1,8 @@
1
+ """Validators __init__ module."""
2
+
3
+ from dotflow.cli.validators.start import StartValidator
4
+
5
+
6
+ __all__ = [
7
+ "StartValidator"
8
+ ]
@@ -0,0 +1,16 @@
1
+ """Start validator module"""
2
+
3
+ from typing import Optional
4
+
5
+ from pydantic import BaseModel, Field # type: ignore
6
+
7
+ from dotflow.settings import Settings as settings
8
+
9
+
10
+ class StartValidator(BaseModel):
11
+
12
+ step: str
13
+ callable: Optional[str] = Field(default=None)
14
+ initial_context: Optional[str] = Field(default=None)
15
+ output: Optional[bool] = Field(default=True)
16
+ path: Optional[str] = Field(default=settings.INITIAL_PATH)
@@ -0,0 +1,18 @@
1
+ """Config module"""
2
+
3
+ from dotflow.core.utils import make_dir
4
+ from dotflow.settings import Settings as settings
5
+
6
+
7
+ class Config:
8
+
9
+ def __init__(
10
+ self,
11
+ path: str = settings.INITIAL_PATH,
12
+ output: bool = False
13
+ ) -> None:
14
+ self.path = path
15
+ self.log_path = f"{path}/{settings.LOG_FILE}"
16
+ self.output = output
17
+
18
+ make_dir(path=self.path, show_log=True)
@@ -0,0 +1,37 @@
1
+ """DotFlow"""
2
+
3
+ from uuid import uuid4
4
+ from functools import partial
5
+
6
+ from dotflow.core.config import Config
7
+ from dotflow.core.workflow import Workflow
8
+ from dotflow.core.task import TaskBuilder
9
+
10
+
11
+ class DotFlow:
12
+
13
+ def __init__(
14
+ self,
15
+ config: Config = Config()
16
+ ) -> None:
17
+ self.workflow_id = uuid4()
18
+
19
+ self.task = TaskBuilder(
20
+ config=config,
21
+ workflow_id=self.workflow_id
22
+ )
23
+
24
+ self.start = partial(
25
+ Workflow,
26
+ tasks=self.task.queu,
27
+ id=self.workflow_id
28
+ )
29
+
30
+ def result_task(self):
31
+ return self.task.queu
32
+
33
+ def result_context(self):
34
+ return [task.current_context for task in self.task.queu]
35
+
36
+ def result_storage(self):
37
+ return [task.current_context.storage for task in self.task.queu]
@@ -1,8 +1,10 @@
1
1
  """Exception module"""
2
2
 
3
+ MESSAGE_UNKNOWN_ERROR = "Unknown error, please check logs for more information."
3
4
  MESSAGE_MISSING_STEP_DECORATOR = "A step function necessarily needs an 'action' decorator to circulate in the workflow. For more implementation details, access the documentation: https://dotflow-io.github.io/dotflow/nav/getting-started/#3-task-function."
4
5
  MESSAGE_EXECUTION_NOT_EXIST = "The execution mode does not exist. Allowed parameter is 'sequential' and 'background'."
5
6
  MESSAGE_STEP_MISSING_INIT = "The '{name}' class assigned to the step is incomplete. It is extremely important that there is an '__init__' function."
7
+ MESSAGE_MODULE_NOT_FOUND = "Problem importing the python module, it probably doesn't exist or is wrong."
6
8
 
7
9
 
8
10
  class MissingActionDecorator(Exception):
@@ -28,3 +30,11 @@ class StepMissingInit(Exception):
28
30
  super(StepMissingInit, self).__init__(
29
31
  MESSAGE_STEP_MISSING_INIT.format(name=name)
30
32
  )
33
+
34
+
35
+ class ModuleNotFound(Exception):
36
+
37
+ def __init__(self):
38
+ super(ModuleNotFound, self).__init__(
39
+ MESSAGE_MODULE_NOT_FOUND
40
+ )
@@ -7,7 +7,7 @@ from dotflow.core.action import Action
7
7
  from dotflow.core.context import Context
8
8
  from dotflow.core.exception import StepMissingInit
9
9
  from dotflow.core.task import Task
10
- from dotflow.core.models import Status
10
+ from dotflow.core.models import TaskStatus
11
11
 
12
12
  from dotflow.core.decorators import time
13
13
 
@@ -20,9 +20,9 @@ class Execution:
20
20
  previous_context: Context
21
21
  ) -> None:
22
22
  self.task = task
23
- self.task._set_status(Status.IN_PROGRESS)
23
+ self.task.status = TaskStatus.IN_PROGRESS
24
24
  self.task._set_workflow_id(workflow_id)
25
- self.task._set_previous_context(previous_context)
25
+ self.task.previous_context = previous_context
26
26
 
27
27
  self._excution()
28
28
 
@@ -55,20 +55,20 @@ class Execution:
55
55
  step_class=current_context.storage
56
56
  )
57
57
 
58
- self.task._set_current_context(current_context)
59
- self.task._set_status(Status.COMPLETED)
58
+ self.task.status = TaskStatus.COMPLETED
59
+ self.task.current_context = current_context
60
60
 
61
61
  except AttributeError as err:
62
62
  if self.task.step.func and hasattr(self.task.step.func, "__name__"):
63
63
  if "'__code__'" in err.args[0].split():
64
64
  err = StepMissingInit(name=self.task.step.func.__name__)
65
65
 
66
- self.task._set_error(err)
67
- self.task._set_status(Status.FAILED)
66
+ self.task.status = TaskStatus.FAILED
67
+ self.task.error = err
68
68
 
69
69
  except Exception as err:
70
- self.task._set_error(err)
71
- self.task._set_status(Status.FAILED)
70
+ self.task.status = TaskStatus.FAILED
71
+ self.task.error = err
72
72
 
73
73
  finally:
74
74
  self.task.callback(content=self.task)
@@ -1,10 +1,10 @@
1
1
  """Types __init__ module."""
2
2
 
3
3
  from dotflow.core.models.execution import TypeExecution
4
- from dotflow.core.models.status import Status
4
+ from dotflow.core.models.status import TaskStatus
5
5
 
6
6
 
7
7
  __all__ = [
8
8
  "TypeExecution",
9
- "Status"
9
+ "TaskStatus"
10
10
  ]
@@ -1,7 +1,7 @@
1
- """Step Status module"""
1
+ """Step Task Status module"""
2
2
 
3
3
 
4
- class Status:
4
+ class TaskStatus:
5
5
 
6
6
  NOT_STARTED = "Not started"
7
7
  IN_PROGRESS = "In progress"
@@ -0,0 +1,8 @@
1
+ """Step Workflow Status module"""
2
+
3
+
4
+ class WorkflowStatus:
5
+
6
+ NEW = "New"
7
+ IN_PROGRESS = "In progress"
8
+ COMPLETED = "Completed"
@@ -0,0 +1,41 @@
1
+ """Task module"""
2
+
3
+ import sys
4
+
5
+ from importlib.util import (
6
+ spec_from_file_location as file_location,
7
+ module_from_spec
8
+ )
9
+
10
+ from typing import Any
11
+
12
+ from dotflow.core.exception import ModuleNotFound
13
+
14
+
15
+ class Module:
16
+
17
+ def __new__(cls, value: Any):
18
+ if isinstance(value, str):
19
+ value = cls.import_module(value)
20
+ return value
21
+
22
+ @classmethod
23
+ def import_module(cls, value: str):
24
+ spec = file_location(value, cls._get_path(value))
25
+ module = module_from_spec(spec)
26
+
27
+ sys.modules[module] = module
28
+ spec.loader.exec_module(module)
29
+
30
+ if hasattr(module, cls._get_name(value)):
31
+ return getattr(module, cls._get_name(value))
32
+
33
+ raise ModuleNotFound()
34
+
35
+ @classmethod
36
+ def _get_name(cls, value: str):
37
+ return value.split(".")[-1:][0]
38
+
39
+ @classmethod
40
+ def _get_path(cls, value: str):
41
+ return f"{'/'.join(value.split('.')[:-1])}.py"