예제 #1
0
def test_manual_instance():
    defn = PipelineDefinition([the_solid], "test")
    with pytest.raises(
            DagsterInvariantViolationError,
            match=
            "Reconstructable target should be a function or definition produced by a decorated function",
    ):
        reconstructable(defn)
예제 #2
0
def test_bad_target():
    with pytest.raises(
            DagsterInvariantViolationError,
            match=re.escape(
                "Loadable attributes must be either a JobDefinition, GraphDefinition, PipelineDefinition, "
                "AssetGroup, or RepositoryDefinition. Got None."),
    ):
        reconstructable(not_the_pipeline)
예제 #3
0
def test_not_defined_in_module(mocker):
    mocker.patch("inspect.getmodule",
                 return_value=types.ModuleType("__main__"))
    with pytest.raises(
            DagsterInvariantViolationError,
            match=re.escape(
                "reconstructable() can not reconstruct jobs or pipelines defined in interactive environments"
            ),
    ):
        reconstructable(get_the_pipeline)
예제 #4
0
def test_reconstructable_module():
    original_sys_path = sys.path
    try:
        sys.path.insert(0, file_relative_path(__file__, "."))
        from foo import bar_pipeline  # pylint: disable=import-error

        reconstructable(bar_pipeline)

    finally:
        sys.path = original_sys_path
예제 #5
0
def test_inner_scope():
    def get_the_pipeline_inner():
        return the_pipeline

    with pytest.raises(
            DagsterInvariantViolationError,
            match=
            "Use a function or decorated function defined at module scope",
    ):
        reconstructable(get_the_pipeline_inner)
예제 #6
0
def test_inner_decorator():
    @pipeline
    def pipe():
        the_solid()

    with pytest.raises(
            DagsterInvariantViolationError,
            match=
            "Use a function or decorated function defined at module scope",
    ):
        reconstructable(pipe)
예제 #7
0
def test_solid_selection():
    recon_pipe = reconstructable(get_the_pipeline)
    sub_pipe_full = recon_pipe.subset_for_execution(["the_solid"])
    assert sub_pipe_full.solids_to_execute == {"the_solid"}

    sub_pipe_unresolved = recon_pipe.subset_for_execution(["the_solid+"])
    assert sub_pipe_unresolved.solids_to_execute == {"the_solid"}
예제 #8
0
def test_step_handler_context():
    recon_pipeline = reconstructable(foo_pipline)
    with instance_for_test() as instance:
        run = create_run_for_test(instance)

        args = ExecuteStepArgs(
            pipeline_origin=recon_pipeline.get_python_origin(),
            pipeline_run_id=run.run_id,
            step_keys_to_execute=run.step_keys_to_execute,
            instance_ref=None,
        )
        ctx = StepHandlerContext(
            instance=instance,
            execute_step_args=args,
            step_tags={},
            pipeline_run=run,
        )

        assert ctx.execute_step_args == args
        assert ctx.pipeline_run == run
예제 #9
0
def test_args_fails():
    with pytest.raises(
            DagsterInvariantViolationError,
            match="Reconstructable target must be callable with no arguments",
    ):
        reconstructable(get_with_args)
예제 #10
0
def test_lambda():
    with pytest.raises(DagsterInvariantViolationError,
                       match="Reconstructable target can not be a lambda"):
        reconstructable(lambda_version)
예제 #11
0
def test_decorator():
    recon_pipe = reconstructable(the_pipeline)
    assert pid(recon_pipe.get_definition()) == pid(the_pipeline)
예제 #12
0
def test_function():
    recon_pipe = reconstructable(get_the_pipeline)
    assert pid(recon_pipe.get_definition()) == pid(the_pipeline)