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 define_subprocess_context_for_file(python_file, fn_name, instance=None): return DagsterGraphQLContext( handle=ExecutionTargetHandle.for_repo_python_file( python_file, fn_name), instance=instance or DagsterInstance.ephemeral(), execution_manager=SubprocessExecutionManager(instance), )
def test_repo_file_dynamic_load(): repository = ExecutionTargetHandle.for_repo_python_file( python_file=script_relative_path('test_handle.py'), fn_name='define_bar_repo').build_repository_definition() assert isinstance(repository, RepositoryDefinition) assert repository.name == 'bar'
def test_repo_file_dynamic_load(): handle = ExecutionTargetHandle.for_repo_python_file( python_file=file_relative_path(__file__, 'test_handle.py'), fn_name='define_bar_repo') 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_build_repository_definition(): handle = ExecutionTargetHandle.for_repo_python_file(__file__, 'define_foo_pipeline') repo = handle.build_repository_definition() assert repo.name == EPHEMERAL_NAME
def define_context_for_file(python_file, fn_name, instance=None): return DagsterGraphQLInProcessRepositoryContext( handle=ExecutionTargetHandle.for_repo_python_file(python_file, fn_name), instance=instance or DagsterInstance.ephemeral(), execution_manager=SynchronousExecutionManager(), )