def get_external_schedule_execution(external_schedule_execution_args): check.inst_param( external_schedule_execution_args, 'external_schedule_execution_args', ExternalScheduleExecutionArgs, ) recon_repo = recon_repository_from_origin( external_schedule_execution_args.repository_origin) definition = recon_repo.get_definition() schedule_def = definition.get_schedule_def( external_schedule_execution_args.schedule_name) instance = DagsterInstance.from_ref( external_schedule_execution_args.instance_ref) schedule_context = ScheduleExecutionContext(instance) try: with user_code_error_boundary( ScheduleExecutionError, lambda: 'Error occurred during the execution of run_config_fn for schedule ' '{schedule_name}'.format(schedule_name=schedule_def.name), ): run_config = schedule_def.get_run_config(schedule_context) return ExternalScheduleExecutionData(run_config=run_config) except ScheduleExecutionError: return ExternalScheduleExecutionErrorData( serializable_error_info_from_exc_info(sys.exc_info()))
def get_external_schedule_execution( recon_repo, instance_ref, schedule_name, scheduled_execution_timestamp, scheduled_execution_timezone, ): check.inst_param( recon_repo, "recon_repo", ReconstructableRepository, ) definition = recon_repo.get_definition() schedule_def = definition.get_schedule_def(schedule_name) scheduled_execution_time = (pendulum.from_timestamp( scheduled_execution_timestamp, tz=scheduled_execution_timezone, ) if scheduled_execution_timestamp else None) schedule_context = ScheduleExecutionContext(instance_ref, scheduled_execution_time) try: with user_code_error_boundary( ScheduleExecutionError, lambda: "Error occurred during the execution function for schedule " "{schedule_name}".format(schedule_name=schedule_def.name), ): return ExternalScheduleExecutionData.from_execution_data( schedule_def.get_execution_data(schedule_context)) except ScheduleExecutionError: return ExternalScheduleExecutionErrorData( serializable_error_info_from_exc_info(sys.exc_info()))
def get_external_schedule_execution(recon_repo, external_schedule_execution_args): check.inst_param( recon_repo, "recon_repo", ReconstructableRepository, ) check.inst_param( external_schedule_execution_args, "external_schedule_execution_args", ExternalScheduleExecutionArgs, ) definition = recon_repo.get_definition() schedule_def = definition.get_schedule_def( external_schedule_execution_args.schedule_name) with DagsterInstance.from_ref( external_schedule_execution_args.instance_ref) as instance: schedule_context = ScheduleExecutionContext(instance) schedule_execution_data_mode = external_schedule_execution_args.schedule_execution_data_mode try: with user_code_error_boundary( ScheduleExecutionError, lambda: "Error occurred during the execution of should_execute for schedule " "{schedule_name}".format(schedule_name=schedule_def.name), ): should_execute = None if (schedule_execution_data_mode == ScheduleExecutionDataMode.LAUNCH_SCHEDULED_EXECUTION): should_execute = schedule_def.should_execute( schedule_context) if not should_execute: return ExternalScheduleExecutionData( should_execute=False, run_config=None, tags=None) with user_code_error_boundary( ScheduleExecutionError, lambda: "Error occurred during the execution of run_config_fn for schedule " "{schedule_name}".format(schedule_name=schedule_def.name), ): run_config = schedule_def.get_run_config(schedule_context) with user_code_error_boundary( ScheduleExecutionError, lambda: "Error occurred during the execution of tags_fn for schedule " "{schedule_name}".format(schedule_name=schedule_def.name), ): tags = schedule_def.get_tags(schedule_context) return ExternalScheduleExecutionData(run_config=run_config, tags=tags, should_execute=should_execute) except ScheduleExecutionError: return ExternalScheduleExecutionErrorData( serializable_error_info_from_exc_info(sys.exc_info()))
def get_external_schedule_execution( recon_repo, instance_ref, schedule_name, scheduled_execution_timestamp, scheduled_execution_timezone, ): check.inst_param( recon_repo, "recon_repo", ReconstructableRepository, ) definition = recon_repo.get_definition() schedule_def = definition.get_schedule_def(schedule_name) with DagsterInstance.from_ref(instance_ref) as instance: scheduled_execution_time = (pendulum.from_timestamp( scheduled_execution_timestamp, tz=scheduled_execution_timezone, ) if scheduled_execution_timestamp else None) schedule_context = ScheduleExecutionContext(instance, scheduled_execution_time) try: with user_code_error_boundary( ScheduleExecutionError, lambda: "Error occurred during the execution of should_execute for schedule " "{schedule_name}".format(schedule_name=schedule_def.name), ): if not schedule_def.should_execute(schedule_context): return ExternalScheduleExecutionData(should_execute=False, run_config=None, tags=None) with user_code_error_boundary( ScheduleExecutionError, lambda: "Error occurred during the execution of run_config_fn for schedule " "{schedule_name}".format(schedule_name=schedule_def.name), ): run_config = schedule_def.get_run_config(schedule_context) with user_code_error_boundary( ScheduleExecutionError, lambda: "Error occurred during the execution of tags_fn for schedule " "{schedule_name}".format(schedule_name=schedule_def.name), ): tags = schedule_def.get_tags(schedule_context) return ExternalScheduleExecutionData(run_config=run_config, tags=tags, should_execute=True) except ScheduleExecutionError: return ExternalScheduleExecutionErrorData( serializable_error_info_from_exc_info(sys.exc_info()))