ddeutil-workflow 0.0.9__py3-none-any.whl → 0.0.11__py3-none-any.whl
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/__about__.py +1 -1
- ddeutil/workflow/__init__.py +3 -2
- ddeutil/workflow/api.py +99 -31
- ddeutil/workflow/cli.py +105 -22
- ddeutil/workflow/cron.py +116 -26
- ddeutil/workflow/exceptions.py +8 -5
- ddeutil/workflow/job.py +572 -0
- ddeutil/workflow/log.py +73 -66
- ddeutil/workflow/on.py +10 -4
- ddeutil/workflow/repeat.py +68 -39
- ddeutil/workflow/route.py +194 -44
- ddeutil/workflow/scheduler.py +1020 -229
- ddeutil/workflow/stage.py +27 -23
- ddeutil/workflow/utils.py +145 -9
- ddeutil_workflow-0.0.11.dist-info/METADATA +178 -0
- ddeutil_workflow-0.0.11.dist-info/RECORD +21 -0
- {ddeutil_workflow-0.0.9.dist-info → ddeutil_workflow-0.0.11.dist-info}/WHEEL +1 -1
- ddeutil_workflow-0.0.11.dist-info/entry_points.txt +2 -0
- ddeutil/workflow/loader.py +0 -132
- ddeutil/workflow/pipeline.py +0 -1142
- ddeutil_workflow-0.0.9.dist-info/METADATA +0 -273
- ddeutil_workflow-0.0.9.dist-info/RECORD +0 -22
- ddeutil_workflow-0.0.9.dist-info/entry_points.txt +0 -2
- {ddeutil_workflow-0.0.9.dist-info → ddeutil_workflow-0.0.11.dist-info}/LICENSE +0 -0
- {ddeutil_workflow-0.0.9.dist-info → ddeutil_workflow-0.0.11.dist-info}/top_level.txt +0 -0
ddeutil/workflow/loader.py
DELETED
@@ -1,132 +0,0 @@
|
|
1
|
-
# ------------------------------------------------------------------------------
|
2
|
-
# Copyright (c) 2022 Korawich Anuttra. All rights reserved.
|
3
|
-
# Licensed under the MIT License. See LICENSE in the project root for
|
4
|
-
# license information.
|
5
|
-
# ------------------------------------------------------------------------------
|
6
|
-
from __future__ import annotations
|
7
|
-
|
8
|
-
from collections.abc import Iterator
|
9
|
-
from functools import cached_property
|
10
|
-
from typing import TypeVar
|
11
|
-
|
12
|
-
from ddeutil.core import import_string
|
13
|
-
from ddeutil.io import PathSearch, YamlFlResolve
|
14
|
-
from pydantic import BaseModel
|
15
|
-
|
16
|
-
from .__types import DictData
|
17
|
-
from .utils import ConfParams, config
|
18
|
-
|
19
|
-
AnyModel = TypeVar("AnyModel", bound=BaseModel)
|
20
|
-
AnyModelType = type[AnyModel]
|
21
|
-
|
22
|
-
|
23
|
-
class SimLoad:
|
24
|
-
"""Simple Load Object that will search config data by name.
|
25
|
-
|
26
|
-
:param name: A name of config data that will read by Yaml Loader object.
|
27
|
-
:param params: A Params model object.
|
28
|
-
:param externals: An external parameters
|
29
|
-
|
30
|
-
Noted:
|
31
|
-
The config data should have ``type`` key for engine can know what is
|
32
|
-
config should to do next.
|
33
|
-
"""
|
34
|
-
|
35
|
-
def __init__(
|
36
|
-
self,
|
37
|
-
name: str,
|
38
|
-
params: ConfParams,
|
39
|
-
externals: DictData | None = None,
|
40
|
-
) -> None:
|
41
|
-
self.data: DictData = {}
|
42
|
-
for file in PathSearch(params.engine.paths.conf).files:
|
43
|
-
if any(file.suffix.endswith(s) for s in (".yml", ".yaml")) and (
|
44
|
-
data := YamlFlResolve(file).read().get(name, {})
|
45
|
-
):
|
46
|
-
self.data = data
|
47
|
-
if not self.data:
|
48
|
-
raise ValueError(f"Config {name!r} does not found on conf path")
|
49
|
-
|
50
|
-
# TODO: Validate the version of template data that mean if version of
|
51
|
-
# Template were change it should raise to upgrade package version.
|
52
|
-
# ---
|
53
|
-
# <pipeline-name>:
|
54
|
-
# version: 1
|
55
|
-
# type: pipeline.Pipeline
|
56
|
-
#
|
57
|
-
self.conf_params: ConfParams = params
|
58
|
-
self.externals: DictData = externals or {}
|
59
|
-
self.data.update(self.externals)
|
60
|
-
|
61
|
-
@classmethod
|
62
|
-
def find(
|
63
|
-
cls,
|
64
|
-
obj: object,
|
65
|
-
params: ConfParams,
|
66
|
-
*,
|
67
|
-
include: list[str] | None = None,
|
68
|
-
exclude: list[str] | None = None,
|
69
|
-
) -> Iterator[tuple[str, DictData]]:
|
70
|
-
"""Find all object"""
|
71
|
-
exclude: list[str] = exclude or []
|
72
|
-
for file in PathSearch(params.engine.paths.conf).files:
|
73
|
-
if any(file.suffix.endswith(s) for s in (".yml", ".yaml")) and (
|
74
|
-
values := YamlFlResolve(file).read()
|
75
|
-
):
|
76
|
-
for key, data in values.items():
|
77
|
-
if key in exclude:
|
78
|
-
continue
|
79
|
-
if (
|
80
|
-
(t := data.get("type"))
|
81
|
-
and issubclass(cls.get_type(t, params), obj)
|
82
|
-
and all(i in data for i in (include or data.keys()))
|
83
|
-
):
|
84
|
-
yield key, data
|
85
|
-
|
86
|
-
@classmethod
|
87
|
-
def get_type(cls, t: str, params: ConfParams) -> AnyModelType:
|
88
|
-
try:
|
89
|
-
# NOTE: Auto adding module prefix if it does not set
|
90
|
-
return import_string(f"ddeutil.workflow.{t}")
|
91
|
-
except ModuleNotFoundError:
|
92
|
-
for registry in params.engine.registry:
|
93
|
-
try:
|
94
|
-
return import_string(f"{registry}.{t}")
|
95
|
-
except ModuleNotFoundError:
|
96
|
-
continue
|
97
|
-
return import_string(f"{t}")
|
98
|
-
|
99
|
-
@cached_property
|
100
|
-
def type(self) -> AnyModelType:
|
101
|
-
"""Return object of string type which implement on any registry. The
|
102
|
-
object type
|
103
|
-
"""
|
104
|
-
if not (_typ := self.data.get("type")):
|
105
|
-
raise ValueError(
|
106
|
-
f"the 'type' value: {_typ} does not exists in config data."
|
107
|
-
)
|
108
|
-
return self.get_type(_typ, self.conf_params)
|
109
|
-
|
110
|
-
|
111
|
-
class Loader(SimLoad):
|
112
|
-
"""Loader Object that get the config `yaml` file from current path.
|
113
|
-
|
114
|
-
:param name: A name of config data that will read by Yaml Loader object.
|
115
|
-
:param externals: An external parameters
|
116
|
-
"""
|
117
|
-
|
118
|
-
@classmethod
|
119
|
-
def find(
|
120
|
-
cls,
|
121
|
-
obj,
|
122
|
-
*,
|
123
|
-
include: list[str] | None = None,
|
124
|
-
exclude: list[str] | None = None,
|
125
|
-
**kwargs,
|
126
|
-
) -> DictData:
|
127
|
-
return super().find(
|
128
|
-
obj=obj, params=config(), include=include, exclude=exclude
|
129
|
-
)
|
130
|
-
|
131
|
-
def __init__(self, name: str, externals: DictData) -> None:
|
132
|
-
super().__init__(name, config(), externals)
|