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.
@@ -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 use
90
- for override the on field if the schedule time was change but you do not
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
- externals: DictData | None = None,
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 externals: An external parameters that pass to the Loader object.
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 = externals or {}
197
+ extras: DictData = extras or {}
198
198
 
199
199
  # NOTE: Loading workflow model from the name of workflow.
200
- wf: Workflow = Workflow.from_loader(self.name, externals=extras)
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 from_loader(
257
+ def from_conf(
258
258
  cls,
259
259
  name: str,
260
- externals: DictData | None = None,
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 externals: An external parameters that want to pass to Loader
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=(externals or {}))
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
- externals: DictData | None = None,
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 datetime for queue.
335
- :type queue: dict[str, ReleaseQueue]
336
- :param externals: An external parameters that pass to the Loader object.
337
- :type externals: DictData | None
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, externals=externals)
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
- externals: DictData | None = None,
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 externals: An external parameters that pass to Loader.
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
- externals: DictData | None = None,
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 externals: An external parameters that pass to Loader.
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.from_loader(name, externals=externals).tasks(
746
+ Schedule.from_conf(name, extras=extras).tasks(
749
747
  start_date_waiting,
750
748
  queue=queue,
751
- externals=externals,
749
+ extras=extras,
752
750
  ),
753
751
  )
754
752