コード例 #1
0
def scope_dbt_rpc_run_and_wait():
    # start_marker_dbt_rpc_run_and_wait
    from dagster import job, op
    from dagster_dbt import dbt_rpc_sync_resource

    my_remote_sync_rpc = dbt_rpc_sync_resource.configured({"host": "80.80.80.80", "port": 8080})

    @op(required_resource_keys={"dbt_sync"})
    def run_staging_models_and_wait(context):
        context.resources.dbt.run(models=["tag:staging"])

    @job(resource_defs={"dbt_sync": my_remote_sync_rpc})
    def my_dbt_job():
        run_staging_models_and_wait()
コード例 #2
0
def test_dbt_rpc_sync_resource_is_waiting(dbt_rpc_server):  # pylint: disable=unused-argument
    @solid(required_resource_keys={"dbt_rpc"})
    def cli_solid(context):
        assert isinstance(context.resources.dbt_rpc, DbtRpcSyncResource)
        out = context.resources.dbt_rpc.cli("run")
        return out

    result = execute_solid(
        cli_solid,
        ModeDefinition(
            resource_defs={"dbt_rpc": dbt_rpc_sync_resource.configured({"host": "localhost"})}
        ),
    )

    assert result.success
    result = result.output_value("result")
    assert isinstance(result, DbtRpcOutput)

    response = result.response_dict.get("result", {})
    assert "elapsed" in response
    assert "request_token" not in response