Skip to content

taipy.enterprise.scheduler.scheduled method.ScheduledMethod

Bases: Job

A periodic scheduled method used by Taipy Scheduler. A scheduled method is usually created and returned by the Scheduler.every() method, which also defines its interval.

Attributes:

Name Type Description
interval int

A quantity of a certain time unit.

scheduler Scheduler

The scheduler instance that this scheduled method will register itself with once it has been fully configured in ScheduledMethod.do().

__fix_unexpected_next_run_when_intervel_lt_1(now)

On the schedule._schedule_next_run() method, if the interval is > 1 (for all units), the next run will always be run the first time in the next few days, hours, or minutes.

This is an unexpected behavior, since even if a method is scheduled to run every 2 days, if the time to run can still fit today (now is 12AM, schedule at 3PM), then the first run should be 3PM today, not 3PM 2 days later.

This method fixes that behavior by also checking if the self.interval > 1.

__on_month(date)

Parse the month and day for monthly scheduled methods

__on_year(date)

Parse the month and day for yearly scheduled methods

__replace_negative_day(day)

If the day is a negative number, then get the number of days in the month and subtract the day

at(time, tz=None)

Specify a particular time that the method should be run at.

Parameters:

Name Type Description Default
time Union[str, time, datetime]

The time or date when the method gets invoked.
If a datetime.time or datetime.datetime object:

  • For daily scheduled methods, the hour, minute, and second will be used.
  • For hourly scheduled methods, the minute and second will be used.
  • For minute scheduled methods, only the second will be used.

If a string, it must be in one of the following formats:

  • For daily, monthly, or yearly scheduled methods -> "HH:MM:SS" or "HH:MM"
  • For hourly scheduled methods -> "MM:SS" or ":MM"
  • For minute scheduled methods -> ":SS"
required
tz Optional[str]

The timezone that this timestamp refers to. Can be a string that can be parsed by pytz.timezone(), or a pytz.BaseTzInfo object.

None

do_create_and_submit_scenario(config, creation_date=None, name=None)

Schedule the creation and submission of a scenario.

When triggered, create_scenario() is invoked to create a new scenario, then submit() is executed on the newly created scenario.

Parameters:

Name Type Description Default
config ScenarioConfig

The scenario configuration used to create a new scenario.

required
creation_date Optional[datetime]

The creation date of the scenario. If None, the current date time is used.

None
name Optional[str]

The displayable name of the scenario.

None

do_create_scenario(config, creation_date=None, name=None)

Schedule the create_scenario()^ method.

Parameters:

Name Type Description Default
config ScenarioConfig

The scenario configuration.

required
creation_date Optional[datetime]

The creation date of the scenario. If None, the current date time is used.

None
name Optional[str]

The displayable name of the scenario.

None

do_submit(entity, force=False, wait=False, timeout=None)

Schedule the submit()^ method.

Parameters:

Name Type Description Default
entity Union[Scenario, Sequence, Task]

The scenario, sequence or task entity to submit.

required
force bool

If True, the execution is forced even if for skippable tasks.

False
wait bool

Wait for the orchestrated jobs created from the submission to be finished in asynchronous mode.

False
timeout Union[float, int]

The optional maximum number of seconds to wait for the jobs to be finished before returning.

None

on(date)

Specify a particular date that the method should be run on.

This method applies only to monthly and yearly scheduled methods.

Parameters:

Name Type Description Default
date Union[str, date, datetime]

The date when the method gets invoked.
If this parameter is a datetime.date or a datetime.datetime object:

  • For monthly scheduled methods, only the day will be used.
  • For yearly scheduled methods, the month and day will be used.

If this parameter is a string, it must be in one of the following formats:

  • For monthly scheduled methods -> "DD". The day string can be a number representing the date, or a negative number representing the number of days from the end of the month. For example, -1 represents the last day of the month.
  • For yearly scheduled methods -> "MM DD". The month can be a number representing the month or the name of the month in English (e.g. "January" or "Jan"). The day string can be a number representing the date, or a negative number representing the number of days from the end of the month. For example, -1 represents the last day of the month.
required