ddeutil-workflow 0.0.58__py3-none-any.whl → 0.0.60__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/utils.py CHANGED
@@ -15,7 +15,7 @@ from inspect import isfunction
15
15
  from itertools import chain, islice, product
16
16
  from pathlib import Path
17
17
  from random import randrange
18
- from typing import Any, Final, TypeVar
18
+ from typing import Any, Final, Optional, TypeVar, Union
19
19
  from zoneinfo import ZoneInfo
20
20
 
21
21
  from ddeutil.core import hash_str
@@ -24,7 +24,7 @@ from .__types import DictData, Matrix
24
24
 
25
25
  T = TypeVar("T")
26
26
  UTC: Final[ZoneInfo] = ZoneInfo("UTC")
27
- MARK_NL: Final[str] = "||"
27
+ MARK_NEWLINE: Final[str] = "||"
28
28
 
29
29
 
30
30
  def prepare_newline(msg: str) -> str:
@@ -34,11 +34,12 @@ def prepare_newline(msg: str) -> str:
34
34
 
35
35
  :rtype: str
36
36
  """
37
- msg: str = msg.strip("\n").replace("\n", MARK_NL)
38
- if MARK_NL not in msg:
37
+ # NOTE: Remove ending with "\n" and replace "\n" with the "||" value.
38
+ msg: str = msg.strip("\n").replace("\n", MARK_NEWLINE)
39
+ if MARK_NEWLINE not in msg:
39
40
  return msg
40
41
 
41
- msg_lines: list[str] = msg.split(MARK_NL)
42
+ msg_lines: list[str] = msg.split(MARK_NEWLINE)
42
43
  msg_last: str = msg_lines[-1]
43
44
  msg_body: str = (
44
45
  "\n" + "\n".join(f" ... | \t{s}" for s in msg_lines[1:-1])
@@ -63,7 +64,7 @@ def clear_tz(dt: datetime) -> datetime:
63
64
  return dt.replace(tzinfo=None)
64
65
 
65
66
 
66
- def get_dt_now(tz: ZoneInfo | None = None, offset: float = 0.0) -> datetime:
67
+ def get_dt_now(tz: Optional[ZoneInfo] = None, offset: float = 0.0) -> datetime:
67
68
  """Return the current datetime object.
68
69
 
69
70
  :param tz: A ZoneInfo object for replace timezone of return datetime object.
@@ -76,7 +77,7 @@ def get_dt_now(tz: ZoneInfo | None = None, offset: float = 0.0) -> datetime:
76
77
 
77
78
 
78
79
  def get_d_now(
79
- tz: ZoneInfo | None = None, offset: float = 0.0
80
+ tz: Optional[ZoneInfo] = None, offset: float = 0.0
80
81
  ) -> date: # pragma: no cov
81
82
  """Return the current date object.
82
83
 
@@ -147,7 +148,7 @@ def gen_id(
147
148
  *,
148
149
  sensitive: bool = True,
149
150
  unique: bool = False,
150
- simple_mode: bool | None = None,
151
+ simple_mode: Optional[bool] = None,
151
152
  extras: DictData | None = None,
152
153
  ) -> str:
153
154
  """Generate running ID for able to tracking. This generates process use
@@ -197,7 +198,7 @@ def default_gen_id() -> str:
197
198
  return gen_id("manual", unique=True)
198
199
 
199
200
 
200
- def make_exec(path: str | Path) -> None:
201
+ def make_exec(path: Union[Path, str]) -> None:
201
202
  """Change mode of file to be executable file.
202
203
 
203
204
  :param path: A file path that want to make executable permission.
@@ -244,7 +245,7 @@ def cross_product(matrix: Matrix) -> Iterator[DictData]:
244
245
  )
245
246
 
246
247
 
247
- def batch(iterable: Iterator[Any] | range, n: int) -> Iterator[Any]:
248
+ def batch(iterable: Union[Iterator[Any], range], n: int) -> Iterator[Any]:
248
249
  """Batch data into iterators of length n. The last batch may be shorter.
249
250
 
250
251
  Example:
@@ -69,10 +69,10 @@ __all__: TupleStr = (
69
69
  class ReleaseType(str, Enum):
70
70
  """Release Type Enum support the type field on the Release dataclass."""
71
71
 
72
- DEFAULT: str = "manual"
73
- SCHEDULE: str = "schedule"
74
- POKING: str = "poking"
75
- FORCE: str = "force"
72
+ DEFAULT = "manual"
73
+ SCHEDULE = "schedule"
74
+ POKING = "poking"
75
+ FORCE = "force"
76
76
 
77
77
 
78
78
  @total_ordering
@@ -105,14 +105,14 @@ class Release:
105
105
  return f"{self.date:%Y-%m-%d %H:%M:%S}"
106
106
 
107
107
  @classmethod
108
- def from_dt(cls, dt: datetime | str) -> Self:
108
+ def from_dt(cls, dt: Union[datetime, str]) -> Self:
109
109
  """Construct Release object from `datetime` or `str` objects.
110
110
 
111
111
  This method will replace second and millisecond value to 0 and
112
112
  replace timezone to the `tz` config setting or extras overriding before
113
113
  create Release object.
114
114
 
115
- :param dt: (datetime | str) A datetime object or string that want to
115
+ :param dt: (Union[datetime, str]) A datetime object or string that want to
116
116
  construct to the Release object.
117
117
 
118
118
  :raise TypeError: If the type of the dt argument does not valid with
@@ -129,7 +129,7 @@ class Release:
129
129
  )
130
130
  return cls(date=replace_sec(dt.replace(tzinfo=None)))
131
131
 
132
- def __eq__(self, other: Release | datetime) -> bool:
132
+ def __eq__(self, other: Union[Release, datetime]) -> bool:
133
133
  """Override equal property that will compare only the same type or
134
134
  datetime.
135
135
 
@@ -141,7 +141,7 @@ class Release:
141
141
  return self.date == other
142
142
  return NotImplemented
143
143
 
144
- def __lt__(self, other: Release | datetime) -> bool:
144
+ def __lt__(self, other: Union[Release, datetime]) -> bool:
145
145
  """Override less-than property that will compare only the same type or
146
146
  datetime.
147
147
 
@@ -209,7 +209,7 @@ class ReleaseQueue:
209
209
  """
210
210
  return len(self.queue) > 0
211
211
 
212
- def check_queue(self, value: Release | datetime) -> bool:
212
+ def check_queue(self, value: Union[Release, datetime]) -> bool:
213
213
  """Check a Release value already exists in list of tracking
214
214
  queues.
215
215
 
@@ -476,7 +476,7 @@ class Workflow(BaseModel):
476
476
  if len(set_tz) > 1:
477
477
  raise ValueError(
478
478
  f"The on fields should not contain multiple timezone, "
479
- f"{list[set_tz]}."
479
+ f"{list(set_tz)}."
480
480
  )
481
481
 
482
482
  extras: Optional[DictData] = info.data.get("extras")
@@ -563,11 +563,12 @@ class Workflow(BaseModel):
563
563
  adding jobs key to this parameter.
564
564
  """
565
565
  # VALIDATE: Incoming params should have keys that set on this workflow.
566
- if check_key := tuple(
566
+ check_key: list[str] = [
567
567
  f"{k!r}"
568
568
  for k in self.params
569
569
  if (k not in params and self.params[k].required)
570
- ):
570
+ ]
571
+ if check_key:
571
572
  raise WorkflowException(
572
573
  f"Required Param on this workflow setting does not set: "
573
574
  f"{', '.join(check_key)}."
@@ -588,14 +589,14 @@ class Workflow(BaseModel):
588
589
 
589
590
  def release(
590
591
  self,
591
- release: datetime | Release,
592
+ release: Union[Release, datetime],
592
593
  params: DictData,
593
594
  *,
594
- run_id: str | None = None,
595
- parent_run_id: str | None = None,
595
+ run_id: Optional[str] = None,
596
+ parent_run_id: Optional[str] = None,
596
597
  audit: type[Audit] = None,
597
598
  queue: Optional[ReleaseQueue] = None,
598
- override_log_name: str | None = None,
599
+ override_log_name: Optional[str] = None,
599
600
  result: Optional[Result] = None,
600
601
  timeout: int = 600,
601
602
  ) -> Result:
@@ -670,7 +671,7 @@ class Workflow(BaseModel):
670
671
  rs: Result = self.execute(
671
672
  params=values,
672
673
  result=result,
673
- parent_run_id=result.parent_run_id,
674
+ parent_run_id=result.run_id,
674
675
  timeout=timeout,
675
676
  )
676
677
  result.trace.info(
@@ -745,12 +746,12 @@ class Workflow(BaseModel):
745
746
 
746
747
  def poke(
747
748
  self,
748
- params: DictData | None = None,
749
- start_date: datetime | None = None,
749
+ params: Optional[DictData] = None,
750
+ start_date: Optional[datetime] = None,
750
751
  *,
751
- run_id: str | None = None,
752
+ run_id: Optional[str] = None,
752
753
  periods: int = 1,
753
- audit: Audit | None = None,
754
+ audit: Optional[Audit] = None,
754
755
  force_run: bool = False,
755
756
  timeout: int = 1800,
756
757
  max_poking_pool_worker: int = 2,
@@ -907,8 +908,8 @@ class Workflow(BaseModel):
907
908
  job: Job,
908
909
  params: DictData,
909
910
  *,
910
- result: Result | None = None,
911
- event: Event | None = None,
911
+ result: Optional[Result] = None,
912
+ event: Optional[Event] = None,
912
913
  ) -> Result:
913
914
  """Job execution with passing dynamic parameters from the main workflow
914
915
  execution to the target job object via job's ID.
@@ -969,10 +970,10 @@ class Workflow(BaseModel):
969
970
  self,
970
971
  params: DictData,
971
972
  *,
972
- run_id: str | None = None,
973
- parent_run_id: str | None = None,
974
- result: Result | None = None,
975
- event: Event | None = None,
973
+ run_id: Optional[str] = None,
974
+ parent_run_id: Optional[str] = None,
975
+ result: Optional[Result] = None,
976
+ event: Optional[Event] = None,
976
977
  timeout: int = 3600,
977
978
  max_job_parallel: int = 2,
978
979
  ) -> Result:
@@ -999,8 +1000,8 @@ class Workflow(BaseModel):
999
1000
  at the result context.
1000
1001
 
1001
1002
  :param params: A parameter data that will parameterize before execution.
1002
- :param run_id: (str | None) A workflow running ID.
1003
- :param parent_run_id: (str | None) A parent workflow running ID.
1003
+ :param run_id: (Optional[str]) A workflow running ID.
1004
+ :param parent_run_id: (Optional[str]) A parent workflow running ID.
1004
1005
  :param result: (Result) A Result instance for return context and status.
1005
1006
  :param event: (Event) An Event manager instance that use to cancel this
1006
1007
  execution if it forces stopped by parent execution.
@@ -1165,10 +1166,10 @@ class WorkflowTask:
1165
1166
 
1166
1167
  def release(
1167
1168
  self,
1168
- release: datetime | Release | None = None,
1169
- run_id: str | None = None,
1169
+ release: Optional[Union[Release, datetime]] = None,
1170
+ run_id: Optional[str] = None,
1170
1171
  audit: type[Audit] = None,
1171
- queue: ReleaseQueue | None = None,
1172
+ queue: Optional[ReleaseQueue] = None,
1172
1173
  ) -> Result:
1173
1174
  """Release the workflow task that passing an override parameter to
1174
1175
  the parent release method with the `values` field.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ddeutil-workflow
3
- Version: 0.0.58
3
+ Version: 0.0.60
4
4
  Summary: Lightweight workflow orchestration
5
5
  Author-email: ddeutils <korawich.anu@gmail.com>
6
6
  License: MIT
@@ -23,17 +23,20 @@ Requires-Python: >=3.9.13
23
23
  Description-Content-Type: text/markdown
24
24
  License-File: LICENSE
25
25
  Requires-Dist: ddeutil[checksum]>=0.4.8
26
- Requires-Dist: ddeutil-io[toml,yaml]>=0.2.12
27
- Requires-Dist: pydantic==2.11.1
26
+ Requires-Dist: ddeutil-io[toml,yaml]>=0.2.13
27
+ Requires-Dist: pydantic==2.11.4
28
28
  Requires-Dist: python-dotenv==1.1.0
29
29
  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
+ Requires-Dist: uvicorn; extra == "all"
32
33
  Requires-Dist: httpx; extra == "all"
34
+ Requires-Dist: ujson; extra == "all"
33
35
  Requires-Dist: aiofiles; extra == "all"
34
36
  Requires-Dist: aiohttp; extra == "all"
35
37
  Provides-Extra: api
36
38
  Requires-Dist: fastapi<1.0.0,>=0.115.0; extra == "api"
39
+ Requires-Dist: uvicorn; extra == "api"
37
40
  Requires-Dist: httpx; extra == "api"
38
41
  Requires-Dist: ujson; extra == "api"
39
42
  Provides-Extra: async
@@ -41,6 +44,8 @@ Requires-Dist: aiofiles; extra == "async"
41
44
  Requires-Dist: aiohttp; extra == "async"
42
45
  Provides-Extra: docker
43
46
  Requires-Dist: docker==7.1.0; extra == "docker"
47
+ Provides-Extra: self-hosted
48
+ Requires-Dist: requests==2.32.3; extra == "self-hosted"
44
49
  Dynamic: license-file
45
50
 
46
51
  # Workflow Orchestration
@@ -0,0 +1,31 @@
1
+ ddeutil/workflow/__about__.py,sha256=sQSmxiDbXlnTI1qDQGcyxr1EGvwITzIX0PKi2dOg4LU,28
2
+ ddeutil/workflow/__cron.py,sha256=5DHQKejG-76L_oREW78RcwMzeyKddJxSMmBzYyMAeeY,28536
3
+ ddeutil/workflow/__init__.py,sha256=NXEhjzKFdIGa-jtIq9HXChLCjSXNPd8VJ8ltggxbBO8,1371
4
+ ddeutil/workflow/__main__.py,sha256=x-sYedl4T8p6054aySk-EQX6vhytvPR0HvaBNYxMzp0,364
5
+ ddeutil/workflow/__types.py,sha256=uNfoRbVmNK5O37UUMVnqcmoghD9oMS1q9fXC0APnjSI,4584
6
+ ddeutil/workflow/conf.py,sha256=NLvjZ8bpDsn4e0MG3m1vgMdAwtmii5hP1D0STKQyZeo,14907
7
+ ddeutil/workflow/event.py,sha256=iAvd7TfAJaMndDhxbi1xNLzl4wNlgLqe1nIseaIm5-Y,10533
8
+ ddeutil/workflow/exceptions.py,sha256=TKHBIlfquz3yEb8_kg6UXpxVLKxstt3QA9a1XYsLPJk,2455
9
+ ddeutil/workflow/job.py,sha256=Php1b3n6c-jddel8PTSa61kAW22QBTetzoLVR4XXM4E,35240
10
+ ddeutil/workflow/logs.py,sha256=81wl83dbYDcMctGmWiptmFaoZoXFO2TS0E4sxOILOQk,31321
11
+ ddeutil/workflow/params.py,sha256=tBjKe1_e0TlUrSrlMahDuAdNNBlGBAKMmMMQ9eV-YSs,11616
12
+ ddeutil/workflow/result.py,sha256=4M9VCcveI8Yz6ZrnI-67SZlry-Z8G7e0hziy1k-pklk,5906
13
+ ddeutil/workflow/reusables.py,sha256=mw_Fi763B5am0EmntcjLBF7MDEhKqud2BYHcYyno5Ec,17663
14
+ ddeutil/workflow/scheduler.py,sha256=OsEyj2zscQ-3bDMk2z7UtKlCWLlgoGjaRFt17o1B1ew,27263
15
+ ddeutil/workflow/stages.py,sha256=N_DkEUGiwpglovtXx-Wg3zX_03eGBT650zRsZV7knKk,92640
16
+ ddeutil/workflow/utils.py,sha256=ADJTt3kiF44qntsRnOUdCFihlB2WWbRE-Tojp5EOYbk,8898
17
+ ddeutil/workflow/workflow.py,sha256=BFnaB_7mrYZ3KV07AV16xR9khsoSt9i3QLyEtrLNAqs,44877
18
+ ddeutil/workflow/api/__init__.py,sha256=kY30dL8HPY8tY_GBmm7y_3OdoXzB1-EA2a96PLU0AQw,5278
19
+ ddeutil/workflow/api/logs.py,sha256=NMTnOnsBrDB5129329xF2myLdrb-z9k1MQrmrP7qXJw,1818
20
+ ddeutil/workflow/api/utils.py,sha256=uTtUFVLpiYYahXvCVx8sueRQ03K2Xw1id_gW3IMmX1U,5295
21
+ ddeutil/workflow/api/routes/__init__.py,sha256=qoGtOMyVgQ5nTUc8J8wH27A8isaxl3IFCX8qoyibeCY,484
22
+ ddeutil/workflow/api/routes/job.py,sha256=8X5VLDJH6PumyNIY6JGRNBsf2gWN0eG9DzxRPSh6n4I,2190
23
+ ddeutil/workflow/api/routes/logs.py,sha256=U6vOni3wd-ZTOwd3yVdSOpgyRmNdcgfngU5KlLM3Cww,5383
24
+ ddeutil/workflow/api/routes/schedules.py,sha256=14RnaJKEGMSJtncI1H_QQVZNBe_jDS40PPRO6qFc3i0,4805
25
+ ddeutil/workflow/api/routes/workflows.py,sha256=GJu5PiXEylswrXylEImpncySjeU9chrvrtjhiMCw2RQ,4529
26
+ ddeutil_workflow-0.0.60.dist-info/licenses/LICENSE,sha256=nGFZ1QEhhhWeMHf9n99_fdt4vQaXS29xWKxt-OcLywk,1085
27
+ ddeutil_workflow-0.0.60.dist-info/METADATA,sha256=VixljHKK-7rmiv5UC_65sp2DAgb3kHjms1H7vvF0DyY,19427
28
+ ddeutil_workflow-0.0.60.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
29
+ ddeutil_workflow-0.0.60.dist-info/entry_points.txt,sha256=qDTpPSauL0ciO6T4iSVt8bJeYrVEkkoEEw_RlGx6Kgk,63
30
+ ddeutil_workflow-0.0.60.dist-info/top_level.txt,sha256=m9M6XeSWDwt_yMsmH6gcOjHZVK5O0-vgtNBuncHjzW4,8
31
+ ddeutil_workflow-0.0.60.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (79.0.1)
2
+ Generator: setuptools (80.3.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,31 +0,0 @@
1
- ddeutil/workflow/__about__.py,sha256=aH1VtwOIsTYSvZ--4Gjq5U7sAIC_RxyBRrJoMOYdUMs,28
2
- ddeutil/workflow/__cron.py,sha256=yLWN_1MtcN5Uc3Dinq5lpsjW1_0HmIM5tEm-o_q0Spw,28527
3
- ddeutil/workflow/__init__.py,sha256=NXEhjzKFdIGa-jtIq9HXChLCjSXNPd8VJ8ltggxbBO8,1371
4
- ddeutil/workflow/__main__.py,sha256=x-sYedl4T8p6054aySk-EQX6vhytvPR0HvaBNYxMzp0,364
5
- ddeutil/workflow/__types.py,sha256=7xXy6ynpT6Do6U5A-XYSVuinE2g-4wlZGGJ1NACK1BE,4343
6
- ddeutil/workflow/conf.py,sha256=x3ZCvz_NCpfqMV2DQtMMdYN4pMN9s6AEX9uFsIpiqz0,14827
7
- ddeutil/workflow/event.py,sha256=VAXUwkuKwaH2gpqc2g0qTE1EhO0dAi46b-RSEtBYvnc,10397
8
- ddeutil/workflow/exceptions.py,sha256=HNXkZLaoWa6ejYG1NdwlUAyZiJWbsjjOJ9DjIPaM-aw,2343
9
- ddeutil/workflow/job.py,sha256=FYfnJnSKVLtyVzM0VrcMRXOk_m_YH4vPCvfmzvaOiZ8,35241
10
- ddeutil/workflow/logs.py,sha256=Jkcj42-GdK5kTY0w2y8PTCPyofRjfG5EVSirWICrjv4,27618
11
- ddeutil/workflow/params.py,sha256=QCI5u2gCzi9vR8_emjyJaVevTrr81ofhFK_vPHfPf2k,11560
12
- ddeutil/workflow/result.py,sha256=yEV_IXtiC8x-4zx6DKal5swebjtOWdKakv-WuhNyiNQ,5891
13
- ddeutil/workflow/reusables.py,sha256=iXcS7Gg-71qVX4ln0ILTDx03cTtUnj_rNoXHTVdVrxc,17636
14
- ddeutil/workflow/scheduler.py,sha256=8btWD5dDgTHyx92MJvFWbN79dDTAvVuaLzjm4c_HQvo,27239
15
- ddeutil/workflow/stages.py,sha256=83pP3kLjTKIV66XsMm8rvEnF4ZNknxQTk80MePb_e5U,92032
16
- ddeutil/workflow/utils.py,sha256=wrL9nAVPOFWEvgniELAHbB_NGVX5QeL9DkzHEE35LE8,8766
17
- ddeutil/workflow/workflow.py,sha256=bJ-CCv4U8EOg73qQKVjdAQ0xU82OShUCJGdSgfa8dRs,44785
18
- ddeutil/workflow/api/__init__.py,sha256=kY30dL8HPY8tY_GBmm7y_3OdoXzB1-EA2a96PLU0AQw,5278
19
- ddeutil/workflow/api/logs.py,sha256=NMTnOnsBrDB5129329xF2myLdrb-z9k1MQrmrP7qXJw,1818
20
- ddeutil/workflow/api/utils.py,sha256=uTtUFVLpiYYahXvCVx8sueRQ03K2Xw1id_gW3IMmX1U,5295
21
- ddeutil/workflow/api/routes/__init__.py,sha256=qoGtOMyVgQ5nTUc8J8wH27A8isaxl3IFCX8qoyibeCY,484
22
- ddeutil/workflow/api/routes/job.py,sha256=8X5VLDJH6PumyNIY6JGRNBsf2gWN0eG9DzxRPSh6n4I,2190
23
- ddeutil/workflow/api/routes/logs.py,sha256=U6vOni3wd-ZTOwd3yVdSOpgyRmNdcgfngU5KlLM3Cww,5383
24
- ddeutil/workflow/api/routes/schedules.py,sha256=14RnaJKEGMSJtncI1H_QQVZNBe_jDS40PPRO6qFc3i0,4805
25
- ddeutil/workflow/api/routes/workflows.py,sha256=GJu5PiXEylswrXylEImpncySjeU9chrvrtjhiMCw2RQ,4529
26
- ddeutil_workflow-0.0.58.dist-info/licenses/LICENSE,sha256=nGFZ1QEhhhWeMHf9n99_fdt4vQaXS29xWKxt-OcLywk,1085
27
- ddeutil_workflow-0.0.58.dist-info/METADATA,sha256=1jRIZa2yDn_5BojKYl-Fvpbkb5rUSHwPnZl5JlDmSqA,19228
28
- ddeutil_workflow-0.0.58.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
29
- ddeutil_workflow-0.0.58.dist-info/entry_points.txt,sha256=qDTpPSauL0ciO6T4iSVt8bJeYrVEkkoEEw_RlGx6Kgk,63
30
- ddeutil_workflow-0.0.58.dist-info/top_level.txt,sha256=m9M6XeSWDwt_yMsmH6gcOjHZVK5O0-vgtNBuncHjzW4,8
31
- ddeutil_workflow-0.0.58.dist-info/RECORD,,