ddeutil-workflow 0.0.41__py3-none-any.whl → 0.0.42__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/api/api.py +7 -7
- ddeutil/workflow/api/routes/schedules.py +5 -5
- ddeutil/workflow/api/routes/workflows.py +2 -2
- ddeutil/workflow/conf.py +39 -28
- ddeutil/workflow/cron.py +12 -13
- ddeutil/workflow/job.py +18 -10
- ddeutil/workflow/logs.py +33 -6
- ddeutil/workflow/reusables.py +16 -13
- ddeutil/workflow/scheduler.py +26 -28
- ddeutil/workflow/stages.py +257 -62
- ddeutil/workflow/utils.py +0 -1
- ddeutil/workflow/workflow.py +111 -74
- {ddeutil_workflow-0.0.41.dist-info → ddeutil_workflow-0.0.42.dist-info}/METADATA +6 -9
- ddeutil_workflow-0.0.42.dist-info/RECORD +30 -0
- ddeutil/workflow/context.py +0 -61
- ddeutil_workflow-0.0.41.dist-info/RECORD +0 -31
- {ddeutil_workflow-0.0.41.dist-info → ddeutil_workflow-0.0.42.dist-info}/WHEEL +0 -0
- {ddeutil_workflow-0.0.41.dist-info → ddeutil_workflow-0.0.42.dist-info}/licenses/LICENSE +0 -0
- {ddeutil_workflow-0.0.41.dist-info → ddeutil_workflow-0.0.42.dist-info}/top_level.txt +0 -0
ddeutil/workflow/scheduler.py
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
# Licensed under the MIT License. See LICENSE in the project root for
|
4
4
|
# license information.
|
5
5
|
# ------------------------------------------------------------------------------
|
6
|
-
|
7
|
-
The main schedule running is `schedule_runner` function that trigger the
|
6
|
+
# [x] Use fix config
|
7
|
+
"""The main schedule running is `schedule_runner` function that trigger the
|
8
8
|
multiprocess of `schedule_control` function for listing schedules on the
|
9
9
|
config by `Loader.finds(Schedule)`.
|
10
10
|
|
@@ -86,9 +86,9 @@ class ScheduleWorkflow(BaseModel):
|
|
86
86
|
model.
|
87
87
|
|
88
88
|
This on field does not equal to the on field of Workflow model, but it
|
89
|
-
uses same logic to generate running release date with crontab object. It
|
90
|
-
for override the on field if the schedule time was change but you do
|
91
|
-
want to change on the workflow model.
|
89
|
+
uses same logic to generate running release date with crontab object. It
|
90
|
+
uses for override the on field if the schedule time was change, but you do
|
91
|
+
not want to change on the workflow model.
|
92
92
|
"""
|
93
93
|
|
94
94
|
alias: Optional[str] = Field(
|
@@ -177,7 +177,7 @@ class ScheduleWorkflow(BaseModel):
|
|
177
177
|
start_date: datetime,
|
178
178
|
queue: dict[str, ReleaseQueue],
|
179
179
|
*,
|
180
|
-
|
180
|
+
extras: DictData | None = None,
|
181
181
|
) -> list[WorkflowTask]:
|
182
182
|
"""Return the list of WorkflowTask object from the specific input
|
183
183
|
datetime that mapping with the on field.
|
@@ -187,17 +187,17 @@ class ScheduleWorkflow(BaseModel):
|
|
187
187
|
|
188
188
|
:param start_date: A start date that get from the workflow schedule.
|
189
189
|
:param queue: A mapping of name and list of datetime for queue.
|
190
|
-
:param
|
190
|
+
:param extras: An extra parameters that pass to the Loader object.
|
191
191
|
|
192
192
|
:rtype: list[WorkflowTask]
|
193
193
|
:return: Return the list of WorkflowTask object from the specific
|
194
194
|
input datetime that mapping with the on field.
|
195
195
|
"""
|
196
196
|
workflow_tasks: list[WorkflowTask] = []
|
197
|
-
extras: DictData =
|
197
|
+
extras: DictData = extras or {}
|
198
198
|
|
199
199
|
# NOTE: Loading workflow model from the name of workflow.
|
200
|
-
wf: Workflow = Workflow.
|
200
|
+
wf: Workflow = Workflow.from_conf(self.name, extras=extras)
|
201
201
|
wf_queue: ReleaseQueue = queue[self.alias]
|
202
202
|
|
203
203
|
# IMPORTANT: Create the default 'on' value if it does not pass the `on`
|
@@ -254,24 +254,24 @@ class Schedule(BaseModel):
|
|
254
254
|
return dedent(value)
|
255
255
|
|
256
256
|
@classmethod
|
257
|
-
def
|
257
|
+
def from_conf(
|
258
258
|
cls,
|
259
259
|
name: str,
|
260
|
-
|
260
|
+
extras: DictData | None = None,
|
261
261
|
) -> Self:
|
262
262
|
"""Create Schedule instance from the Loader object that only receive
|
263
263
|
an input schedule name. The loader object will use this schedule name to
|
264
264
|
searching configuration data of this schedule model in conf path.
|
265
265
|
|
266
266
|
:param name: (str) A schedule name that want to pass to Loader object.
|
267
|
-
:param
|
267
|
+
:param extras: An extra parameters that want to pass to Loader
|
268
268
|
object.
|
269
269
|
|
270
270
|
:raise ValueError: If the type does not match with current object.
|
271
271
|
|
272
272
|
:rtype: Self
|
273
273
|
"""
|
274
|
-
loader: Loader = Loader(name, externals=(
|
274
|
+
loader: Loader = Loader(name, externals=(extras or {}))
|
275
275
|
|
276
276
|
# NOTE: Validate the config type match with current connection model
|
277
277
|
if loader.type != cls.__name__:
|
@@ -325,16 +325,16 @@ class Schedule(BaseModel):
|
|
325
325
|
start_date: datetime,
|
326
326
|
queue: dict[str, ReleaseQueue],
|
327
327
|
*,
|
328
|
-
|
328
|
+
extras: DictData | None = None,
|
329
329
|
) -> list[WorkflowTask]:
|
330
330
|
"""Return the list of WorkflowTask object from the specific input
|
331
331
|
datetime that mapping with the on field from workflow schedule model.
|
332
332
|
|
333
333
|
:param start_date: A start date that get from the workflow schedule.
|
334
|
-
:param queue: A mapping of name and list of
|
335
|
-
|
336
|
-
:param
|
337
|
-
|
334
|
+
:param queue: (dict[str, ReleaseQueue]) A mapping of name and list of
|
335
|
+
datetime for queue.
|
336
|
+
:param extras: (DictData) An extra parameters that pass to the Loader
|
337
|
+
object.
|
338
338
|
|
339
339
|
:rtype: list[WorkflowTask]
|
340
340
|
:return: Return the list of WorkflowTask object from the specific
|
@@ -348,7 +348,7 @@ class Schedule(BaseModel):
|
|
348
348
|
queue[workflow.alias] = ReleaseQueue()
|
349
349
|
|
350
350
|
workflow_tasks.extend(
|
351
|
-
workflow.tasks(start_date, queue=queue,
|
351
|
+
workflow.tasks(start_date, queue=queue, extras=extras)
|
352
352
|
)
|
353
353
|
|
354
354
|
return workflow_tasks
|
@@ -357,14 +357,14 @@ class Schedule(BaseModel):
|
|
357
357
|
self,
|
358
358
|
*,
|
359
359
|
stop: datetime | None = None,
|
360
|
-
|
360
|
+
extras: DictData | None = None,
|
361
361
|
audit: type[Audit] | None = None,
|
362
362
|
parent_run_id: str | None = None,
|
363
363
|
) -> Result: # pragma: no cov
|
364
364
|
"""Pending this schedule tasks with the schedule package.
|
365
365
|
|
366
366
|
:param stop: A datetime value that use to stop running schedule.
|
367
|
-
:param
|
367
|
+
:param extras: An extra parameters that pass to Loader.
|
368
368
|
:param audit: An audit class that use on the workflow task release for
|
369
369
|
writing its release audit context.
|
370
370
|
:param parent_run_id: A parent workflow running ID for this release.
|
@@ -385,9 +385,7 @@ class Schedule(BaseModel):
|
|
385
385
|
) + timedelta(minutes=1)
|
386
386
|
|
387
387
|
scheduler_pending(
|
388
|
-
tasks=self.tasks(
|
389
|
-
start_date_waiting, queue=queue, externals=externals
|
390
|
-
),
|
388
|
+
tasks=self.tasks(start_date_waiting, queue=queue, extras=extras),
|
391
389
|
stop=stop_date,
|
392
390
|
queue=queue,
|
393
391
|
threads=threads,
|
@@ -709,7 +707,7 @@ def scheduler_pending(
|
|
709
707
|
def schedule_control(
|
710
708
|
schedules: list[str],
|
711
709
|
stop: datetime | None = None,
|
712
|
-
|
710
|
+
extras: DictData | None = None,
|
713
711
|
*,
|
714
712
|
audit: type[Audit] | None = None,
|
715
713
|
parent_run_id: str | None = None,
|
@@ -720,7 +718,7 @@ def schedule_control(
|
|
720
718
|
|
721
719
|
:param schedules: A list of workflow names that want to schedule running.
|
722
720
|
:param stop: A datetime value that use to stop running schedule.
|
723
|
-
:param
|
721
|
+
:param extras: An extra parameters that pass to Loader.
|
724
722
|
:param audit: An audit class that use on the workflow task release for
|
725
723
|
writing its release audit context.
|
726
724
|
:param parent_run_id: A parent workflow running ID for this release.
|
@@ -745,10 +743,10 @@ def schedule_control(
|
|
745
743
|
tasks: list[WorkflowTask] = []
|
746
744
|
for name in schedules:
|
747
745
|
tasks.extend(
|
748
|
-
Schedule.
|
746
|
+
Schedule.from_conf(name, extras=extras).tasks(
|
749
747
|
start_date_waiting,
|
750
748
|
queue=queue,
|
751
|
-
|
749
|
+
extras=extras,
|
752
750
|
),
|
753
751
|
)
|
754
752
|
|