Skip to content

best_practice 工作流在 v0.10.19 中更新已有 container 时崩溃 #256

@07-clottattoos-cyber

Description

@07-clottattoos-cyber

问题概述

这个问题不是自定义工作流,而是官方文档 best_practice(最佳实践)中的示例工作流本身无法跑通。

按照文档 best_practice 中的工作流操作时,如果 host_node/create_resourceres_id 指向一个已存在的 container,本地执行器会直接崩溃。

这会导致文档里的两步工作流无法跑通:

  1. creat_resource 向已有 container 中加入水
  2. PumpTransferProtocol 将液体传输到 container1

版本信息

  • Uni-Lab-OS v0.10.19
  • tag/main commit: c001f6a1512affb48e9ae5c068e201bda3412679

文档位置

docs/user_guide/best_practice.md
第 7.5 - 7.9 节当前给出的配置是:

  • creat_resource

    • class_name: container
    • device_id: workstation
    • parent: workstation
    • res_id: container
    • liquid_type: water
    • liquid_volume: 50
  • PumpTransferProtocol

    • from_vessel: water
    • to_vessel: container1

复现步骤

  1. 启动 Uni-Lab,并完成 registry 上传。
  2. 在 Web UI 中创建实验室,包含:
    • workstation(其 protocol_type 包含 PumpTransferProtocol
    • virtual_transfer_pump
    • container
    • container1
  3. 严格按照 best_practice.md 的说明创建工作流。
  4. 运行 creat_resource,参数为:
    • res_id=container
    • liquid_type=water
    • liquid_volume=50

期望行为

作为最佳实践文档中的示例工作流,这个流程应该可以直接跑通:

  • 已有的 container 被更新为包含 water
  • 然后工作流继续执行 PumpTransferProtocol

实际行为

本地 host executor 在线程中崩溃,还没有执行到 PumpTransferProtocol

报错堆栈如下:

File "unilabos/ros/nodes/base_device_node.py", line 433, in append_resource
    logger.info(f"更新物料{container_instance.name}的数据{found_resource.state}")
AttributeError: 'RegularContainer' object has no attribute 'state'

怀疑的根因

这看起来像一次不完整的重构 / 回归

在提交 a79c0a8fix container volume)中,RegularContainer.state 似乎已经被移除:

  • unilabos/resources/container.py 中不再定义 self.state
  • load_state() 也改为调用 super().load_state(state)

但是 append_resource 仍然在使用旧接口:

logger.info(f"更新物料{container_instance.name}的数据{found_resource.state}")
found_resource.state.update(container_instance.state)

因此,文档中“create_resource 更新已有 container”这条路径在 v0.10.19 上会直接崩溃。

额外说明

文档下一步里还有一个可能的文档 / 实现不一致:

  • 文档写的是 from_vessel: water
  • 当前 PumpTransferProtocol 的实现看起来更像是要求传入 vessel/resource id,而不是液体名

不过当前最直接的阻塞问题,还是上面的 create_resource 崩溃。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions