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())
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)
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())
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
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'
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)
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
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
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)
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)
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)
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
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
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)
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, )
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)
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)
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)
def test_create_app(): handle = ExecutionTargetHandle.for_repo_yaml( script_relative_path('./repository.yaml')) assert create_app(handle, DagsterInstance.ephemeral())
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(), )
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())