Esempio n. 1
0
def define_subprocess_context_for_file(python_file, fn_name, instance):
    check.inst_param(instance, 'instance', DagsterInstance)
    return DagsterGraphQLContext(
        locations=[
            InProcessRepositoryLocation(
                ReconstructableRepository.for_file(python_file, fn_name))
        ],
        instance=instance,
    )
Esempio n. 2
0
def get_test_project_external_pipeline(pipeline_name):
    return (
        InProcessRepositoryLocation(
            ReconstructableRepository.for_file(
                file_relative_path(__file__, 'test_project/test_pipelines/test_pipelines/repo.py'),
                'define_demo_execution_repo',
            )
        )
        .get_repository('demo_execution_repo')
        .get_full_external_pipeline(pipeline_name)
    )
Esempio n. 3
0
def test_execute_hammer_through_dagit():
    recon_repo = ReconstructableRepository.for_file(
        file_relative_path(__file__, '../../../../examples/dagster_examples/toys/hammer.py'),
        'hammer_pipeline',
    )
    instance = DagsterInstance.local_temp()

    context = DagsterGraphQLContext(
        locations=[InProcessRepositoryLocation(recon_repo)], instance=instance,
    )

    selector = get_legacy_pipeline_selector(context, 'hammer_pipeline')

    executor = SyncExecutor()

    variables = {
        'executionParams': {
            'runConfigData': {
                'storage': {'filesystem': {}},
                'execution': {'dask': {'config': {'cluster': {'local': {}}}}},
            },
            'selector': selector,
            'mode': 'default',
        }
    }

    start_pipeline_result = graphql(
        request_string=START_PIPELINE_EXECUTION_MUTATION,
        schema=create_schema(),
        context=context,
        variables=variables,
        executor=executor,
    )

    if start_pipeline_result.errors:
        raise Exception('{}'.format(start_pipeline_result.errors))

    run_id = start_pipeline_result.data['startPipelineExecution']['run']['runId']

    context.drain_outstanding_executions()

    subscription = execute_dagster_graphql(context, SUBSCRIPTION_QUERY, variables={'runId': run_id})

    subscribe_results = []
    subscription.subscribe(subscribe_results.append)

    messages = [x['__typename'] for x in subscribe_results[0].data['pipelineRunLogs']['messages']]

    assert 'PipelineStartEvent' in messages
    assert 'PipelineSuccessEvent' in messages
Esempio n. 4
0
def define_test_snapshot_context():
    return DagsterGraphQLContext(
        instance=DagsterInstance.ephemeral(),
        locations=[InProcessRepositoryLocation(create_main_recon_repo())],
    )
Esempio n. 5
0
def get_main_external_repo():
    return InProcessRepositoryLocation(
        ReconstructableRepository.from_legacy_repository_yaml(
            file_relative_path(__file__,
                               'repo.yaml')), ).get_repository('test_repo')
Esempio n. 6
0
 def _mgr_fn(recon_repo):
     check.inst_param(recon_repo, 'recon_repo',
                      ReconstructableRepository)
     yield InProcessRepositoryLocation(recon_repo=recon_repo)
Esempio n. 7
0
def define_context_for_repository_yaml(path, instance):
    check.inst_param(instance, 'instance', DagsterInstance)
    return DagsterGraphQLContext(
        locations=[InProcessRepositoryLocation(ReconstructableRepository.from_yaml(path))],
        instance=instance,
    )