Changeset View
Changeset View
Standalone View
Standalone View
python_modules/dagster/dagster/core/definitions/schedule.py
from collections import namedtuple | from collections import namedtuple | ||||
from datetime import datetime | from datetime import datetime | ||||
from dagster import check | from dagster import check | ||||
from dagster.core.errors import DagsterInvalidDefinitionError | from dagster.core.errors import DagsterInvalidDefinitionError | ||||
from dagster.core.instance import DagsterInstance | from dagster.core.instance import DagsterInstance | ||||
from dagster.core.storage.pipeline_run import PipelineRun | from dagster.core.storage.pipeline_run import PipelineRun | ||||
from dagster.core.storage.tags import check_tags | from dagster.core.storage.tags import check_tags | ||||
from dagster.utils import merge_dicts | from dagster.utils import merge_dicts | ||||
from .mode import DEFAULT_MODE_NAME | from .mode import DEFAULT_MODE_NAME | ||||
from .utils import check_for_invalid_name_and_warn | from .utils import check_for_invalid_name_and_warn | ||||
class ScheduleExecutionContext( | class ScheduleExecutionContext( | ||||
namedtuple("ScheduleExecutionContext", "instance scheduled_execution_time_utc") | namedtuple("ScheduleExecutionContext", "instance scheduled_execution_time") | ||||
): | ): | ||||
"""Schedule-specific execution context. | """Schedule-specific execution context. | ||||
An instance of this class is made available as the first argument to various ScheduleDefinition | An instance of this class is made available as the first argument to various ScheduleDefinition | ||||
functions. It is passed as the first argument to ``run_config_fn``, ``tags_fn``, | functions. It is passed as the first argument to ``run_config_fn``, ``tags_fn``, | ||||
and ``should_execute``. | and ``should_execute``. | ||||
Attributes: | Attributes: | ||||
instance (DagsterInstance): The instance configured to run the schedule | instance (DagsterInstance): The instance configured to run the schedule | ||||
scheduled_execution_time_utc (datetime): | scheduled_execution_time (datetime): | ||||
The time in UTC in which the execution was scheduled to happen. May differ slightly | The time in which the execution was scheduled to happen. May differ slightly | ||||
from both the actual execution time and the time at which the run config is computed. | from both the actual execution time and the time at which the run config is computed. | ||||
""" | """ | ||||
def __new__( | def __new__( | ||||
cls, instance, scheduled_execution_time_utc, | cls, instance, scheduled_execution_time, | ||||
): | ): | ||||
return super(ScheduleExecutionContext, cls).__new__( | return super(ScheduleExecutionContext, cls).__new__( | ||||
cls, | cls, | ||||
check.inst_param(instance, "instance", DagsterInstance), | check.inst_param(instance, "instance", DagsterInstance), | ||||
check.opt_inst_param( | check.opt_inst_param(scheduled_execution_time, "scheduled_execution_time", datetime), | ||||
scheduled_execution_time_utc, "scheduled_execution_time_utc", datetime | |||||
), | |||||
) | ) | ||||
class ScheduleDefinition(object): | class ScheduleDefinition(object): | ||||
"""Define a schedule that targets a pipeline | """Define a schedule that targets a pipeline | ||||
Args: | Args: | ||||
name (str): The name of the schedule to create. | name (str): The name of the schedule to create. | ||||
▲ Show 20 Lines • Show All 142 Lines • Show Last 20 Lines |