示例#1
0
def test_create_app_with_active_repo_data():
    handle = ExecutionTargetHandle.for_repo_yaml(
        file_relative_path(__file__, './repository.yaml'))
    active_repository_data = active_repository_data_from_def(
        handle.build_repository_definition())
    assert create_app_with_active_repository_data(active_repository_data,
                                                  DagsterInstance.ephemeral())
示例#2
0
def test_create_app():
    handle = ExecutionTargetHandle.for_repo_yaml(
        script_relative_path('./repository.yaml'))
    pipeline_run_storage = InMemoryRunStorage()
    assert create_app(handle,
                      pipeline_run_storage,
                      use_synchronous_execution_manager=True)
示例#3
0
def test_create_app_with_snapshot():
    handle = ExecutionTargetHandle.for_repo_yaml(
        file_relative_path(__file__, './repository.yaml'))
    repository_snapshot = RepositorySnapshot.from_repository_definition(
        handle.build_repository_definition())
    assert create_app_with_snapshot(repository_snapshot,
                                    DagsterInstance.ephemeral())
示例#4
0
def test_repo_entrypoints():
    module = importlib.import_module('dagster_examples.intro_tutorial.repos')

    expected = LoaderEntrypoint(module, 'dagster_examples.intro_tutorial.repos', 'define_repo')
    handle = ExecutionTargetHandle.for_repo_yaml(script_relative_path('repository.yaml'))
    assert handle.entrypoint.module == expected.module
    assert handle.entrypoint.module_name == expected.module_name
    assert handle.entrypoint.fn_name == expected.fn_name
    assert handle.entrypoint.from_handle == handle

    module = importlib.import_module('dagster')
    expected = LoaderEntrypoint(module, 'dagster', 'define_bar_repo')
    handle = ExecutionTargetHandle.for_repo_module(module_name='dagster', fn_name='define_bar_repo')
    assert handle.entrypoint.module == expected.module
    assert handle.entrypoint.module_name == expected.module_name
    assert handle.entrypoint.fn_name == expected.fn_name
    assert handle.entrypoint.from_handle == handle

    python_file = script_relative_path('bar_repo.py')
    module = imp.load_source('bar_repo', python_file)

    expected = LoaderEntrypoint(module, 'bar_repo', 'define_bar_repo')
    handle = ExecutionTargetHandle.for_repo_python_file(
        python_file=python_file, fn_name='define_bar_repo'
    )
    assert handle.entrypoint.module == expected.module
    assert handle.entrypoint.module_name == expected.module_name
    assert handle.entrypoint.fn_name == expected.fn_name
    assert handle.entrypoint.from_handle == handle
示例#5
0
def test_repo_yaml_file_dynamic_load():
    repository = ExecutionTargetHandle.for_repo_yaml(
        repository_yaml=script_relative_path(
            'repository_file.yaml')).build_repository_definition()

    assert isinstance(repository, RepositoryDefinition)
    assert repository.name == 'bar'
示例#6
0
def test_repo_yaml_module_dynamic_load():
    handle = ExecutionTargetHandle.for_repo_yaml(
        repository_yaml=script_relative_path('repository_module.yaml'))
    repository = handle.build_repository_definition()

    assert isinstance(repository, RepositoryDefinition)
    assert repository.name == 'demo_repository'
    assert ExecutionTargetHandle.get_handle(repository) == (handle, None)
示例#7
0
def test_index_view():
    with create_app(
        ExecutionTargetHandle.for_repo_yaml(script_relative_path('./repository.yaml')),
        PipelineRunStorage(),
    ).test_client() as client:
        res = client.get('/')

    assert res.status_code == 200, res.data
    assert b'You need to enable JavaScript to run this app' in res.data
示例#8
0
def test_index_view():
    with create_app(
        ExecutionTargetHandle.for_repo_yaml(file_relative_path(__file__, './repository.yaml')),
        DagsterInstance.ephemeral(),
    ).test_client() as client:
        res = client.get('/')

    assert res.status_code == 200, res.data
    assert b'You need to enable JavaScript to run this app' in res.data
示例#9
0
def test_repo_yaml_file_dynamic_load():
    handle = ExecutionTargetHandle.for_repo_yaml(
        repository_yaml=file_relative_path(__file__, 'repository_file.yaml'))
    handle = ExecutionTargetHandle.from_dict(handle.to_dict())
    repository = handle.build_repository_definition()

    assert isinstance(repository, RepositoryDefinition)
    assert repository.name == 'bar'
    assert ExecutionTargetHandle.get_handle(repository) == (handle, None)
示例#10
0
def test_successful_host_dagit_ui():
    with mock.patch('gevent.pywsgi.WSGIServer'), seven.TemporaryDirectory(
    ) as temp_dir:
        handle = ExecutionTargetHandle.for_repo_yaml(
            file_relative_path(__file__, './repository.yaml'))
        host_dagit_ui_with_execution_handle(storage_fallback=temp_dir,
                                            handle=handle,
                                            host=None,
                                            port=2343)
示例#11
0
def test_port_collision():
    def _raise_os_error():
        raise OSError('Address already in use')

    with mock.patch('gevent.pywsgi.WSGIServer',
                    new=_define_mock_server(_raise_os_error)):
        handle = ExecutionTargetHandle.for_repo_yaml(
            script_relative_path('./repository.yaml'))
        with pytest.raises(Exception) as exc_info:
            host_dagit_ui(handle=handle, host=None, port=2343)

        assert 'Another process ' in str(exc_info.value)
示例#12
0
def test_notebook_view():
    notebook_path = script_relative_path('render_uuid_notebook.ipynb')

    with create_app(
        ExecutionTargetHandle.for_repo_yaml(script_relative_path('./repository.yaml')),
        PipelineRunStorage(),
    ).test_client() as client:
        res = client.get('/dagit/notebook?path={}'.format(notebook_path))

    assert res.status_code == 200
    # This magic guid is hardcoded in the notebook
    assert b'6cac0c38-2c97-49ca-887c-4ac43f141213' in res.data
示例#13
0
def test_notebook_view():
    notebook_path = file_relative_path(__file__, 'render_uuid_notebook.ipynb')

    with create_app(
        ExecutionTargetHandle.for_repo_yaml(file_relative_path(__file__, './repository.yaml')),
        DagsterInstance.ephemeral(),
    ).test_client() as client:
        res = client.get('/dagit/notebook?path={}'.format(notebook_path))

    assert res.status_code == 200
    # This magic guid is hardcoded in the notebook
    assert b'6cac0c38-2c97-49ca-887c-4ac43f141213' in res.data
示例#14
0
def test_unknown_error():
    class AnException(Exception):
        pass

    def _raise_custom_error():
        raise AnException('foobar')

    with mock.patch('gevent.pywsgi.WSGIServer',
                    new=_define_mock_server(_raise_custom_error)):
        handle = ExecutionTargetHandle.for_repo_yaml(
            script_relative_path('./repository.yaml'))
        with pytest.raises(AnException):
            host_dagit_ui(handle=handle, host=None, port=2343)
示例#15
0
def test_successful_host_dagit_ui():
    with mock.patch('gevent.pywsgi.WSGIServer'):
        handle = ExecutionTargetHandle.for_repo_yaml(
            script_relative_path('./repository.yaml'))
        host_dagit_ui(
            log=False,
            log_dir=None,
            schedule_dir=None,
            handle=handle,
            use_sync=True,
            host=None,
            port=2343,
        )
示例#16
0
def test_unknown_error():
    class AnException(Exception):
        pass

    def _raise_custom_error():
        raise AnException('foobar')

    with mock.patch(
        'gevent.pywsgi.WSGIServer', new=_define_mock_server(_raise_custom_error)
    ), seven.TemporaryDirectory() as temp_dir:
        handle = ExecutionTargetHandle.for_repo_yaml(
            file_relative_path(__file__, './repository.yaml')
        )
        with pytest.raises(AnException):
            host_dagit_ui(storage_fallback=temp_dir, handle=handle, host=None, port=2343)
示例#17
0
def test_port_collision():
    def _raise_os_error():
        raise OSError('Address already in use')

    with mock.patch(
        'gevent.pywsgi.WSGIServer', new=_define_mock_server(_raise_os_error)
    ), seven.TemporaryDirectory() as temp_dir:
        handle = ExecutionTargetHandle.for_repo_yaml(
            file_relative_path(__file__, './repository.yaml')
        )
        with pytest.raises(Exception) as exc_info:
            host_dagit_ui(
                storage_fallback=temp_dir, handle=handle, host=None, port=2343, port_lookup=False
            )

        assert 'another instance of dagit ' in str(exc_info.value)
示例#18
0
def test_successful_host_dagit_ui():
    with mock.patch('gevent.pywsgi.WSGIServer'):
        handle = ExecutionTargetHandle.for_repo_yaml(
            script_relative_path('./repository.yaml'))
        host_dagit_ui(handle=handle, host=None, port=2343)
示例#19
0
def test_create_app():
    handle = ExecutionTargetHandle.for_repo_yaml(
        script_relative_path('./repository.yaml'))
    assert create_app(handle, DagsterInstance.ephemeral())
示例#20
0
文件: setup.py 项目: xhochy/dagster
def define_context_for_repository_yaml(path, instance=None):
    return DagsterGraphQLContext(
        handle=ExecutionTargetHandle.for_repo_yaml(path),
        instance=instance or DagsterInstance.ephemeral(),
        execution_manager=SynchronousExecutionManager(),
    )
示例#21
0
def test_create_app_with_execution_handle():
    handle = ExecutionTargetHandle.for_repo_yaml(
        file_relative_path(__file__, './repository.yaml'))
    assert create_app_with_execution_handle(handle,
                                            DagsterInstance.ephemeral())