def define_context(raise_on_error=True, log_dir=None): return DagsterGraphQLContext( handle=ExecutionTargetHandle.for_repo_fn(define_repository), pipeline_runs=PipelineRunStorage(log_dir), execution_manager=SynchronousExecutionManager(), raise_on_error=raise_on_error, )
def test_for_repo_fn_with_pipeline_name(): handle = ExecutionTargetHandle.for_repo_fn(define_bar_repo) handle = ExecutionTargetHandle.from_dict(handle.to_dict()) repo = handle.build_repository_definition() assert repo.name == 'bar' with pytest.raises(DagsterInvariantViolationError) as exc_info: handle.build_pipeline_definition() assert ( str(exc_info.value) == 'Cannot construct a pipeline from a repository-based ' 'ExecutionTargetHandle without a pipeline name. Use with_pipeline_name() to construct a ' 'pipeline ExecutionTargetHandle.') handle_for_pipeline = handle.with_pipeline_name('foo_pipeline') repo = handle_for_pipeline.build_repository_definition() assert repo.name == 'bar' pipe = handle_for_pipeline.build_pipeline_definition() assert pipe.name == 'foo_pipeline' handle_double = handle_for_pipeline.with_pipeline_name('foo_pipeline') pipe = handle_double.build_pipeline_definition() assert pipe.name == 'foo_pipeline'
def define_context(raise_on_error=True, instance=None): return DagsterGraphQLContext( handle=ExecutionTargetHandle.for_repo_fn(define_repository), instance=instance or DagsterInstance.ephemeral(), execution_manager=SynchronousExecutionManager(), raise_on_error=raise_on_error, )
def test_pipelines_python_error(): ctx = DagsterGraphQLContext( handle=ExecutionTargetHandle.for_repo_fn(define_error_pipeline_repo), pipeline_runs=InMemoryRunStorage(), execution_manager=SynchronousExecutionManager(), ) result = execute_dagster_graphql(ctx, PIPELINES) assert result.data['pipelinesOrError']['__typename'] == "PythonError"
def define_context(raise_on_error=True, log_dir=None, schedule_dir=None): return DagsterGraphQLContext( handle=ExecutionTargetHandle.for_repo_fn(define_repository), pipeline_runs=FilesystemRunStorage(base_dir=log_dir) if log_dir else InMemoryRunStorage(), scheduler=TestSystemCronScheduler(schedule_dir) if schedule_dir else None, execution_manager=SynchronousExecutionManager(), raise_on_error=raise_on_error, )
def test_pipelines_or_error_invalid(): context = DagsterGraphQLContext( handle=ExecutionTargetHandle.for_repo_fn(define_test_repository), instance=DagsterInstance.ephemeral(), execution_manager=SynchronousExecutionManager(), ) result = execute_dagster_graphql( context, '{ pipelinesOrError { ... on PythonError { message } } }') msg = result.data['pipelinesOrError']['message'] assert 'circular reference detected in solid "csolid"' in msg
def test_pipelines_or_error_invalid(): context = DagsterGraphQLContext( handle=ExecutionTargetHandle.for_repo_fn(define_test_repository), pipeline_runs=PipelineRunStorage(), execution_manager=SynchronousExecutionManager(), ) result = execute_dagster_graphql( context, '{ pipelinesOrError { ... on InvalidDefinitionError { message } } }' ) msg = result.data['pipelinesOrError']['message'] assert "Circular reference detected in solid csolid" in msg
def test_bad_modes(): handle = ExecutionTargetHandle.for_repo_fn( define_bar_repo).with_pipeline_name('foo_pipeline') handle.mode = 'not a mode' with pytest.raises(check.CheckError) as exc_info: handle.entrypoint() assert str( exc_info.value) == 'Failure condition: Unhandled mode not a mode' with pytest.raises(check.CheckError) as exc_info: handle.build_pipeline_definition() assert str( exc_info.value) == 'Failure condition: Unhandled mode not a mode'
def define_subprocess_context(instance): return DagsterGraphQLContext( handle=ExecutionTargetHandle.for_repo_fn(define_repository), instance=instance, execution_manager=SubprocessExecutionManager(instance), )
def define_context(repo_fn, instance=None): return DagsterGraphQLContext( handle=ExecutionTargetHandle.for_repo_fn(repo_fn), instance=instance or DagsterInstance.ephemeral(), execution_manager=SynchronousExecutionManager(), )