Beispiel #1
0
def get_external_job_params(recon_repo, instance_ref, name):
    check.inst_param(recon_repo, "recon_repo", ReconstructableRepository)
    check.inst_param(instance_ref, "instance_ref", InstanceRef)
    check.str_param(name, "name")
    definition = recon_repo.get_definition()
    job_def = definition.get_job_def(name)
    with DagsterInstance.from_ref(instance_ref) as instance:
        context = JobContext(instance)

        try:
            with user_code_error_boundary(
                    JobError,
                    lambda:
                    "Error occured during the execution of run_config_fn for triggered "
                    "execution {name}".format(name=job_def.name),
            ):
                run_config = job_def.get_run_config(context)

            with user_code_error_boundary(
                    JobError,
                    lambda:
                    "Error occured during the execution of tags_fn for triggered "
                    "execution {name}".format(name=job_def.name),
            ):
                tags = job_def.get_tags(context)

            return ExternalExecutionParamsData(run_config=run_config,
                                               tags=tags)
        except JobError:
            return ExternalExecutionParamsErrorData(
                serializable_error_info_from_exc_info(sys.exc_info()))
Beispiel #2
0
def get_external_triggered_execution_params(recon_repo,
                                            external_triggered_execution_args):
    check.inst_param(recon_repo, "recon_repo", ReconstructableRepository)
    check.inst_param(
        external_triggered_execution_args,
        "external_triggered_execution_args",
        ExternalTriggeredExecutionArgs,
    )
    definition = recon_repo.get_definition()
    triggered_execution_def = definition.get_triggered_execution_def(
        external_triggered_execution_args.trigger_name)
    with DagsterInstance.from_ref(
            external_triggered_execution_args.instance_ref) as instance:
        context = TriggeredExecutionContext(instance)

        try:
            with user_code_error_boundary(
                    TriggeredExecutionError,
                    lambda:
                    "Error occured during the execution of should_execute_fn for triggered "
                    "execution {name}".format(name=triggered_execution_def.name
                                              ),
            ):
                should_execute = triggered_execution_def.should_execute(
                    context)
                if not should_execute:
                    return ExternalExecutionParamsData(run_config=None,
                                                       tags=None,
                                                       should_execute=False)

            with user_code_error_boundary(
                    TriggeredExecutionError,
                    lambda:
                    "Error occured during the execution of run_config_fn for triggered "
                    "execution {name}".format(name=triggered_execution_def.name
                                              ),
            ):
                run_config = triggered_execution_def.get_run_config(context)

            with user_code_error_boundary(
                    TriggeredExecutionError,
                    lambda:
                    "Error occured during the execution of tags_fn for triggered "
                    "execution {name}".format(name=triggered_execution_def.name
                                              ),
            ):
                tags = triggered_execution_def.get_tags(context)

            return ExternalExecutionParamsData(run_config=run_config,
                                               tags=tags,
                                               should_execute=should_execute)
        except TriggeredExecutionError:
            return ExternalExecutionParamsErrorData(
                serializable_error_info_from_exc_info(sys.exc_info()))
Beispiel #3
0
def get_external_executable_params(recon_repo, external_executable_args):
    check.inst_param(recon_repo, "recon_repo", ReconstructableRepository)
    check.inst_param(
        external_executable_args,
        "external_executable_args",
        ExternalExecutableArgs,
    )
    definition = recon_repo.get_definition()
    executable_def = definition.get_executable_def(
        external_executable_args.name)
    with DagsterInstance.from_ref(
            external_executable_args.instance_ref) as instance:
        context = ExecutableContext(instance)

        try:
            with user_code_error_boundary(
                    ExecutableError,
                    lambda:
                    "Error occured during the execution of run_config_fn for triggered "
                    "execution {name}".format(name=executable_def.name),
            ):
                run_config = executable_def.get_run_config(context)

            with user_code_error_boundary(
                    ExecutableError,
                    lambda:
                    "Error occured during the execution of tags_fn for triggered "
                    "execution {name}".format(name=executable_def.name),
            ):
                tags = executable_def.get_tags(context)

            return ExternalExecutionParamsData(run_config=run_config,
                                               tags=tags)
        except ExecutableError:
            return ExternalExecutionParamsErrorData(
                serializable_error_info_from_exc_info(sys.exc_info()))