ddeutil-workflow 0.0.44__tar.gz → 0.0.45__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.
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/PKG-INFO +6 -7
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/README.md +5 -5
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/pyproject.toml +0 -1
- ddeutil_workflow-0.0.45/src/ddeutil/workflow/__about__.py +1 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/conf.py +33 -27
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/logs.py +44 -5
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/result.py +10 -1
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/reusables.py +1 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/workflow.py +5 -2
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil_workflow.egg-info/PKG-INFO +6 -7
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil_workflow.egg-info/requires.txt +0 -1
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_workflow.py +51 -0
- ddeutil_workflow-0.0.44/src/ddeutil/workflow/__about__.py +0 -1
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/LICENSE +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/setup.cfg +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/__cron.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/__init__.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/__types.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/api/__init__.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/api/api.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/api/log.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/api/repeat.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/api/routes/__init__.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/api/routes/job.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/api/routes/logs.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/api/routes/schedules.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/api/routes/workflows.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/cron.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/exceptions.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/job.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/params.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/scheduler.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/stages.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/utils.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil_workflow.egg-info/SOURCES.txt +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil_workflow.egg-info/dependency_links.txt +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil_workflow.egg-info/top_level.txt +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test__cron.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test__regex.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_conf.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_cron_on.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_job.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_job_exec.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_job_exec_strategy.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_job_strategy.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_logs_audit.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_logs_trace.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_params.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_release.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_release_queue.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_result.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_reusables_call_tag.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_reusables_template.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_reusables_template_filter.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_schedule.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_schedule_pending.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_schedule_tasks.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_schedule_workflow.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_scheduler_control.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_stage.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_stage_handler_exec.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_utils.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_workflow_exec.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_workflow_exec_job.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_workflow_exec_poke.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_workflow_exec_release.py +0 -0
- {ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/tests/test_workflow_task.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ddeutil-workflow
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.45
|
4
4
|
Summary: Lightweight workflow orchestration
|
5
5
|
Author-email: ddeutils <korawich.anu@gmail.com>
|
6
6
|
License: MIT
|
@@ -30,7 +30,6 @@ Requires-Dist: schedule<2.0.0,==1.2.2
|
|
30
30
|
Provides-Extra: all
|
31
31
|
Requires-Dist: fastapi<1.0.0,>=0.115.0; extra == "all"
|
32
32
|
Requires-Dist: httpx; extra == "all"
|
33
|
-
Requires-Dist: ujson; extra == "all"
|
34
33
|
Requires-Dist: aiofiles; extra == "all"
|
35
34
|
Requires-Dist: aiohttp; extra == "all"
|
36
35
|
Provides-Extra: api
|
@@ -71,9 +70,9 @@ configuration. It called **Metadata Driven Data Workflow**.
|
|
71
70
|
|
72
71
|
**:pushpin: <u>Rules of This Workflow engine</u>**:
|
73
72
|
|
74
|
-
1. The Minimum frequency unit of scheduling is **1 Minute** 🕘
|
73
|
+
1. The Minimum frequency unit of built-in scheduling is **1 Minute** 🕘
|
75
74
|
2. **Can not** re-run only failed stage and its pending downstream ↩️
|
76
|
-
3. All parallel tasks inside workflow engine use **Multi-Threading**
|
75
|
+
3. All parallel tasks inside workflow core engine use **Multi-Threading** pool
|
77
76
|
(Python 3.13 unlock GIL 🐍🔓)
|
78
77
|
|
79
78
|
---
|
@@ -266,11 +265,11 @@ it will use default value and do not raise any error to you.
|
|
266
265
|
| **ROOT_PATH** | Core | `.` | No | The root path of the workflow application. |
|
267
266
|
| **REGISTRY_CALLER** | Core | `.` | Yes | List of importable string for the call stage. |
|
268
267
|
| **REGISTRY_FILTER** | Core | `ddeutil.workflow.templates` | Yes | List of importable string for the filter template. |
|
269
|
-
| **CONF_PATH** | Core | `conf` |
|
268
|
+
| **CONF_PATH** | Core | `conf` | Yes | The config path that keep all template `.yaml` files. |
|
270
269
|
| **TIMEZONE** | Core | `Asia/Bangkok` | No | A Timezone string value that will pass to `ZoneInfo` object. |
|
271
|
-
| **STAGE_DEFAULT_ID** | Core | `true` |
|
270
|
+
| **STAGE_DEFAULT_ID** | Core | `true` | Yes | A flag that enable default stage ID that use for catch an execution output. |
|
272
271
|
| **STAGE_RAISE_ERROR** | Core | `false` | Yes | A flag that all stage raise StageException from stage execution. |
|
273
|
-
| **JOB_DEFAULT_ID** | Core | `false` |
|
272
|
+
| **JOB_DEFAULT_ID** | Core | `false` | Yes | A flag that enable default job ID that use for catch an execution output. The ID that use will be sequence number. |
|
274
273
|
| **JOB_RAISE_ERROR** | Core | `true` | Yes | A flag that all job raise JobException from job strategy execution. |
|
275
274
|
| **MAX_CRON_PER_WORKFLOW** | Core | `5` | No | |
|
276
275
|
| **MAX_QUEUE_COMPLETE_HIST** | Core | `16` | No | |
|
@@ -27,9 +27,9 @@ configuration. It called **Metadata Driven Data Workflow**.
|
|
27
27
|
|
28
28
|
**:pushpin: <u>Rules of This Workflow engine</u>**:
|
29
29
|
|
30
|
-
1. The Minimum frequency unit of scheduling is **1 Minute** 🕘
|
30
|
+
1. The Minimum frequency unit of built-in scheduling is **1 Minute** 🕘
|
31
31
|
2. **Can not** re-run only failed stage and its pending downstream ↩️
|
32
|
-
3. All parallel tasks inside workflow engine use **Multi-Threading**
|
32
|
+
3. All parallel tasks inside workflow core engine use **Multi-Threading** pool
|
33
33
|
(Python 3.13 unlock GIL 🐍🔓)
|
34
34
|
|
35
35
|
---
|
@@ -222,11 +222,11 @@ it will use default value and do not raise any error to you.
|
|
222
222
|
| **ROOT_PATH** | Core | `.` | No | The root path of the workflow application. |
|
223
223
|
| **REGISTRY_CALLER** | Core | `.` | Yes | List of importable string for the call stage. |
|
224
224
|
| **REGISTRY_FILTER** | Core | `ddeutil.workflow.templates` | Yes | List of importable string for the filter template. |
|
225
|
-
| **CONF_PATH** | Core | `conf` |
|
225
|
+
| **CONF_PATH** | Core | `conf` | Yes | The config path that keep all template `.yaml` files. |
|
226
226
|
| **TIMEZONE** | Core | `Asia/Bangkok` | No | A Timezone string value that will pass to `ZoneInfo` object. |
|
227
|
-
| **STAGE_DEFAULT_ID** | Core | `true` |
|
227
|
+
| **STAGE_DEFAULT_ID** | Core | `true` | Yes | A flag that enable default stage ID that use for catch an execution output. |
|
228
228
|
| **STAGE_RAISE_ERROR** | Core | `false` | Yes | A flag that all stage raise StageException from stage execution. |
|
229
|
-
| **JOB_DEFAULT_ID** | Core | `false` |
|
229
|
+
| **JOB_DEFAULT_ID** | Core | `false` | Yes | A flag that enable default job ID that use for catch an execution output. The ID that use will be sequence number. |
|
230
230
|
| **JOB_RAISE_ERROR** | Core | `true` | Yes | A flag that all job raise JobException from job strategy execution. |
|
231
231
|
| **MAX_CRON_PER_WORKFLOW** | Core | `5` | No | |
|
232
232
|
| **MAX_QUEUE_COMPLETE_HIST** | Core | `16` | No | |
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__: str = "0.0.45"
|
@@ -341,6 +341,32 @@ class SimLoad:
|
|
341
341
|
)
|
342
342
|
|
343
343
|
|
344
|
+
config: Config = Config()
|
345
|
+
api_config: APIConfig = APIConfig()
|
346
|
+
|
347
|
+
|
348
|
+
def dynamic(
|
349
|
+
key: Optional[str] = None,
|
350
|
+
*,
|
351
|
+
f: Optional[T] = None,
|
352
|
+
extras: Optional[DictData] = None,
|
353
|
+
) -> Optional[T]:
|
354
|
+
"""Dynamic get config if extra value was passed at run-time.
|
355
|
+
|
356
|
+
:param key: (str) A config key that get from Config object.
|
357
|
+
:param f: An inner config function scope.
|
358
|
+
:param extras: An extra values that pass at run-time.
|
359
|
+
"""
|
360
|
+
rsx: Optional[T] = extras[key] if extras and key in extras else None
|
361
|
+
rs: Optional[T] = f or getattr(config, key, None)
|
362
|
+
if rsx is not None and not isinstance(rsx, type(rs)):
|
363
|
+
raise TypeError(
|
364
|
+
f"Type of config {key!r} from extras: {rsx!r} does not valid "
|
365
|
+
f"as config {type(rs)}."
|
366
|
+
)
|
367
|
+
return rsx or rs
|
368
|
+
|
369
|
+
|
344
370
|
class Loader(SimLoad):
|
345
371
|
"""Loader Object that get the config `yaml` file from current path.
|
346
372
|
|
@@ -355,6 +381,7 @@ class Loader(SimLoad):
|
|
355
381
|
*,
|
356
382
|
included: list[str] | None = None,
|
357
383
|
excluded: list[str] | None = None,
|
384
|
+
path: Path | None = None,
|
358
385
|
**kwargs,
|
359
386
|
) -> Iterator[tuple[str, DictData]]:
|
360
387
|
"""Override the find class method from the Simple Loader object.
|
@@ -362,44 +389,23 @@ class Loader(SimLoad):
|
|
362
389
|
:param obj: An object that want to validate matching before return.
|
363
390
|
:param included:
|
364
391
|
:param excluded:
|
392
|
+
:param path:
|
365
393
|
|
366
394
|
:rtype: Iterator[tuple[str, DictData]]
|
367
395
|
"""
|
368
396
|
return super().finds(
|
369
397
|
obj=obj,
|
370
|
-
conf_path=config.conf_path,
|
398
|
+
conf_path=(path or config.conf_path),
|
371
399
|
included=included,
|
372
400
|
excluded=excluded,
|
373
401
|
)
|
374
402
|
|
375
403
|
def __init__(self, name: str, externals: DictData) -> None:
|
376
|
-
super().__init__(
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
api_config: APIConfig = APIConfig()
|
381
|
-
|
382
|
-
|
383
|
-
def dynamic(
|
384
|
-
key: Optional[str] = None,
|
385
|
-
*,
|
386
|
-
f: Optional[T] = None,
|
387
|
-
extras: Optional[DictData] = None,
|
388
|
-
) -> Optional[T]:
|
389
|
-
"""Dynamic get config if extra value was passed at run-time.
|
390
|
-
|
391
|
-
:param key: (str) A config key that get from Config object.
|
392
|
-
:param f: An inner config function scope.
|
393
|
-
:param extras: An extra values that pass at run-time.
|
394
|
-
"""
|
395
|
-
rsx: Optional[T] = extras[key] if extras and key in extras else None
|
396
|
-
rs: Optional[T] = f or getattr(config, key, None)
|
397
|
-
if rsx is not None and not isinstance(rsx, type(rs)):
|
398
|
-
raise TypeError(
|
399
|
-
f"Type of config {key!r} from extras: {rsx!r} does not valid "
|
400
|
-
f"as config {type(rs)}."
|
404
|
+
super().__init__(
|
405
|
+
name,
|
406
|
+
conf_path=dynamic("conf_path", extras=externals),
|
407
|
+
externals=externals,
|
401
408
|
)
|
402
|
-
return rsx or rs
|
403
409
|
|
404
410
|
|
405
411
|
@lru_cache
|
@@ -80,6 +80,8 @@ class TraceMeda(BaseModel): # pragma: no cov
|
|
80
80
|
|
81
81
|
|
82
82
|
class TraceData(BaseModel): # pragma: no cov
|
83
|
+
"""Trace Data model for keeping data for any Trace models."""
|
84
|
+
|
83
85
|
stdout: str = Field(description="A standard output trace data.")
|
84
86
|
stderr: str = Field(description="A standard error trace data.")
|
85
87
|
meta: list[TraceMeda] = Field(
|
@@ -92,6 +94,12 @@ class TraceData(BaseModel): # pragma: no cov
|
|
92
94
|
|
93
95
|
@classmethod
|
94
96
|
def from_path(cls, file: Path) -> Self:
|
97
|
+
"""Construct this trace data model with a trace path.
|
98
|
+
|
99
|
+
:param file: (Path) A trace path.
|
100
|
+
|
101
|
+
:rtype: Self
|
102
|
+
"""
|
95
103
|
data: DictStr = {"stdout": "", "stderr": "", "meta": []}
|
96
104
|
|
97
105
|
if (file / "stdout.txt").exists():
|
@@ -207,27 +215,52 @@ class BaseTraceLog(ABC): # pragma: no cov
|
|
207
215
|
logger.exception(msg, stacklevel=2)
|
208
216
|
|
209
217
|
async def adebug(self, message: str) -> None: # pragma: no cov
|
218
|
+
"""Async write trace log with append mode and logging this message with
|
219
|
+
the DEBUG level.
|
220
|
+
|
221
|
+
:param message: (str) A message that want to log.
|
222
|
+
"""
|
210
223
|
msg: str = self.make_message(message)
|
211
224
|
if config.debug:
|
212
225
|
await self.awriter(msg)
|
213
226
|
logger.info(msg, stacklevel=2)
|
214
227
|
|
215
228
|
async def ainfo(self, message: str) -> None: # pragma: no cov
|
229
|
+
"""Async write trace log with append mode and logging this message with
|
230
|
+
the INFO level.
|
231
|
+
|
232
|
+
:param message: (str) A message that want to log.
|
233
|
+
"""
|
216
234
|
msg: str = self.make_message(message)
|
217
235
|
await self.awriter(msg)
|
218
236
|
logger.info(msg, stacklevel=2)
|
219
237
|
|
220
238
|
async def awarning(self, message: str) -> None: # pragma: no cov
|
239
|
+
"""Async write trace log with append mode and logging this message with
|
240
|
+
the WARNING level.
|
241
|
+
|
242
|
+
:param message: (str) A message that want to log.
|
243
|
+
"""
|
221
244
|
msg: str = self.make_message(message)
|
222
245
|
await self.awriter(msg)
|
223
246
|
logger.warning(msg, stacklevel=2)
|
224
247
|
|
225
248
|
async def aerror(self, message: str) -> None: # pragma: no cov
|
249
|
+
"""Async write trace log with append mode and logging this message with
|
250
|
+
the ERROR level.
|
251
|
+
|
252
|
+
:param message: (str) A message that want to log.
|
253
|
+
"""
|
226
254
|
msg: str = self.make_message(message)
|
227
255
|
await self.awriter(msg, is_err=True)
|
228
256
|
logger.error(msg, stacklevel=2)
|
229
257
|
|
230
258
|
async def aexception(self, message: str) -> None: # pragma: no cov
|
259
|
+
"""Async write trace log with append mode and logging this message with
|
260
|
+
the EXCEPTION level.
|
261
|
+
|
262
|
+
:param message: (str) A message that want to log.
|
263
|
+
"""
|
231
264
|
msg: str = self.make_message(message)
|
232
265
|
await self.awriter(msg, is_err=True)
|
233
266
|
logger.exception(msg, stacklevel=2)
|
@@ -237,23 +270,29 @@ class FileTraceLog(BaseTraceLog): # pragma: no cov
|
|
237
270
|
"""Trace Log object that write file to the local storage."""
|
238
271
|
|
239
272
|
@classmethod
|
240
|
-
def find_logs(
|
273
|
+
def find_logs(
|
274
|
+
cls, path: Path | None = None
|
275
|
+
) -> Iterator[TraceData]: # pragma: no cov
|
276
|
+
"""Find trace logs."""
|
241
277
|
for file in sorted(
|
242
|
-
config.log_path.glob("./run_id=*"),
|
278
|
+
(path or config.log_path).glob("./run_id=*"),
|
243
279
|
key=lambda f: f.lstat().st_mtime,
|
244
280
|
):
|
245
281
|
yield TraceData.from_path(file)
|
246
282
|
|
247
283
|
@classmethod
|
248
284
|
def find_log_with_id(
|
249
|
-
cls, run_id: str, force_raise: bool = True
|
285
|
+
cls, run_id: str, force_raise: bool = True, *, path: Path | None = None
|
250
286
|
) -> TraceData:
|
251
|
-
|
287
|
+
"""Find trace log with an input specific run ID."""
|
288
|
+
base_path: Path = path or config.log_path
|
289
|
+
file: Path = base_path / f"run_id={run_id}"
|
252
290
|
if file.exists():
|
253
291
|
return TraceData.from_path(file)
|
254
292
|
elif force_raise:
|
255
293
|
raise FileNotFoundError(
|
256
|
-
f"Trace log on path
|
294
|
+
f"Trace log on path {base_path}, does not found trace "
|
295
|
+
f"'run_id={run_id}'."
|
257
296
|
)
|
258
297
|
return {}
|
259
298
|
|
@@ -72,6 +72,7 @@ class Result:
|
|
72
72
|
ts: datetime = field(default_factory=get_dt_tznow, compare=False)
|
73
73
|
|
74
74
|
trace: Optional[TraceLog] = field(default=None, compare=False, repr=False)
|
75
|
+
extras: DictData = field(default_factory=dict)
|
75
76
|
|
76
77
|
@classmethod
|
77
78
|
def construct_with_rs_or_id(
|
@@ -80,6 +81,8 @@ class Result:
|
|
80
81
|
run_id: str | None = None,
|
81
82
|
parent_run_id: str | None = None,
|
82
83
|
id_logic: str | None = None,
|
84
|
+
*,
|
85
|
+
extras: DictData | None = None,
|
83
86
|
) -> Self:
|
84
87
|
"""Create the Result object or set parent running id if passing Result
|
85
88
|
object.
|
@@ -88,16 +91,22 @@ class Result:
|
|
88
91
|
:param run_id:
|
89
92
|
:param parent_run_id:
|
90
93
|
:param id_logic:
|
94
|
+
:param extras:
|
91
95
|
|
92
96
|
:rtype: Self
|
93
97
|
"""
|
94
98
|
if result is None:
|
95
|
-
|
99
|
+
return cls(
|
96
100
|
run_id=(run_id or gen_id(id_logic or "", unique=True)),
|
97
101
|
parent_run_id=parent_run_id,
|
102
|
+
extras=(extras or {}),
|
98
103
|
)
|
99
104
|
elif parent_run_id:
|
100
105
|
result.set_parent_run_id(parent_run_id)
|
106
|
+
|
107
|
+
if extras is not None:
|
108
|
+
result.extras.update(extras)
|
109
|
+
|
101
110
|
return result
|
102
111
|
|
103
112
|
@model_validator(mode="after")
|
@@ -314,7 +314,8 @@ class Workflow(BaseModel):
|
|
314
314
|
|
315
315
|
loader_data: DictData = copy.deepcopy(loader.data)
|
316
316
|
loader_data["name"] = name.replace(" ", "_")
|
317
|
-
|
317
|
+
|
318
|
+
if extras:
|
318
319
|
loader_data["extras"] = extras
|
319
320
|
|
320
321
|
cls.__bypass_on__(loader_data, path=loader.conf_path, extras=extras)
|
@@ -325,6 +326,7 @@ class Workflow(BaseModel):
|
|
325
326
|
cls,
|
326
327
|
name: str,
|
327
328
|
path: Path,
|
329
|
+
*,
|
328
330
|
extras: DictData | None = None,
|
329
331
|
) -> Self:
|
330
332
|
"""Create Workflow instance from the specific path. The loader object
|
@@ -349,7 +351,8 @@ class Workflow(BaseModel):
|
|
349
351
|
|
350
352
|
loader_data: DictData = copy.deepcopy(loader.data)
|
351
353
|
loader_data["name"] = name.replace(" ", "_")
|
352
|
-
|
354
|
+
|
355
|
+
if extras:
|
353
356
|
loader_data["extras"] = extras
|
354
357
|
|
355
358
|
cls.__bypass_on__(loader_data, path=path, extras=extras)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ddeutil-workflow
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.45
|
4
4
|
Summary: Lightweight workflow orchestration
|
5
5
|
Author-email: ddeutils <korawich.anu@gmail.com>
|
6
6
|
License: MIT
|
@@ -30,7 +30,6 @@ Requires-Dist: schedule<2.0.0,==1.2.2
|
|
30
30
|
Provides-Extra: all
|
31
31
|
Requires-Dist: fastapi<1.0.0,>=0.115.0; extra == "all"
|
32
32
|
Requires-Dist: httpx; extra == "all"
|
33
|
-
Requires-Dist: ujson; extra == "all"
|
34
33
|
Requires-Dist: aiofiles; extra == "all"
|
35
34
|
Requires-Dist: aiohttp; extra == "all"
|
36
35
|
Provides-Extra: api
|
@@ -71,9 +70,9 @@ configuration. It called **Metadata Driven Data Workflow**.
|
|
71
70
|
|
72
71
|
**:pushpin: <u>Rules of This Workflow engine</u>**:
|
73
72
|
|
74
|
-
1. The Minimum frequency unit of scheduling is **1 Minute** 🕘
|
73
|
+
1. The Minimum frequency unit of built-in scheduling is **1 Minute** 🕘
|
75
74
|
2. **Can not** re-run only failed stage and its pending downstream ↩️
|
76
|
-
3. All parallel tasks inside workflow engine use **Multi-Threading**
|
75
|
+
3. All parallel tasks inside workflow core engine use **Multi-Threading** pool
|
77
76
|
(Python 3.13 unlock GIL 🐍🔓)
|
78
77
|
|
79
78
|
---
|
@@ -266,11 +265,11 @@ it will use default value and do not raise any error to you.
|
|
266
265
|
| **ROOT_PATH** | Core | `.` | No | The root path of the workflow application. |
|
267
266
|
| **REGISTRY_CALLER** | Core | `.` | Yes | List of importable string for the call stage. |
|
268
267
|
| **REGISTRY_FILTER** | Core | `ddeutil.workflow.templates` | Yes | List of importable string for the filter template. |
|
269
|
-
| **CONF_PATH** | Core | `conf` |
|
268
|
+
| **CONF_PATH** | Core | `conf` | Yes | The config path that keep all template `.yaml` files. |
|
270
269
|
| **TIMEZONE** | Core | `Asia/Bangkok` | No | A Timezone string value that will pass to `ZoneInfo` object. |
|
271
|
-
| **STAGE_DEFAULT_ID** | Core | `true` |
|
270
|
+
| **STAGE_DEFAULT_ID** | Core | `true` | Yes | A flag that enable default stage ID that use for catch an execution output. |
|
272
271
|
| **STAGE_RAISE_ERROR** | Core | `false` | Yes | A flag that all stage raise StageException from stage execution. |
|
273
|
-
| **JOB_DEFAULT_ID** | Core | `false` |
|
272
|
+
| **JOB_DEFAULT_ID** | Core | `false` | Yes | A flag that enable default job ID that use for catch an execution output. The ID that use will be sequence number. |
|
274
273
|
| **JOB_RAISE_ERROR** | Core | `true` | Yes | A flag that all job raise JobException from job strategy execution. |
|
275
274
|
| **MAX_CRON_PER_WORKFLOW** | Core | `5` | No | |
|
276
275
|
| **MAX_QUEUE_COMPLETE_HIST** | Core | `16` | No | |
|
@@ -1,3 +1,6 @@
|
|
1
|
+
import shutil
|
2
|
+
from pathlib import Path
|
3
|
+
|
1
4
|
import pytest
|
2
5
|
from ddeutil.workflow import Workflow
|
3
6
|
from ddeutil.workflow.exceptions import WorkflowException
|
@@ -151,6 +154,54 @@ def test_workflow_from_path(test_path):
|
|
151
154
|
assert rs.context == {}
|
152
155
|
|
153
156
|
|
157
|
+
def test_workflow_from_loader_override(test_path):
|
158
|
+
conf_path: Path = test_path / "mock_conf"
|
159
|
+
conf_path.mkdir(exist_ok=True)
|
160
|
+
(conf_path / "demo").mkdir(exist_ok=True)
|
161
|
+
|
162
|
+
with dump_yaml_context(
|
163
|
+
conf_path / "demo/01_99_wf_test_override_config.yml",
|
164
|
+
data="""
|
165
|
+
tmp-wf-override-conf:
|
166
|
+
type: Workflow
|
167
|
+
param: {name: str}
|
168
|
+
jobs:
|
169
|
+
first-job:
|
170
|
+
stages:
|
171
|
+
- name: "Hello"
|
172
|
+
echo: "Hello ${{ params.name }}"
|
173
|
+
|
174
|
+
tmp-wf-override-conf-trigger:
|
175
|
+
type: Workflow
|
176
|
+
params: {name: str}
|
177
|
+
jobs:
|
178
|
+
trigger-job:
|
179
|
+
stages:
|
180
|
+
- name: "Trigger override"
|
181
|
+
id: trigger-stage
|
182
|
+
trigger: tmp-wf-override-conf
|
183
|
+
params:
|
184
|
+
name: ${{ params.name }}
|
185
|
+
""",
|
186
|
+
):
|
187
|
+
workflow = Workflow.from_conf(
|
188
|
+
name="tmp-wf-override-conf", extras={"conf_path": conf_path}
|
189
|
+
)
|
190
|
+
rs: Result = workflow.execute(params={"name": "foo"})
|
191
|
+
print(rs.context)
|
192
|
+
|
193
|
+
workflow = Workflow.from_conf(
|
194
|
+
name="tmp-wf-override-conf-trigger", extras={"conf_path": conf_path}
|
195
|
+
)
|
196
|
+
stage = workflow.job(name="trigger-job").stage("trigger-stage")
|
197
|
+
assert stage.extras == {"conf_path": conf_path}
|
198
|
+
|
199
|
+
rs: Result = workflow.execute(params={"name": "bar"})
|
200
|
+
print(rs.context)
|
201
|
+
|
202
|
+
shutil.rmtree(conf_path)
|
203
|
+
|
204
|
+
|
154
205
|
def test_workflow_from_loader_raise(test_path):
|
155
206
|
test_file = test_path / "conf/demo/01_01_wf_run_raise.yml"
|
156
207
|
|
@@ -1 +0,0 @@
|
|
1
|
-
__version__: str = "0.0.44"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/api/routes/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/api/routes/schedules.py
RENAMED
File without changes
|
{ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil/workflow/api/routes/workflows.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil_workflow.egg-info/SOURCES.txt
RENAMED
File without changes
|
File without changes
|
{ddeutil_workflow-0.0.44 → ddeutil_workflow-0.0.45}/src/ddeutil_workflow.egg-info/top_level.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|