コード例 #1
0
def host_dagit_ui(host, port, path_prefix, storage_fallback, port_lookup=True, **kwargs):
    with DagsterInstance.get(storage_fallback) as instance:
        with get_workspace_from_kwargs(kwargs, instance) as workspace:
            if not workspace:
                raise Exception("Unable to load workspace with cli_args: {}".format(kwargs))

            host_dagit_ui_with_workspace(instance, workspace, host, port, path_prefix, port_lookup)
コード例 #2
0
ファイル: cli.py プロジェクト: cy56/dagster
def host_dagit_ui(host, port, storage_fallback, port_lookup=True, **kwargs):
    workspace = get_workspace_from_kwargs(kwargs)
    if not workspace:
        raise Exception(
            'Unable to load workspace with cli_args: {}'.format(kwargs))

    return host_dagit_ui_with_workspace(workspace, host, port,
                                        storage_fallback, port_lookup)
コード例 #3
0
ファイル: test_smoke.py プロジェクト: cy56/dagster
def test_smoke_app():
    flask_app = app.create_app_from_workspace(
        get_workspace_from_kwargs(
            dict(
                module_name='dagster_examples.intro_tutorial.repos',
                definition='hello_cereal_repository',
            )),
        DagsterInstance.ephemeral(),
    )
    client = flask_app.test_client()

    result = client.post(
        '/graphql',
        data={'query': SMOKE_TEST_QUERY},
    )
    data = json.loads(result.data.decode('utf-8'))
    assert len(data['data']['repositoryLocationsOrError']['nodes']) == 1
    assert len(data['data']['repositoryLocationsOrError']['nodes'][0]
               ['repositories']) == 1
    assert (len(data['data']['repositoryLocationsOrError']['nodes'][0]
                ['repositories'][0]['pipelines']) == 2)
    assert {
        node_data['name']
        for node_data in data['data']['repositoryLocationsOrError']['nodes'][0]
        ['repositories'][0]['pipelines']
    } == set(['hello_cereal_pipeline', 'complex_pipeline'])

    result = client.get('/graphql')
    assert result.status_code == 400
    data = json.loads(result.data.decode('utf-8'))
    assert len(data['errors']) == 1
    assert data['errors'][0]['message'] == 'Must provide query string.'

    result = client.get('/dagit/notebook?path=foo.bar')
    assert result.status_code == 400
    assert result.data.decode('utf-8') == 'Invalid Path'

    result = client.post('/graphql',
                         data={'query': 'query { version { slkjd } }'})
    data = json.loads(result.data.decode('utf-8'))
    assert 'errors' in data
    assert len(data['errors']) == 1
    assert 'must not have a sub selection' in data['errors'][0]['message']

    # Missing routes return the index.html file of the Dagit react app, so the user
    # gets our UI when they navigate to "synthetic" react router URLs.
    result = client.get('static/foo/bar')
    assert result.status_code == 200
    assert "You need to enable JavaScript to run this app." in result.data.decode(
        'utf-8')

    result = client.get('pipelines/foo')
    assert result.status_code == 200
    assert "You need to enable JavaScript to run this app." in result.data.decode(
        'utf-8')
コード例 #4
0
def host_dagit_ui(
    host, port, path_prefix, storage_fallback, db_statement_timeout, port_lookup=True, **kwargs
):
    with DagsterInstance.get(storage_fallback) as instance:
        # Allow the instance components to change behavior in the context of a long running server process
        instance.optimize_for_dagit(db_statement_timeout)

        with get_workspace_from_kwargs(kwargs, instance) as workspace:
            if not workspace:
                raise Exception("Unable to load workspace with cli_args: {}".format(kwargs))

            host_dagit_ui_with_workspace(instance, workspace, host, port, path_prefix, port_lookup)
コード例 #5
0
def test_smoke_app(gen_instance):
    with get_workspace_from_kwargs(
            dict(module_name="dagit_tests.toy.bar_repo",
                 definition="bar")) as workspace:

        with gen_instance() as instance:
            flask_app = app.create_app_from_workspace(workspace, instance)
            client = flask_app.test_client()

            result = client.post(
                "/graphql",
                data={"query": SMOKE_TEST_QUERY},
            )
            data = json.loads(result.data.decode("utf-8"))
            assert len(data["data"]["repositoriesOrError"]["nodes"]) == 1
            assert len(data["data"]["repositoriesOrError"]["nodes"][0]
                       ["pipelines"]) == 2
            assert {
                node_data["name"]
                for node_data in data["data"]["repositoriesOrError"]["nodes"]
                [0]["pipelines"]
            } == set(["foo", "baz"])

            result = client.get("/graphql")
            assert result.status_code == 400
            data = json.loads(result.data.decode("utf-8"))
            assert len(data["errors"]) == 1
            assert data["errors"][0]["message"] == "Must provide query string."

            result = client.get("/dagit/notebook?path=foo.bar")
            assert result.status_code == 400
            assert result.data.decode("utf-8") == "Invalid Path"

            result = client.post("/graphql",
                                 data={"query": "query { version { slkjd } }"})
            data = json.loads(result.data.decode("utf-8"))
            assert "errors" in data
            assert len(data["errors"]) == 1
            assert "must not have a sub selection" in data["errors"][0][
                "message"]

            # Missing routes return the index.html file of the Dagit react app, so the user
            # gets our UI when they navigate to "synthetic" react router URLs.
            result = client.get("static/foo/bar")
            assert result.status_code == 200
            assert "You need to enable JavaScript to run this app." in result.data.decode(
                "utf-8")

            result = client.get("pipelines/foo")
            assert result.status_code == 200
            assert "You need to enable JavaScript to run this app." in result.data.decode(
                "utf-8")
コード例 #6
0
def host_dagit_ui(host,
                  port,
                  path_prefix,
                  storage_fallback,
                  port_lookup=True,
                  **kwargs):

    instance = DagsterInstance.get(storage_fallback)

    workspace = get_workspace_from_kwargs(kwargs, instance)
    if not workspace:
        raise Exception(
            'Unable to load workspace with cli_args: {}'.format(kwargs))

    return host_dagit_ui_with_workspace(instance, workspace, host, port,
                                        path_prefix, port_lookup)
コード例 #7
0
ファイル: test_cli_invocations.py プロジェクト: yuhan/dagster
def load_dagit_for_workspace_cli_args(n_pipelines=1, **kwargs):
    instance = DagsterInstance.ephemeral()
    with get_workspace_from_kwargs(kwargs, instance) as workspace:
        app = create_app_from_workspace(workspace, instance)

        client = app.test_client()

        res = client.get("/graphql?query={query_string}".format(
            query_string=PIPELINES_OR_ERROR_QUERY))
        json_res = json.loads(res.data.decode("utf-8"))
        assert "data" in json_res
        assert "repositoriesOrError" in json_res["data"]
        assert "nodes" in json_res["data"]["repositoriesOrError"]
        assert len(json_res["data"]["repositoriesOrError"]["nodes"][0]
                   ["pipelines"]) == n_pipelines

    return res
コード例 #8
0
def load_dagit_for_workspace_cli_args(n_pipelines=1, **kwargs):
    instance = DagsterInstance.ephemeral()
    workspace = get_workspace_from_kwargs(kwargs, instance)
    app = create_app_from_workspace(workspace, instance)

    client = app.test_client()

    res = client.get('/graphql?query={query_string}'.format(
        query_string=PIPELINES_OR_ERROR_QUERY))
    json_res = json.loads(res.data.decode('utf-8'))
    assert 'data' in json_res
    assert 'repositoriesOrError' in json_res['data']
    assert 'nodes' in json_res['data']['repositoriesOrError']
    assert len(json_res['data']['repositoriesOrError']['nodes'][0]
               ['pipelines']) == n_pipelines

    return res
コード例 #9
0
ファイル: test_graphql.py プロジェクト: nidhalrahali/dagster
def test_execute_hammer_through_dagit():
    with instance_for_test() as instance:
        with get_workspace_from_kwargs({
                "python_file":
                file_relative_path(
                    __file__,
                    "../../../dagster-test/dagster_test/toys/hammer.py"),
                "attribute":
                "hammer_pipeline",
        }) as workspace:
            context = ProcessContext(
                workspace=workspace,
                instance=instance,
            ).create_request_context()
            selector = infer_pipeline_selector(context, "hammer_pipeline")
            executor = SyncExecutor()

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

            start_pipeline_result = graphql(
                request_string=LAUNCH_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["launchPipelineExecution"][
                "run"]["runId"]

            context.instance.run_launcher.join(timeout=60)

            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