layer-workflow-import

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Layer Workflow Import

Layer 工作流导入

Overview

概述

Read what the source does, rebuild it from Layer's node kinds, and hand the whole graph to
import_workflow
. The result is always private; sharing is a separate step in the Layer app. To run a workflow that already exists, use
layer-workflows
. The spend gate and polling rules live in the
layer
skill.
If a sibling skill named here is missing from your available skills, ask the user to install it (
npx skills add layerai/skills --skill <name>
); unattended, proceed from tool schemas and flag the gap.
先了解源工作流的功能,再基于Layer的节点类型进行重构,最后将完整的图提交给
import_workflow
。导入结果默认是私有的;分享操作需要在Layer应用中单独执行。如果要运行已有的工作流,请使用
layer-workflows
。消费门槛和轮询规则在
layer
技能中定义。
如果此处提到的关联技能不在你的可用技能列表中,请让用户安装(
npx skills add layerai/skills --skill <name>
);若处于无人值守模式,则基于工具schema继续操作并标记缺失项。

Translate intent, not nodes

转换意图,而非节点

Other tools expose the machinery; Layer exposes the task. A low-level text-to-image graph is a model loader, a text encoder per prompt, an empty latent, a sampler and a decoder. In Layer that is one generate node. Read what goes in, what each step does, and what comes out, then use the fewest Layer nodes that do the same job.
How to read an unfamiliar source, and what common node patterns mean, is in references/sources.md.
其他工具展示底层机制,而Layer聚焦任务本身。一个底层的文生图节点图包含模型加载器、每个提示词对应的文本编码器、空潜变量、采样器和解码器。在Layer中,这仅需一个generate节点即可实现。先理清输入内容、每一步的作用以及输出结果,再用最少的Layer节点实现相同功能。
如何解读不熟悉的源工作流,以及常见节点模式的含义,请参考references/sources.md。

Quick reference

快速参考

StepToolNotes
Learn the parts
get_blueprint_system_config
Node kinds, their ports and value schemas. Call once, reuse.
Pick models
list_base_models
,
get_base_model
Discover by use case. Never copy the source's model name.
Sample files
request_file_upload_url
or
upload_file
Only for the proof run: a file input's value is a
file_id
.
Check the graph
import_workflow
with
validate_only: true
Creates nothing. Fix every problem it reports.
Import
import_workflow
Publishes privately by default so it can run.
Prove it runs
estimate_workflow_price
,
execute_workflow
Run shape as in
layer-workflows
. Poll
get_workflow_run
.
File it
list_projects
, then
project_id
on import
Optional: land the workflow in a project for review.
步骤工具说明
了解组件
get_blueprint_system_config
获取节点类型、其端口及值schema。只需调用一次,可重复使用。
选择模型
list_base_models
,
get_base_model
按用例查找模型。切勿直接复制源工作流的模型名称。
示例文件
request_file_upload_url
或
upload_file
仅用于验证运行:文件输入的值为
file_id
。
检查节点图开启
validate_only: true
的
import_workflow
不创建任何内容。修复其报告的所有问题。
导入
import_workflow
默认以私有状态发布,导入后即可运行。
验证运行
estimate_workflow_price
,
execute_workflow
按照
layer-workflows
中的方式运行。轮询
get_workflow_run
获取状态。
归档项目先调用
list_projects
,导入时传入
project_id
可选:将工作流归档到某个项目以供审核。

The graph

图结构

graph
is an open object with three maps:
inputs
(parameter key to input parameter),
nodes
(node id to node) and
outputs
(parameter key to output parameter). No public surface defines the fields inside them, so do not assume a shape. Node kinds, port keys, port types and value schemas come from
get_blueprint_system_config
;
validate_only
names whatever is missing or misnamed.
There is no edge list. Whatever is fed names its source in
refs
,
{"_default": [...]}
, holding
nodes::<node id>[<kind key>]::<port key>
for a node output or
blueprint::<input key>
for a workflow input.
An output of type A may feed an input of type B only when A equals B or (A, B) is a casting rule. A rule carrying a
transformer
is blocked, not allowed: insert the named transformer node kind between the two and wire through it.
Static values must conform to their type's JSON schema in the system config. Where a port selects a model, discover it with
list_base_models
filtered by the use case that node serves.
graph
是一个开放对象,包含三个映射:
inputs
(参数键到输入参数的映射)、
nodes
(节点ID到节点的映射)和
outputs
(参数键到输出参数的映射)。没有公开接口定义其内部字段,因此不要预设结构。节点类型、端口键、端口类型和值schema均来自
get_blueprint_system_config
;
validate_only
会指出所有缺失或命名错误的内容。
没有单独的边列表。所有输入的源都通过
refs
中的
{"_default": [...]}
指定,节点输出的格式为
nodes::<node id>[<kind key>]::<port key>
,工作流输入的格式为
blueprint::<input key>
。
类型为A的输出只能连接到类型为B的输入,当且仅当A等于B,或(A, B)符合类型转换规则。如果某条规则带有
transformer
属性,则表示该转换被禁止,不允许直接连接:需要在两者之间插入指定的transformer节点类型,通过该节点完成连接。
静态值必须符合系统配置中对应类型的JSON schema规范。如果某个端口用于选择模型,需通过
list_base_models
按该节点的用例过滤来查找合适的模型。

The loop

操作流程

  1. get_blueprint_system_config
    for the workspace.
  2. Read the source and write down inputs, steps and outputs in plain words.
  3. Map each step to a node kind. When nothing fits, stop and tell the user which step has no Layer equivalent, rather than approximating it with an unrelated node.
  4. Build the graph, then
    import_workflow
    with
    validate_only: true
    . The result groups problems by node, input and output. Fix and repeat until
    is_valid
    is true.
  5. import_workflow
    for real, with a clear
    name
    and a
    description
    that says where it came from. Pass
    project_id
    when the user wants it filed in a project.
  6. Prove it: upload a sample for each file input,
    estimate_workflow_price
    , confirm above 20 CUs, then
    execute_workflow
    with a
    session_name
    and poll. A graph that validates can still produce the wrong thing; look at the output.
  7. Report: the workflow id, what was mapped to what, and anything dropped or approximated.
publish: false
keeps a draft instead of a runnable workflow, and is accepted even with validation problems. Use it only when the user wants to finish the graph by hand in the editor.
  1. 调用
    get_blueprint_system_config
    获取工作区配置。
  2. 解读源工作流,用简明的语言记录输入、步骤和输出。
  3. 将每个步骤映射到对应的节点类型。如果没有匹配的节点类型,请停止并告知用户哪个步骤没有对应的Layer等效节点,切勿用不相关的节点勉强近似。
  4. 构建节点图,然后调用
    import_workflow
    并开启
    validate_only: true
    参数。返回结果会按节点、输入、输出对问题进行分组。修复问题后重复此步骤,直到
    is_valid
    为true。
  5. 正式调用
    import_workflow
    ,设置清晰的
    name
    和说明来源的
    description
    。如果用户希望将工作流归档到项目中,需传入
    project_id
    。
  6. 验证运行:为每个文件输入上传示例文件,调用
    estimate_workflow_price
    预估费用,确认超过20 CUs后,调用带有
    session_name
    参数的
    execute_workflow
    并轮询状态。通过验证的节点图仍可能产出错误结果,因此必须检查输出内容。
  7. 报告内容需包含:工作流ID、各步骤的映射关系,以及所有被舍弃或近似处理的内容。
publish: false
参数会将工作流保存为草稿而非可运行状态,即使存在验证问题也能提交保存。仅当用户希望在编辑器中手动完成节点图时才使用该参数。

Worked example

实操示例

"Import this workflow." The user attaches a node-graph JSON: a top-level
nodes
list and a
links
list of
[link, from node, from slot, to node, to slot]
.
  1. Reading it: a checkpoint loader, a pixel-art style adapter, positive and negative text encoders, an empty 1024x1024 latent, a sampler, a decoder, a 2x upscale and a save node.
  2. Intent: text in, pixel-art image out, upscaled 2x. Inputs: the prompt. Fixed: size, the style.
  3. get_blueprint_system_config
    , then pick generate-image and upscale node kinds whose ports fit. If the generate kind has a style port, check
    list_reference_sets
    for a pixel-art set; otherwise fold the style into the prompt.
  4. list_base_models
    with the text-to-image use case; take the first result for the generate node.
  5. Graph: input
    prompt
    ; the generate node's prompt port refs
    blueprint::prompt
    ; the upscale node's image port refs
    nodes::<generate id>[<generate kind>]::<image port>
    ; an output refs the upscale node's output.
  6. validate_only
    reports the upscale node's image port as the wrong type. The casting rule for that pair carries a
    transformer
    , so it is blocked: insert that transformer node kind and wire through it.
  7. Import, estimate (6 CUs), execute with a
    session_name
    and a sample prompt, poll, and check the image is upscaled and pixel-styled.
  8. Report: "Imported as a private workflow. The sampler, latent and decoder plumbing became one generate node. The style adapter became a reference set. The negative prompt was dropped: the chosen model has no negative prompt port."
"导入这个工作流。" 用户附上了一个node-graph JSON:顶层包含
nodes
列表和
links
列表,
links
的元素格式为
[link, 源节点, 源插槽, 目标节点, 目标插槽]
。
  1. 解读源文件:包含检查点加载器、像素风格适配器、正向与负向文本编码器、空的1024x1024潜变量、采样器、解码器、2倍超分节点和保存节点。
  2. 工作流意图:输入文本,输出像素风格图像,并完成2倍超分。输入:提示词。固定参数:尺寸、风格。
  3. 调用
    get_blueprint_system_config
    ,然后选择端口匹配的generate-image和upscale节点类型。如果generate节点类型有风格端口,调用
    list_reference_sets
    查找像素风格参考集;否则将风格融入提示词中。
  4. 按文生图用例调用
    list_base_models
    ;将第一个返回结果用于generate节点。
  5. 节点图结构:输入
    prompt
    ;generate节点的prompt端口引用
    blueprint::prompt
    ;upscale节点的图像端口引用
    nodes::<generate id>[<generate kind>]::<image port>
    ;输出引用upscale节点的输出。
  6. validate_only
    报告upscale节点的图像端口类型错误。该端口对的类型转换规则带有
    transformer
    属性,因此被禁止直接连接:需要插入对应的transformer节点类型并通过其连接。
  7. 执行导入、预估费用(6 CUs)、使用
    session_name
    和示例提示词运行、轮询状态,并检查图像是否完成超分且具备像素风格。
  8. 报告内容:"已作为私有工作流导入。采样器、潜变量和解码器的底层逻辑合并为一个generate节点。风格适配器转换为参考集。负向提示词被舍弃:所选模型没有负向提示词端口。"

Common mistakes

常见错误

  • Copying a checkpoint or weights file name into a model port instead of discovering a
    base_model_id
    .
  • Inventing field names inside
    graph
    instead of taking them from the system config and validation.
  • Wiring a pair whose casting rule carries a
    transformer
    instead of routing through that node kind.
  • Silently approximating a step Layer has no node for. Say which step and why.
  • Promising the workflow is shared. It is private; sharing happens in the Layer app.
  • Skipping the test run. Validation checks wiring, not whether the output is right.
  • 将检查点或权重文件名直接填入模型端口,而不是通过查找获取
    base_model_id
    。
  • 自行臆造
    graph
    内部的字段名,而不是从系统配置和验证结果中获取。
  • 直接连接类型转换规则带有
    transformer
    的端口对,而不是通过对应节点类型路由。
  • 对于Layer没有对应节点的步骤,默默进行近似处理。应当明确告知用户具体步骤及原因。
  • 承诺工作流已共享。导入的工作流默认是私有的;共享操作需在Layer应用中完成。
  • 跳过测试运行。验证仅检查连接是否正确,无法保证输出结果正确。