ddeutil-workflow 0.0.2__py3-none-any.whl → 0.0.4__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/__types.py +1 -0
- ddeutil/workflow/conn.py +13 -10
- ddeutil/workflow/exceptions.py +0 -20
- ddeutil/workflow/loader.py +39 -11
- ddeutil/workflow/pipeline.py +223 -162
- ddeutil/workflow/schedule.py +7 -7
- ddeutil/workflow/tasks/_pandas.py +1 -1
- ddeutil/workflow/tasks/_polars.py +10 -2
- ddeutil/workflow/utils.py +123 -1
- ddeutil/workflow/vendors/__dataset.py +127 -0
- ddeutil/workflow/vendors/az.py +0 -0
- ddeutil/workflow/vendors/pd.py +13 -0
- ddeutil/workflow/vendors/pg.py +11 -0
- ddeutil/workflow/{dataset.py → vendors/pl.py} +3 -133
- {ddeutil_workflow-0.0.2.dist-info → ddeutil_workflow-0.0.4.dist-info}/METADATA +19 -15
- ddeutil_workflow-0.0.4.dist-info/RECORD +29 -0
- ddeutil_workflow-0.0.2.dist-info/RECORD +0 -25
- /ddeutil/workflow/vendors/{aws_warpped.py → aws.py} +0 -0
- /ddeutil/workflow/vendors/{minio_warpped.py → minio.py} +0 -0
- /ddeutil/workflow/vendors/{sftp_wrapped.py → sftp.py} +0 -0
- {ddeutil_workflow-0.0.2.dist-info → ddeutil_workflow-0.0.4.dist-info}/LICENSE +0 -0
- {ddeutil_workflow-0.0.2.dist-info → ddeutil_workflow-0.0.4.dist-info}/WHEEL +0 -0
- {ddeutil_workflow-0.0.2.dist-info → ddeutil_workflow-0.0.4.dist-info}/top_level.txt +0 -0
ddeutil/workflow/__about__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__: str = "0.0.
|
1
|
+
__version__: str = "0.0.4"
|
ddeutil/workflow/__types.py
CHANGED
ddeutil/workflow/conn.py
CHANGED
@@ -43,8 +43,14 @@ class BaseConn(BaseModel):
|
|
43
43
|
]
|
44
44
|
|
45
45
|
@classmethod
|
46
|
-
def from_dict(cls, values: DictData):
|
47
|
-
"""Construct Connection
|
46
|
+
def from_dict(cls, values: DictData) -> Self:
|
47
|
+
"""Construct Connection Model from dict data. This construct is
|
48
|
+
different with ``.model_validate()`` because it will prepare the values
|
49
|
+
before using it if the data dose not have 'url'.
|
50
|
+
|
51
|
+
:param values: A dict data that use to construct this model.
|
52
|
+
"""
|
53
|
+
# NOTE: filter out the fields of this model.
|
48
54
|
filter_data: DictData = {
|
49
55
|
k: values.pop(k)
|
50
56
|
for k in values.copy()
|
@@ -73,15 +79,11 @@ class BaseConn(BaseModel):
|
|
73
79
|
)
|
74
80
|
|
75
81
|
@classmethod
|
76
|
-
def from_loader(
|
77
|
-
cls,
|
78
|
-
name: str,
|
79
|
-
externals: DictData,
|
80
|
-
) -> Self:
|
82
|
+
def from_loader(cls, name: str, externals: DictData) -> Self:
|
81
83
|
"""Construct Connection with Loader object with specific config name.
|
82
84
|
|
83
|
-
:param name:
|
84
|
-
:param externals:
|
85
|
+
:param name: A config name.
|
86
|
+
:param externals: A external data that want to adding to extras.
|
85
87
|
"""
|
86
88
|
loader: Loader = Loader(name, externals=externals)
|
87
89
|
# NOTE: Validate the config type match with current connection model
|
@@ -96,6 +98,7 @@ class BaseConn(BaseModel):
|
|
96
98
|
|
97
99
|
@field_validator("endpoint")
|
98
100
|
def __prepare_slash(cls, value: str) -> str:
|
101
|
+
"""Prepare slash character that map double form URL model loading."""
|
99
102
|
if value.startswith("//"):
|
100
103
|
return value[1:]
|
101
104
|
return value
|
@@ -148,7 +151,7 @@ class SFTP(Conn):
|
|
148
151
|
dialect: Literal["sftp"] = "sftp"
|
149
152
|
|
150
153
|
def __client(self):
|
151
|
-
from .vendors.
|
154
|
+
from .vendors.sftp import WrapSFTP
|
152
155
|
|
153
156
|
return WrapSFTP(
|
154
157
|
host=self.host,
|
ddeutil/workflow/exceptions.py
CHANGED
@@ -9,24 +9,4 @@ Define Errors Object for Node package
|
|
9
9
|
from __future__ import annotations
|
10
10
|
|
11
11
|
|
12
|
-
class BaseError(Exception):
|
13
|
-
"""Base Error Object that use for catch any errors statement of
|
14
|
-
all step in this src
|
15
|
-
"""
|
16
|
-
|
17
|
-
|
18
|
-
class WorkflowBaseError(BaseError):
|
19
|
-
"""Core Base Error object"""
|
20
|
-
|
21
|
-
|
22
|
-
class ConfigNotFound(WorkflowBaseError):
|
23
|
-
"""Error raise for a method not found the config file or data."""
|
24
|
-
|
25
|
-
|
26
|
-
class PyException(Exception): ...
|
27
|
-
|
28
|
-
|
29
|
-
class ShellException(Exception): ...
|
30
|
-
|
31
|
-
|
32
12
|
class TaskException(Exception): ...
|
ddeutil/workflow/loader.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from __future__ import annotations
|
7
7
|
|
8
8
|
from functools import cached_property
|
9
|
-
from typing import Any, TypeVar
|
9
|
+
from typing import Any, ClassVar, TypeVar
|
10
10
|
|
11
11
|
from ddeutil.core import (
|
12
12
|
getdot,
|
@@ -14,12 +14,12 @@ from ddeutil.core import (
|
|
14
14
|
import_string,
|
15
15
|
)
|
16
16
|
from ddeutil.io import (
|
17
|
-
|
18
|
-
Params,
|
17
|
+
PathData,
|
19
18
|
PathSearch,
|
20
19
|
YamlEnvFl,
|
21
20
|
)
|
22
|
-
from pydantic import BaseModel
|
21
|
+
from pydantic import BaseModel, Field
|
22
|
+
from pydantic.functional_validators import model_validator
|
23
23
|
|
24
24
|
from .__regex import RegexConf
|
25
25
|
from .__types import DictData
|
@@ -29,6 +29,25 @@ BaseModelType = type[BaseModel]
|
|
29
29
|
AnyModel = TypeVar("AnyModel", bound=BaseModel)
|
30
30
|
|
31
31
|
|
32
|
+
class Engine(BaseModel):
|
33
|
+
"""Engine Model"""
|
34
|
+
|
35
|
+
paths: PathData = Field(default_factory=PathData)
|
36
|
+
registry: list[str] = Field(default_factory=lambda: ["ddeutil.workflow"])
|
37
|
+
|
38
|
+
@model_validator(mode="before")
|
39
|
+
def __prepare_registry(cls, values: DictData) -> DictData:
|
40
|
+
if (_regis := values.get("registry")) and isinstance(_regis, str):
|
41
|
+
values["registry"] = [_regis]
|
42
|
+
return values
|
43
|
+
|
44
|
+
|
45
|
+
class Params(BaseModel):
|
46
|
+
"""Params Model"""
|
47
|
+
|
48
|
+
engine: Engine = Field(default_factory=Engine)
|
49
|
+
|
50
|
+
|
32
51
|
class SimLoad:
|
33
52
|
"""Simple Load Object that will search config data by name.
|
34
53
|
|
@@ -36,13 +55,11 @@ class SimLoad:
|
|
36
55
|
:param params: A Params model object.
|
37
56
|
:param externals: An external parameters
|
38
57
|
|
39
|
-
|
58
|
+
Noted:
|
40
59
|
The config data should have ``type`` key for engine can know what is
|
41
60
|
config should to do next.
|
42
61
|
"""
|
43
62
|
|
44
|
-
import_prefix: str = "ddeutil.workflow"
|
45
|
-
|
46
63
|
def __init__(
|
47
64
|
self,
|
48
65
|
name: str,
|
@@ -56,7 +73,7 @@ class SimLoad:
|
|
56
73
|
):
|
57
74
|
self.data = data
|
58
75
|
if not self.data:
|
59
|
-
raise
|
76
|
+
raise ValueError(f"Config {name!r} does not found on conf path")
|
60
77
|
self.__conf_params: Params = params
|
61
78
|
self.externals: DictData = externals
|
62
79
|
|
@@ -75,6 +92,11 @@ class SimLoad:
|
|
75
92
|
# NOTE: Auto adding module prefix if it does not set
|
76
93
|
return import_string(f"ddeutil.workflow.{_typ}")
|
77
94
|
except ModuleNotFoundError:
|
95
|
+
for registry in self.conf_params.engine.registry:
|
96
|
+
try:
|
97
|
+
return import_string(f"{registry}.{_typ}")
|
98
|
+
except ModuleNotFoundError:
|
99
|
+
continue
|
78
100
|
return import_string(f"{_typ}")
|
79
101
|
|
80
102
|
def load(self) -> AnyModel:
|
@@ -82,12 +104,14 @@ class SimLoad:
|
|
82
104
|
|
83
105
|
|
84
106
|
class Loader(SimLoad):
|
85
|
-
"""Main Loader Object.
|
107
|
+
"""Main Loader Object that get the config `yaml` file from current path.
|
86
108
|
|
87
109
|
:param name: A name of config data that will read by Yaml Loader object.
|
88
110
|
:param externals: An external parameters
|
89
111
|
"""
|
90
112
|
|
113
|
+
conf_name: ClassVar[str] = "workflows-conf"
|
114
|
+
|
91
115
|
def __init__(
|
92
116
|
self,
|
93
117
|
name: str,
|
@@ -106,12 +130,16 @@ class Loader(SimLoad):
|
|
106
130
|
def config(cls, path: str | None = None) -> Params:
|
107
131
|
"""Load Config data from ``workflows-conf.yaml`` file."""
|
108
132
|
return Params.model_validate(
|
109
|
-
YamlEnvFl(path or "./
|
133
|
+
YamlEnvFl(path or f"./{cls.conf_name}.yaml").read()
|
110
134
|
)
|
111
135
|
|
112
136
|
|
113
137
|
def map_params(value: Any, params: dict[str, Any]) -> Any:
|
114
|
-
"""Map caller value that found from ``RE_CALLER``
|
138
|
+
"""Map caller value that found from ``RE_CALLER`` regular expression.
|
139
|
+
|
140
|
+
:param value: A value that want to mapped with an params
|
141
|
+
:param params: A parameter value that getting with matched regular
|
142
|
+
expression.
|
115
143
|
|
116
144
|
:rtype: Any
|
117
145
|
:returns: An any getter value from the params input.
|