在 Dagster 的 GraphQL API 中 运行 ExecutePipeline 时 $repositoryLocationName 的值是多少?

What is the value of $repositoryLocationName when running ExecutePipeline in Dagster's GraphQL API?

我正在尝试使用 GraphQL API 启动 Dagster 管道 运行。我在本地有 Dagit 运行ning 和一个可以通过操场触发的工作管道。

但是,我现在正尝试通过 GraphQL Playground 触发管道,可在 /graphql.

我正在使用以下突变:

mutation ExecutePipeline(
  $repositoryLocationName: String!
  $repositoryName: String!
  $pipelineName: String!
  $runConfigData: RunConfigData!
  $mode: String!
)

...因此我提供以下查询参数:

{
  "repositoryName": "my_repo",
  "repositoryLocationName": <???>,
  "pipelineName": "my_pipeline",
  "mode": "dev",
  "runConfigData": {<MY_RUN_CONFIG>}
}

我不确定 repositoryLocationName 应该取什么值?我尝试了一些但收到以下错误:

{
  "data": {
    "launchPipelineExecution": {
      "__typename": "PipelineNotFoundError"
    }
  }
}

This 是我正在关注的教程。

简答:

每个存储库都位于一个存储库位置中。如果您自己没有提供,Dagster 会提供一个默认的存储库位置名称。要查找位置名称,您可以单击 Dagit 中的存储库选择器,它会在存储库名称旁边:

在此示例中,存储库名称为 toys_repository,位置名称为 dagster_test.toys.repo

更长的答案:

工作区(使用您的 workspace.yaml 定义)是存储库位置的集合。

目前有三种类型的存储库位置:

  • Python 文件
  • Python模块
  • gRPC 服务器

每个存储库位置可以有多个存储库。定义位置后,Dagster 能够自动查找该位置中的所有存储库。在上面的示例中,我将我的工作区定义为具有单个 Python 模块存储库位置:

load_from:
  - python_module: dagster_test.toys.repo

请注意,只是指定了一个模块而没有指定存储库位置名称,因此 Dagster 分配了一个默认的存储库位置名称。

如果我想指定一个位置名称,我会这样做:

load_from:
- python_module:
    module_name: dagster_test.toys.repo
    location_name: "my_custom_location_name"

与 python 文件位置类似:

load_from:
- python_file: repo.py

或使用自定义存储库位置名称:

load_from:
- python_file:
    relative_path: repo.py
    location_name: "my_custom_location_name"

您也可以使用 GraphQL 查询来查找。从示例 provided in the documentation 开始,您只需添加

repositoryOrigin {
      repositoryLocationName
    }

导致

query PaginatedPipelineRuns {
  pipelineRunsOrError {
  __typename
     ... on PipelineRuns {
           results {
             runId
             pipelineName
             status
             runConfigYaml
             repositoryOrigin {
                repositoryLocationName
             }
          stats {
            ... on PipelineRunStatsSnapshot {
              startTime
              endTime
              stepsFailed
            }
          }
        }
      }
    }
  }

这将 return 任何 运行 return 编辑的存储库位置名称。在查询之前在 UI 中触发您想要位置名称的管道,并且 运行 将是您的第一个结果。