dagster-code-location-structure

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Dagster Code Location Structure

Dagster代码位置结构

Project layout

项目布局

Code locations live under
dg_projects/
as separate subdirectories, each managed by
dg
. Shared code (base classes, utilities, sensors used by multiple locations) lives in
packages/ol-orchestrate-lib/
.
dg_projects/
  <code_location_name>/
    pyproject.toml
    src/
      <code_location_name>/
        assets/
        sensors/
        ...
packages/
  ol-orchestrate-lib/
    ...
代码位置作为独立子目录存放在
dg_projects/
下,每个子目录由
dg
管理。共享代码(基础类、工具函数、多个位置共用的sensors)存放在
packages/ol-orchestrate-lib/
中。
dg_projects/
  <code_location_name>/
    pyproject.toml
    src/
      <code_location_name>/
        assets/
        sensors/
        ...
packages/
  ol-orchestrate-lib/
    ...

Scaffolding new code locations

搭建新的代码位置

Use the
create-dagster
tool to scaffold new code locations — not
dg scaffold
:
bash
create-dagster <code_location_name>
使用
create-dagster
工具搭建新的代码位置——不要使用
dg scaffold
bash
create-dagster <code_location_name>

Asset and sensor placement

资产与传感器的放置

Assets and sensors must be placed in the code location that owns them. Do not accidentally include an asset or sensor from one code location in another. When migrating or moving definitions, double-check
defs.py
/
__init__.py
imports in each code location.
Assets和sensors必须放在所属的代码位置中。切勿将一个代码位置的asset或sensor错误地包含到另一个位置中。迁移或移动定义时,请仔细检查每个代码位置中的
defs.py
/
__init__.py
导入语句。

Migration sequencing

迁移顺序

When migrating multiple code locations (e.g., from EC2/docker-compose to Kubernetes), do one code location at a time. The first location becomes the validated template. Never try to migrate all locations in a single PR.
当迁移多个代码位置时(例如从EC2/docker-compose迁移到Kubernetes),每次只迁移一个代码位置。第一个迁移的位置将作为验证后的模板。切勿尝试在单个PR中迁移所有位置。

Shared OAuth / base classes

共享OAuth/基础类

The
oauth
module inside
ol-orchestrate-lib
is used as a base class by multiple code locations. It must remain in the library even if it looks unused from a single code location's perspective.
ol-orchestrate-lib
中的
oauth
模块被多个代码位置用作基础类。即使从单个代码位置的角度看它似乎未被使用,也必须保留在该库中。

Checking partitions

检查分区

Static partitions with hardcoded values are the old approach. Prefer dynamic/time-based partitions when an up-to-date implementation already exists in another code location — copy that pattern rather than the older one.
使用硬编码值的静态分区是方法。如果其他代码位置中已有最新的动态/基于时间的分区实现,请优先使用该模式,而非旧模式。