highway-dsl 1.0.5__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Farseed Ashouri
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.4
2
+ Name: highway_dsl
3
+ Version: 1.0.5
4
+ Summary: A stable domain specific language (DSL) for defining and managing data processing pipelines and workflow engines.
5
+ Author-email: Farseed Ashouri <farseed.ashouri@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/rodmena-limited/highway_dsl
8
+ Project-URL: Issues, https://github.com/rodmena-limited/highway_dsl/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: pydantic>=2.12.3
16
+ Requires-Dist: pyyaml>=6.0
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
19
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
20
+ Requires-Dist: types-PyYAML>=6.0.0; extra == "dev"
21
+ Requires-Dist: pytest-cov>=2.12.1; extra == "dev"
22
+ Dynamic: license-file
23
+
24
+ # Highway DSL
25
+
26
+ [![PyPI version](https://badge.fury.io/py/highway-dsl.svg)](https://badge.fury.io/py/highway-dsl)
27
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
28
+ [![Stable](https://img.shields.io/badge/Status-Stable-brightgreen)](https://pypi.org/project/highway-dsl/)
29
+ [![Publish to PyPI](https://github.com/rodmena-limited/highway_dsl/actions/workflows/publish.yml/badge.svg)](https://github.com/rodmena-limited/highway_dsl/actions/workflows/publish.yml)
30
+
31
+ **Highway DSL** is a Python-based domain-specific language for defining complex workflows in a clear, concise, and fluent manner. It is part of the larger **Highway** project, an advanced workflow engine capable of running complex DAG-based workflows.
32
+
33
+ ## Version 1.0.3 - Stable Release
34
+
35
+ This is a stable release with important bug fixes and enhancements, including a critical fix for the ForEach operator dependency management issue.
36
+
37
+ ## Features
38
+
39
+ * **Fluent API:** A powerful and intuitive `WorkflowBuilder` for defining workflows programmatically.
40
+ * **Pydantic-based:** All models are built on Pydantic, providing robust data validation, serialization, and documentation.
41
+ * **Rich Operators:** A comprehensive set of operators for handling various workflow scenarios:
42
+ * `Task` - Basic workflow steps
43
+ * `Condition` (if/else) - Conditional branching
44
+ * `Parallel` - Execute multiple branches simultaneously
45
+ * `ForEach` - Iterate over collections with proper dependency management
46
+ * `Wait` - Pause execution for scheduled tasks
47
+ * `While` - Execute loops based on conditions
48
+ * **Fixed ForEach Bug:** Proper encapsulation of loop body tasks to prevent unwanted "grandparent" dependencies from containing parallel operators.
49
+ * **YAML/JSON Interoperability:** Workflows can be defined in Python and exported to YAML or JSON, and vice-versa.
50
+ * **Retry and Timeout Policies:** Built-in error handling and execution time management.
51
+ * **Extensible:** The DSL is designed to be extensible with custom operators and policies.
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ pip install highway-dsl
57
+ ```
58
+
59
+ ## Quick Start
60
+
61
+ Here's a simple example of how to define a workflow using the `WorkflowBuilder`:
62
+
63
+ ```python
64
+ from datetime import timedelta
65
+ from highway_dsl import WorkflowBuilder
66
+
67
+ workflow = (
68
+ WorkflowBuilder("simple_etl")
69
+ .task("extract", "etl.extract_data", result_key="raw_data")
70
+ .task(
71
+ "transform",
72
+ "etl.transform_data",
73
+ args=["{{raw_data}}"],
74
+ result_key="transformed_data",
75
+ )
76
+ .retry(max_retries=3, delay=timedelta(seconds=10))
77
+ .task("load", "etl.load_data", args=["{{transformed_data}}"])
78
+ .timeout(timeout=timedelta(minutes=30))
79
+ .wait("wait_next", timedelta(hours=24))
80
+ .task("cleanup", "etl.cleanup")
81
+ .build()
82
+ )
83
+
84
+ print(workflow.to_yaml())
85
+ ```
86
+
87
+ ## Advanced Usage
88
+
89
+ ### Conditional Logic
90
+
91
+ ```python
92
+ from highway_dsl import WorkflowBuilder, RetryPolicy
93
+ from datetime import timedelta
94
+
95
+ builder = WorkflowBuilder("data_processing_pipeline")
96
+
97
+ builder.task("start", "workflows.tasks.initialize", result_key="init_data")
98
+ builder.task(
99
+ "validate",
100
+ "workflows.tasks.validate_data",
101
+ args=["{{init_data}}"],
102
+ result_key="validated_data",
103
+ )
104
+
105
+ builder.condition(
106
+ "check_quality",
107
+ condition="{{validated_data.quality_score}} > 0.8",
108
+ if_true=lambda b: b.task(
109
+ "high_quality_processing",
110
+ "workflows.tasks.advanced_processing",
111
+ args=["{{validated_data}}"],
112
+ retry_policy=RetryPolicy(max_retries=5, delay=timedelta(seconds=10), backoff_factor=2.0),
113
+ ),
114
+ if_false=lambda b: b.task(
115
+ "standard_processing",
116
+ "workflows.tasks.basic_processing",
117
+ args=["{{validated_data}}"],
118
+ ),
119
+ )
120
+
121
+ workflow = builder.build()
122
+ ```
123
+
124
+ ### While Loops
125
+
126
+ ```python
127
+ from highway_dsl import WorkflowBuilder
128
+
129
+ builder = WorkflowBuilder("qa_rework_workflow")
130
+
131
+ builder.task("start_qa", "workflows.tasks.start_qa", result_key="qa_results")
132
+
133
+ builder.while_loop(
134
+ "qa_rework_loop",
135
+ condition="{{qa_results.status}} == 'failed'",
136
+ loop_body=lambda b: b.task("perform_rework", "workflows.tasks.perform_rework").task(
137
+ "re_run_qa", "workflows.tasks.run_qa", result_key="qa_results"
138
+ ),
139
+ )
140
+
141
+ builder.task("finalize_product", "workflows.tasks.finalize_product", dependencies=["qa_rework_loop"])
142
+
143
+ workflow = builder.build()
144
+ ```
145
+
146
+ ### For-Each Loops with Proper Dependency Management
147
+
148
+ Fixed bug where foreach loops were incorrectly inheriting dependencies from containing parallel operators:
149
+
150
+ ```python
151
+ # This loop now properly encapsulates its internal tasks
152
+ builder.foreach(
153
+ "process_items",
154
+ items="{{data.items}}",
155
+ loop_body=lambda fb: fb.task("process_item", "processor.handle_item", args=["{{item.id}}"])
156
+ # Loop body tasks only have proper dependencies, not unwanted "grandparent" dependencies
157
+ )
158
+ ```
159
+
160
+ ### Retry Policies
161
+
162
+ ```python
163
+ from highway_dsl import RetryPolicy
164
+ from datetime import timedelta
165
+
166
+ builder.task(
167
+ "reliable_task",
168
+ "service.operation",
169
+ retry_policy=RetryPolicy(
170
+ max_retries=5,
171
+ delay=timedelta(seconds=10),
172
+ backoff_factor=2.0
173
+ )
174
+ )
175
+ ```
176
+
177
+ ### Timeout Policies
178
+
179
+ ```python
180
+ from highway_dsl import TimeoutPolicy
181
+ from datetime import timedelta
182
+
183
+ builder.task(
184
+ "timed_task",
185
+ "service.operation",
186
+ timeout_policy=TimeoutPolicy(
187
+ timeout=timedelta(hours=1),
188
+ kill_on_timeout=True
189
+ )
190
+ )
191
+ ```
192
+
193
+ ## What's New in Version 1.0.2
194
+
195
+ ### Bug Fixes
196
+ * **Fixed ForEach Operator Bug**: Resolved issue where foreach loops were incorrectly getting "grandparent" dependencies from containing parallel operators. Loop body tasks are now properly encapsulated and only depend on their parent loop operator and internal chain dependencies.
197
+
198
+ ### Enhancements
199
+ * **Improved Loop Dependency Management**: While loops and ForEach loops now properly encapsulate their internal dependencies without being affected by containing parallel operators.
200
+ * **Better Error Handling**: Enhanced error handling throughout the DSL.
201
+ * **Comprehensive Test Suite**: Added functional tests for all example workflows to ensure consistency.
202
+
203
+ ## Development
204
+
205
+ To set up the development environment:
206
+
207
+ ```bash
208
+ git clone https://github.com/your-username/highway.git
209
+ cd highway
210
+ python -m venv .venv
211
+ source .venv/bin/activate
212
+ pip install -e .[dev]
213
+ ```
214
+
215
+ ### Running Tests
216
+
217
+ ```bash
218
+ pytest
219
+ ```
220
+
221
+ ### Type Checking
222
+
223
+ ```bash
224
+ mypy .
225
+ ```
226
+
227
+ ## License
228
+
229
+ MIT License
@@ -0,0 +1,206 @@
1
+ # Highway DSL
2
+
3
+ [![PyPI version](https://badge.fury.io/py/highway-dsl.svg)](https://badge.fury.io/py/highway-dsl)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Stable](https://img.shields.io/badge/Status-Stable-brightgreen)](https://pypi.org/project/highway-dsl/)
6
+ [![Publish to PyPI](https://github.com/rodmena-limited/highway_dsl/actions/workflows/publish.yml/badge.svg)](https://github.com/rodmena-limited/highway_dsl/actions/workflows/publish.yml)
7
+
8
+ **Highway DSL** is a Python-based domain-specific language for defining complex workflows in a clear, concise, and fluent manner. It is part of the larger **Highway** project, an advanced workflow engine capable of running complex DAG-based workflows.
9
+
10
+ ## Version 1.0.3 - Stable Release
11
+
12
+ This is a stable release with important bug fixes and enhancements, including a critical fix for the ForEach operator dependency management issue.
13
+
14
+ ## Features
15
+
16
+ * **Fluent API:** A powerful and intuitive `WorkflowBuilder` for defining workflows programmatically.
17
+ * **Pydantic-based:** All models are built on Pydantic, providing robust data validation, serialization, and documentation.
18
+ * **Rich Operators:** A comprehensive set of operators for handling various workflow scenarios:
19
+ * `Task` - Basic workflow steps
20
+ * `Condition` (if/else) - Conditional branching
21
+ * `Parallel` - Execute multiple branches simultaneously
22
+ * `ForEach` - Iterate over collections with proper dependency management
23
+ * `Wait` - Pause execution for scheduled tasks
24
+ * `While` - Execute loops based on conditions
25
+ * **Fixed ForEach Bug:** Proper encapsulation of loop body tasks to prevent unwanted "grandparent" dependencies from containing parallel operators.
26
+ * **YAML/JSON Interoperability:** Workflows can be defined in Python and exported to YAML or JSON, and vice-versa.
27
+ * **Retry and Timeout Policies:** Built-in error handling and execution time management.
28
+ * **Extensible:** The DSL is designed to be extensible with custom operators and policies.
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install highway-dsl
34
+ ```
35
+
36
+ ## Quick Start
37
+
38
+ Here's a simple example of how to define a workflow using the `WorkflowBuilder`:
39
+
40
+ ```python
41
+ from datetime import timedelta
42
+ from highway_dsl import WorkflowBuilder
43
+
44
+ workflow = (
45
+ WorkflowBuilder("simple_etl")
46
+ .task("extract", "etl.extract_data", result_key="raw_data")
47
+ .task(
48
+ "transform",
49
+ "etl.transform_data",
50
+ args=["{{raw_data}}"],
51
+ result_key="transformed_data",
52
+ )
53
+ .retry(max_retries=3, delay=timedelta(seconds=10))
54
+ .task("load", "etl.load_data", args=["{{transformed_data}}"])
55
+ .timeout(timeout=timedelta(minutes=30))
56
+ .wait("wait_next", timedelta(hours=24))
57
+ .task("cleanup", "etl.cleanup")
58
+ .build()
59
+ )
60
+
61
+ print(workflow.to_yaml())
62
+ ```
63
+
64
+ ## Advanced Usage
65
+
66
+ ### Conditional Logic
67
+
68
+ ```python
69
+ from highway_dsl import WorkflowBuilder, RetryPolicy
70
+ from datetime import timedelta
71
+
72
+ builder = WorkflowBuilder("data_processing_pipeline")
73
+
74
+ builder.task("start", "workflows.tasks.initialize", result_key="init_data")
75
+ builder.task(
76
+ "validate",
77
+ "workflows.tasks.validate_data",
78
+ args=["{{init_data}}"],
79
+ result_key="validated_data",
80
+ )
81
+
82
+ builder.condition(
83
+ "check_quality",
84
+ condition="{{validated_data.quality_score}} > 0.8",
85
+ if_true=lambda b: b.task(
86
+ "high_quality_processing",
87
+ "workflows.tasks.advanced_processing",
88
+ args=["{{validated_data}}"],
89
+ retry_policy=RetryPolicy(max_retries=5, delay=timedelta(seconds=10), backoff_factor=2.0),
90
+ ),
91
+ if_false=lambda b: b.task(
92
+ "standard_processing",
93
+ "workflows.tasks.basic_processing",
94
+ args=["{{validated_data}}"],
95
+ ),
96
+ )
97
+
98
+ workflow = builder.build()
99
+ ```
100
+
101
+ ### While Loops
102
+
103
+ ```python
104
+ from highway_dsl import WorkflowBuilder
105
+
106
+ builder = WorkflowBuilder("qa_rework_workflow")
107
+
108
+ builder.task("start_qa", "workflows.tasks.start_qa", result_key="qa_results")
109
+
110
+ builder.while_loop(
111
+ "qa_rework_loop",
112
+ condition="{{qa_results.status}} == 'failed'",
113
+ loop_body=lambda b: b.task("perform_rework", "workflows.tasks.perform_rework").task(
114
+ "re_run_qa", "workflows.tasks.run_qa", result_key="qa_results"
115
+ ),
116
+ )
117
+
118
+ builder.task("finalize_product", "workflows.tasks.finalize_product", dependencies=["qa_rework_loop"])
119
+
120
+ workflow = builder.build()
121
+ ```
122
+
123
+ ### For-Each Loops with Proper Dependency Management
124
+
125
+ Fixed bug where foreach loops were incorrectly inheriting dependencies from containing parallel operators:
126
+
127
+ ```python
128
+ # This loop now properly encapsulates its internal tasks
129
+ builder.foreach(
130
+ "process_items",
131
+ items="{{data.items}}",
132
+ loop_body=lambda fb: fb.task("process_item", "processor.handle_item", args=["{{item.id}}"])
133
+ # Loop body tasks only have proper dependencies, not unwanted "grandparent" dependencies
134
+ )
135
+ ```
136
+
137
+ ### Retry Policies
138
+
139
+ ```python
140
+ from highway_dsl import RetryPolicy
141
+ from datetime import timedelta
142
+
143
+ builder.task(
144
+ "reliable_task",
145
+ "service.operation",
146
+ retry_policy=RetryPolicy(
147
+ max_retries=5,
148
+ delay=timedelta(seconds=10),
149
+ backoff_factor=2.0
150
+ )
151
+ )
152
+ ```
153
+
154
+ ### Timeout Policies
155
+
156
+ ```python
157
+ from highway_dsl import TimeoutPolicy
158
+ from datetime import timedelta
159
+
160
+ builder.task(
161
+ "timed_task",
162
+ "service.operation",
163
+ timeout_policy=TimeoutPolicy(
164
+ timeout=timedelta(hours=1),
165
+ kill_on_timeout=True
166
+ )
167
+ )
168
+ ```
169
+
170
+ ## What's New in Version 1.0.2
171
+
172
+ ### Bug Fixes
173
+ * **Fixed ForEach Operator Bug**: Resolved issue where foreach loops were incorrectly getting "grandparent" dependencies from containing parallel operators. Loop body tasks are now properly encapsulated and only depend on their parent loop operator and internal chain dependencies.
174
+
175
+ ### Enhancements
176
+ * **Improved Loop Dependency Management**: While loops and ForEach loops now properly encapsulate their internal dependencies without being affected by containing parallel operators.
177
+ * **Better Error Handling**: Enhanced error handling throughout the DSL.
178
+ * **Comprehensive Test Suite**: Added functional tests for all example workflows to ensure consistency.
179
+
180
+ ## Development
181
+
182
+ To set up the development environment:
183
+
184
+ ```bash
185
+ git clone https://github.com/your-username/highway.git
186
+ cd highway
187
+ python -m venv .venv
188
+ source .venv/bin/activate
189
+ pip install -e .[dev]
190
+ ```
191
+
192
+ ### Running Tests
193
+
194
+ ```bash
195
+ pytest
196
+ ```
197
+
198
+ ### Type Checking
199
+
200
+ ```bash
201
+ mypy .
202
+ ```
203
+
204
+ ## License
205
+
206
+ MIT License
@@ -0,0 +1,28 @@
1
+ from .workflow_dsl import (
2
+ Workflow,
3
+ WorkflowBuilder,
4
+ TaskOperator,
5
+ ConditionOperator,
6
+ ParallelOperator,
7
+ WaitOperator,
8
+ ForEachOperator,
9
+ WhileOperator,
10
+ RetryPolicy,
11
+ TimeoutPolicy,
12
+ OperatorType,
13
+ )
14
+
15
+ __all__ = [
16
+ "Workflow",
17
+ "WorkflowBuilder",
18
+ "BaseOperator",
19
+ "TaskOperator",
20
+ "ConditionOperator",
21
+ "ParallelOperator",
22
+ "WaitOperator",
23
+ "ForEachOperator",
24
+ "WhileOperator",
25
+ "RetryPolicy",
26
+ "TimeoutPolicy",
27
+ "OperatorType",
28
+ ]