예제 #1
0
def in_pipeline_manager(pipeline_name='hello_world_pipeline',
                        solid_handle=SolidHandle('hello_world', 'hello_world',
                                                 None),
                        **kwargs):
    manager = Manager()

    run_id = str(uuid.uuid4())

    marshal_dir = tempfile.mkdtemp()

    handle = handle_for_pipeline_cli_args({
        'pipeline_name':
        pipeline_name,
        'module_name':
        'dagstermill.examples.repository',
        'fn_name':
        'define_hello_world_pipeline',
    })

    try:
        with tempfile.NamedTemporaryFile() as output_log_file:
            context_dict = {
                'run_config': RunConfig(run_id=run_id, mode='default'),
                'solid_handle': solid_handle,
                'handle': handle,
                'marshal_dir': marshal_dir,
                'environment_dict': {},
                'output_log_path': output_log_file.name,
            }

            manager.reconstitute_pipeline_context(
                **dict(context_dict, **kwargs))
            yield manager
    finally:
        shutil.rmtree(marshal_dir)
예제 #2
0
def test_yield_unserializable_result():
    manager = Manager()
    assert manager.yield_result(threading.Lock())

    with in_pipeline_manager(
            solid_handle=SolidHandle('hello_world_output',
                                     'hello_world_output', None),
            handle=handle_for_pipeline_cli_args({
                'module_name':
                'dagstermill.examples.repository',
                'fn_name':
                'define_hello_world_with_output_pipeline',
            }),
    ) as manager:
        with pytest.raises(TypeError):
            manager.yield_result(threading.Lock())
예제 #3
0
def in_pipeline_manager(register=True, **kwargs):
    repository_def = define_example_repository()

    manager = Manager()

    if register:
        manager.register_repository(repository_def)

    run_id = str(uuid.uuid4())

    marshal_dir = tempfile.mkdtemp()

    try:
        with tempfile.NamedTemporaryFile() as output_log_file:
            context_dict = dict(
                {
                    'run_id': run_id,
                    'mode': 'default',
                    'solid_def_name': 'hello_world',
                    'pipeline_name': 'hello_world_pipeline',
                    'marshal_dir': marshal_dir,
                    'environment_config': {},
                    'output_log_path': output_log_file.name,
                    'input_name_type_dict': {},
                    'output_name_type_dict': {},
                },
                **kwargs
            )
            manager.populate_context(**context_dict)
            yield manager
    finally:
        shutil.rmtree(marshal_dir)
예제 #4
0
def test_out_of_pipeline_manager_yield_materialization():
    manager = Manager()
    assert manager.yield_event(
        Materialization.file('/path/to/artifact', 'artifact')
    ) == Materialization.file('/path/to/artifact', 'artifact')
예제 #5
0
def test_out_of_pipeline_manager_yield_complex_result():
    class Foo:
        pass

    manager = Manager()
    assert isinstance(manager.yield_result(Foo()), Foo)
예제 #6
0
def test_out_of_pipeline_manager_yield_result():
    manager = Manager()
    assert manager.yield_result('foo') == 'foo'
예제 #7
0
def test_out_of_pipeline_yield_event():
    manager = Manager()
    assert manager.yield_event('foo') == 'foo'