支持local_config启动 添加注册表description字段 (#13)

Closes #11

* Update README and MQTTClient for installation instructions and code improvements

* feat: 支持local_config启动
add: 增加对crt path的说明,为传入config.py的相对路径
move: web component

* add: registry description

---------

Co-authored-by: Harvey Que <Q-Query@outlook.com>
This commit is contained in:
Xuwznln
2025-04-20 18:24:45 +08:00
committed by GitHub
parent 22a02bdb06
commit 35ada068cc
39 changed files with 114 additions and 34 deletions

View File

@@ -69,14 +69,17 @@ def main():
args_dict = vars(args)
# 加载配置文件 - 这里保持最先加载配置的逻辑
if args_dict.get("config"):
config_path = args_dict["config"]
config_path = args_dict.get("config")
if config_path:
if not os.path.exists(config_path):
print_status(f"配置文件 {config_path} 不存在", "error")
elif not config_path.endswith(".py"):
print_status(f"配置文件 {config_path} 不是Python文件必须以.py结尾", "error")
else:
load_config(config_path)
else:
print_status(f"启动 UniLab-OS时配置文件参数未正确传入 --config '{config_path}' 尝试本地配置...", "warning")
load_config(config_path)
# 设置BasicConfig参数
BasicConfig.is_host_mode = not args_dict.get("without_host", False)
@@ -92,8 +95,8 @@ def main():
from unilabos.app.mq import mqtt_client
from unilabos.registry.registry import build_registry
from unilabos.app.backend import start_backend
from unilabos.web import http_client
from unilabos.web import start_server
from unilabos.app.web import http_client
from unilabos.app.web import start_server
# 显示启动横幅
print_unilab_banner(args_dict)

View File

@@ -4,10 +4,10 @@ Web UI 模块
提供了UniLab系统的Web界面功能
"""
from unilabos.web.pages import setup_web_pages
from unilabos.web.server import setup_server, start_server
from unilabos.web.client import http_client
from unilabos.web.api import setup_api_routes
from unilabos.app.web.pages import setup_web_pages
from unilabos.app.web.server import setup_server, start_server
from unilabos.app.web.client import http_client
from unilabos.app.web.api import setup_api_routes
__all__ = [
"setup_web_pages", # 设置Web页面

View File

@@ -18,7 +18,7 @@ from unilabos.app.model import (
JobPreintakeFinishReq,
JobFinishReq,
)
from unilabos.web.utils.host_utils import get_host_node_info
from unilabos.app.web.utils.host_utils import get_host_node_info
# 创建API路由器
api = APIRouter()

View File

@@ -20,9 +20,9 @@ from unilabos.app.mq import mqtt_client
from unilabos.ros.msgs.message_converter import msg_converter_manager
from unilabos.utils.log import error
from unilabos.utils.type_check import TypeEncoder
from unilabos.web.utils.device_utils import get_registry_info
from unilabos.web.utils.host_utils import get_host_node_info
from unilabos.web.utils.ros_utils import get_ros_node_info, update_ros_node_info
from unilabos.app.web.utils.device_utils import get_registry_info
from unilabos.app.web.utils.host_utils import get_host_node_info
from unilabos.app.web.utils.ros_utils import get_ros_node_info, update_ros_node_info
# 设置Jinja2模板环境
template_dir = Path(__file__).parent / "templates"

View File

@@ -13,8 +13,8 @@ from starlette.responses import Response
from unilabos.utils.fastapi.log_adapter import setup_fastapi_logging
from unilabos.utils.log import info, error
from unilabos.web.api import setup_api_routes
from unilabos.web.pages import setup_web_pages
from unilabos.app.web.api import setup_api_routes
from unilabos.app.web.pages import setup_web_pages
# 创建FastAPI应用
app = FastAPI(

View File

@@ -9,7 +9,7 @@ from typing import Dict, Any
from unilabos.config.config import BasicConfig
from unilabos.ros.nodes.presets.host_node import HostNode
from unilabos.web.utils.action_utils import get_action_info
from unilabos.app.web.utils.action_utils import get_action_info
def get_host_node_info() -> Dict[str, Any]:

View File

@@ -7,7 +7,7 @@ ROS 工具函数模块
import traceback
from typing import Dict, Any
from unilabos.web.utils.action_utils import get_action_info
from unilabos.app.web.utils.action_utils import get_action_info
# 存储 ROS 节点信息的全局变量
ros_node_info = {"online_devices": {}, "device_topics": {}, "device_actions": {}}

View File

@@ -28,9 +28,9 @@ class MQConfig:
key_content = ""
# 指定
ca_file = ""
cert_file = ""
key_file = ""
ca_file = "" # 相对config.py所在目录的路径
cert_file = "" # 相对config.py所在目录的路径
key_file = "" # 相对config.py所在目录的路径
# OSS上传配置
@@ -97,7 +97,7 @@ def load_config(config_path=None):
BasicConfig.config_path = os.path.abspath(os.path.dirname(config_path))
if not os.path.exists(config_path):
logger.error(f"配置文件 {config_path} 不存在")
return
exit(1)
try:
module_name = "lab_" + os.path.basename(config_path).replace(".py", "")
@@ -114,10 +114,5 @@ def load_config(config_path=None):
traceback.print_exc()
exit(1)
else:
try:
import unilabos.config.local_config as local_config # type: ignore
_update_config_from_module(local_config)
logger.info("已加载默认配置 unilabos.config.local_config")
except ImportError:
pass
config_path = os.path.join(os.path.dirname(__file__), "local_config.py")
load_config(config_path)

View File

@@ -1,4 +1,5 @@
io_snrd:
description: IO Board with 16 IOs
class:
module: unilabos.device_comms.SRND_16_IO:SRND_16_IO
type: python

View File

@@ -1,4 +1,5 @@
serial:
description: Serial communication interface, used when sharing same serial port for multiple devices
class:
module: unilabos.ros.nodes.presets:ROS2SerialNode
type: ros2

View File

@@ -1,5 +1,6 @@
# 光学表征设备:红外、紫外可见、拉曼等
raman_home_made:
description: Raman spectroscopy device
class:
module: unilabos.devices.raman_uv.home_made_raman:RamanObj
type: python

View File

@@ -1,4 +1,5 @@
liquid_handler:
description: Liquid handler device controlled by pylabrobot
class:
module: pylabrobot.liquid_handling:LiquidHandler
type: python

View File

@@ -1,4 +1,5 @@
separator.homemade:
description: Separator device with homemade grbl controller
class:
module: unilabos.devices.separator.homemade_grbl_conductivity:Separator_Controller
type: python
@@ -39,6 +40,7 @@ separator.homemade:
additionalProperties: false
rotavap.one:
description: Rotavap device
class:
module: unilabos.devices.rotavap.rotavap_one:RotavapOne
type: python

View File

@@ -1,4 +1,5 @@
syringe_pump_with_valve.runze:
description: Runze Syringe pump with valve
class:
module: unilabos.devices.pump_and_valve.runze_backbone:RunzeSyringePump
type: python
@@ -25,11 +26,13 @@ syringe_pump_with_valve.runze:
solenoid_valve.mock:
description: Mock solenoid valve
class:
module: unilabos.devices.pump_and_valve.solenoid_valve_mock:SolenoidValveMock
type: python
solenoid_valve:
description: Solenoid valve
class:
module: unilabos.devices.pump_and_valve.solenoid_valve:SolenoidValve
type: python

View File

@@ -1,5 +1,6 @@
# 仙工智能底盘(知行使用)
agv.SEER:
description: SEER AGV
class:
module: unilabos.devices.agv.agv_navigator:AgvNavigator
type: python

View File

@@ -1,4 +1,5 @@
robotic_arm.UR:
description: UR robotic arm
class:
module: unilabos.devices.agv.ur_arm_task:UrArmTask
type: python

View File

@@ -1,4 +1,5 @@
gripper.mock:
description: Mock gripper
class:
module: unilabos.devices.gripper.mock:MockGripper
type: python
@@ -21,6 +22,7 @@ gripper.mock:
gripper.misumi_rz:
description: Misumi RZ gripper
class:
module: unilabos.devices.motor:Grasp.EleGripper
type: python

View File

@@ -1,4 +1,5 @@
linear_motion.grbl:
description: Grbl CNC
class:
module: unilabos.devices.cnc.grbl_sync:GrblCNC
type: python
@@ -38,6 +39,7 @@ linear_motion.grbl:
motor.iCL42:
description: iCL42 motor
class:
module: unilabos.devices.motor.iCL42:iCL42Driver
type: python

View File

@@ -1,4 +1,5 @@
heaterstirrer.dalong:
description: DaLong heater stirrer
class:
module: unilabos.devices.heaterstirrer.dalong:HeaterStirrer_DaLong
type: python
@@ -34,6 +35,7 @@ heaterstirrer.dalong:
success: success
chiller:
description: Chiller
class:
module: unilabos.devices.temperature.chiller:Chiller
type: python
@@ -46,6 +48,7 @@ chiller:
result:
success: success
tempsensor:
description: Temperature sensor
class:
module: unilabos.devices.temperature.sensor_node:TempSensorNode
type: python

View File

@@ -1,9 +1,11 @@
vacuum_pump.mock:
description: Mock vacuum pump
class:
module: unilabos.devices.pump_and_valve.vacuum_pump_mock:VacuumPumpMock
type: python
gas_source.mock:
description: Mock gas source
class:
module: unilabos.devices.pump_and_valve.vacuum_pump_mock:VacuumPumpMock
type: python

View File

@@ -1,4 +1,5 @@
workstation:
description: Workstation
class:
module: unilabos.ros.nodes.presets.protocol_node:ROS2ProtocolNode
type: ros2

View File

@@ -54,9 +54,9 @@ class Registry:
if data:
# 为每个资源添加文件路径信息
for resource_id, resource_info in data.items():
# 添加文件路径 - 使用规范化的完整文件路径
resource_info["file_path"] = str(file.absolute()).replace("\\", "/")
if "description" not in resource_info:
resource_info["description"] = ""
self.resource_type_registry.update(data)
logger.debug(
f"[UniLab Registry] Resource-{current_resource_number} File-{i+1}/{len(files)} "
@@ -112,7 +112,8 @@ class Registry:
for device_id, device_config in data.items():
# 添加文件路径信息 - 使用规范化的完整文件路径
device_config["file_path"] = str(file.absolute()).replace("\\", "/")
if "description" not in device_config:
device_config["description"] = ""
if "class" in device_config:
# 处理状态类型
if "status_types" in device_config["class"]:

View File

@@ -1,4 +1,5 @@
OTDeck:
description: Opentrons deck
class:
module: pylabrobot.resources.opentrons.deck:OTDeck
type: pylabrobot

View File

@@ -1,4 +1,5 @@
Opentrons_96_adapter_Vb:
description: Opentrons 96 adapter Vb
class:
module: pylabrobot.resources.opentrons.plate_adapters:Opentrons_96_adapter_Vb
type: pylabrobot

View File

@@ -1,74 +1,89 @@
corning_6_wellplate_16point8ml_flat:
description: Corning 6 wellplate 16.8ml flat
class:
module: pylabrobot.resources.opentrons.plates:corning_6_wellplate_16point8ml_flat
type: pylabrobot
corning_12_wellplate_6point9ml_flat:
description: Corning 12 wellplate 6.9ml flat
class:
module: pylabrobot.resources.opentrons.plates:corning_12_wellplate_6point9ml_flat
type: pylabrobot
corning_24_wellplate_3point4ml_flat:
description: Corning 24 wellplate 3.4ml flat
class:
module: pylabrobot.resources.opentrons.plates:corning_24_wellplate_3point4ml_flat
type: pylabrobot
corning_48_wellplate_1point6ml_flat:
description: Corning 48 wellplate 1.6ml flat
class:
module: pylabrobot.resources.opentrons.plates:corning_48_wellplate_1point6ml_flat
type: pylabrobot
corning_96_wellplate_360ul_flat:
description: Corning 96 wellplate 360ul flat
class:
module: pylabrobot.resources.opentrons.plates:corning_96_wellplate_360ul_flat
type: pylabrobot
corning_384_wellplate_112ul_flat:
description: Corning 384 wellplate 112ul flat
class:
module: pylabrobot.resources.opentrons.plates:corning_384_wellplate_112ul_flat
type: pylabrobot
nest_96_wellplate_2ml_deep:
description: Nest 96 wellplate 2ml deep
class:
module: pylabrobot.resources.opentrons.plates:nest_96_wellplate_2ml_deep
type: pylabrobot
nest_96_wellplate_200ul_flat:
description: Nest 96 wellplate 200ul flat
class:
module: pylabrobot.resources.opentrons.plates:nest_96_wellplate_200ul_flat
type: pylabrobot
nest_96_wellplate_100ul_pcr_full_skirt:
description: Nest 96 wellplate 100ul pcr full skirt
class:
module: pylabrobot.resources.opentrons.plates:nest_96_wellplate_100ul_pcr_full_skirt
type: pylabrobot
appliedbiosystemsmicroamp_384_wellplate_40ul:
description: Applied Biosystems microamp 384 wellplate 40ul
class:
module: pylabrobot.resources.opentrons.plates:appliedbiosystemsmicroamp_384_wellplate_40ul
type: pylabrobot
thermoscientificnunc_96_wellplate_1300ul:
description: Thermoscientific Nunc 96 wellplate 1300ul
class:
module: pylabrobot.resources.opentrons.plates:thermoscientificnunc_96_wellplate_1300ul
type: pylabrobot
thermoscientificnunc_96_wellplate_2000ul:
description: Thermoscientific Nunc 96 wellplate 2000ul
class:
module: pylabrobot.resources.opentrons.plates:thermoscientificnunc_96_wellplate_2000ul
type: pylabrobot
usascientific_96_wellplate_2point4ml_deep:
description: USAScientific 96 wellplate 2.4ml deep
class:
module: pylabrobot.resources.opentrons.plates:usascientific_96_wellplate_2point4ml_deep
type: pylabrobot
biorad_96_wellplate_200ul_pcr:
description: BioRad 96 wellplate 200ul pcr
class:
module: pylabrobot.resources.opentrons.plates:biorad_96_wellplate_200ul_pcr
type: pylabrobot
biorad_384_wellplate_50ul:
description: BioRad 384 wellplate 50ul
class:
module: pylabrobot.resources.opentrons.plates:biorad_384_wellplate_50ul
type: pylabrobot

View File

@@ -1,29 +1,35 @@
agilent_1_reservoir_290ml:
description: Agilent 1 reservoir 290ml
class:
module: pylabrobot.resources.opentrons.reserviors:agilent_1_reservoir_290ml
type: pylabrobot
axygen_1_reservoir_90ml:
description: Axygen 1 reservoir 90ml
class:
module: pylabrobot.resources.opentrons.reserviors:axygen_1_reservoir_90ml
type: pylabrobot
nest_12_reservoir_15ml:
description: Nest 12 reservoir 15ml
class:
module: pylabrobot.resources.opentrons.reserviors:nest_12_reservoir_15ml
type: pylabrobot
nest_1_reservoir_195ml:
description: Nest 1 reservoir 195ml
class:
module: pylabrobot.resources.opentrons.reserviors:nest_1_reservoir_195ml
type: pylabrobot
nest_1_reservoir_290ml:
description: Nest 1 reservoir 290ml
class:
module: pylabrobot.resources.opentrons.reserviors:nest_1_reservoir_290ml
type: pylabrobot
usascientific_12_reservoir_22ml:
description: USAScientific 12 reservoir 22ml
class:
module: pylabrobot.resources.opentrons.reserviors:usascientific_12_reservoir_22ml
type: pylabrobot

View File

@@ -1,64 +1,77 @@
eppendorf_96_tiprack_1000ul_eptips:
description: Eppendorf 96 tiprack 1000ul eptips
class:
module: pylabrobot.resources.opentrons.tip_racks:eppendorf_96_tiprack_1000ul_eptips
type: pylabrobot
tipone_96_tiprack_200ul:
description: TipOne 96 tiprack 200ul
class:
module: pylabrobot.resources.opentrons.tip_racks:tipone_96_tiprack_200ul
type: pylabrobot
opentrons_96_tiprack_300ul:
description: Opentrons 96 tiprack 300ul
class:
module: pylabrobot.resources.opentrons.tip_racks:opentrons_96_tiprack_300ul
type: pylabrobot
opentrons_96_tiprack_10ul:
description: Opentrons 96 tiprack 10ul
class:
module: pylabrobot.resources.opentrons.tip_racks:opentrons_96_tiprack_10ul
type: pylabrobot
opentrons_96_filtertiprack_10ul:
description: Opentrons 96 filtertiprack 10ul
class:
module: pylabrobot.resources.opentrons.tip_racks:opentrons_96_filtertiprack_10ul
type: pylabrobot
geb_96_tiprack_10ul:
description: Geb 96 tiprack 10ul
class:
module: pylabrobot.resources.opentrons.tip_racks:geb_96_tiprack_10ul
type: pylabrobot
opentrons_96_filtertiprack_200ul:
description: Opentrons 96 filtertiprack 200ul
class:
module: pylabrobot.resources.opentrons.tip_racks:opentrons_96_filtertiprack_200ul
type: pylabrobot
eppendorf_96_tiprack_10ul_eptips:
description: Eppendorf 96 tiprack 10ul eptips
class:
module: pylabrobot.resources.opentrons.tip_racks:eppendorf_96_tiprack_10ul_eptips
type: pylabrobot
opentrons_96_tiprack_1000ul:
description: Opentrons 96 tiprack 1000ul
class:
module: pylabrobot.resources.opentrons.tip_racks:opentrons_96_tiprack_1000ul
type: pylabrobot
opentrons_96_tiprack_20ul:
description: Opentrons 96 tiprack 20ul
class:
module: pylabrobot.resources.opentrons.tip_racks:opentrons_96_tiprack_20ul
type: pylabrobot
opentrons_96_filtertiprack_1000ul:
description: Opentrons 96 filtertiprack 1000ul
class:
module: pylabrobot.resources.opentrons.tip_racks:opentrons_96_filtertiprack_1000ul
type: pylabrobot
opentrons_96_filtertiprack_20ul:
description: Opentrons 96 filtertiprack 20ul
class:
module: pylabrobot.resources.opentrons.tip_racks:opentrons_96_filtertiprack_20ul
type: pylabrobot
geb_96_tiprack_1000ul:
description: Geb 96 tiprack 1000ul
class:
module: pylabrobot.resources.opentrons.tip_racks:geb_96_tiprack_1000ul
type: pylabrobot

View File

@@ -1,99 +1,119 @@
opentrons_24_tuberack_eppendorf_2ml_safelock_snapcap:
description: Opentrons 24 tuberack eppendorf 2ml safelock snapcap
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_24_tuberack_eppendorf_2ml_safelock_snapcap
type: pylabrobot
opentrons_24_tuberack_eppendorf_2ml_safelock_snapcap_acrylic:
description: Opentrons 24 tuberack eppendorf 2ml safelock snapcap acrylic
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_24_tuberack_eppendorf_2ml_safelock_snapcap_acrylic
type: pylabrobot
opentrons_6_tuberack_falcon_50ml_conical:
description: Opentrons 6 tuberack falcon 50ml conical
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_6_tuberack_falcon_50ml_conical
type: pylabrobot
opentrons_15_tuberack_nest_15ml_conical:
description: Opentrons 15 tuberack nest 15ml conical
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_15_tuberack_nest_15ml_conical
type: pylabrobot
opentrons_24_tuberack_nest_2ml_screwcap:
description: Opentrons 24 tuberack nest 2ml screwcap
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_24_tuberack_nest_2ml_screwcap
type: pylabrobot
opentrons_24_tuberack_generic_0point75ml_snapcap_acrylic:
description: Opentrons 24 tuberack generic 0.75ml snapcap acrylic
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_24_tuberack_generic_0point75ml_snapcap_acrylic
type: pylabrobot
opentrons_10_tuberack_nest_4x50ml_6x15ml_conical:
description: Opentrons 10 tuberack nest 4x50ml 6x15ml conical
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_10_tuberack_nest_4x50ml_6x15ml_conical
type: pylabrobot
opentrons_10_tuberack_falcon_4x50ml_6x15ml_conical_acrylic:
description: Opentrons 10 tuberack falcon 4x50ml 6x15ml conical acrylic
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_10_tuberack_falcon_4x50ml_6x15ml_conical_acrylic
type: pylabrobot
opentrons_24_tuberack_nest_1point5ml_screwcap:
description: Opentrons 24 tuberack nest 1.5ml screwcap
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_24_tuberack_nest_1point5ml_screwcap
type: pylabrobot
opentrons_24_tuberack_nest_1point5ml_snapcap:
description: Opentrons 24 tuberack nest 1.5ml snapcap
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_24_tuberack_nest_1point5ml_snapcap
type: pylabrobot
opentrons_10_tuberack_falcon_4x50ml_6x15ml_conical:
description: Opentrons 10 tuberack falcon 4x50ml 6x15ml conical
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_10_tuberack_falcon_4x50ml_6x15ml_conical
type: pylabrobot
opentrons_24_tuberack_nest_2ml_snapcap:
description: Opentrons 24 tuberack nest 2ml snapcap
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_24_tuberack_nest_2ml_snapcap
type: pylabrobot
opentrons_24_tuberack_nest_0point5ml_screwcap:
description: Opentrons 24 tuberack nest 0.5ml screwcap
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_24_tuberack_nest_0point5ml_screwcap
type: pylabrobot
opentrons_24_tuberack_eppendorf_1point5ml_safelock_snapcap:
description: Opentrons 24 tuberack eppendorf 1.5ml safelock snapcap
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_24_tuberack_eppendorf_1point5ml_safelock_snapcap
type: pylabrobot
opentrons_6_tuberack_nest_50ml_conical:
description: Opentrons 6 tuberack nest 50ml conical
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_6_tuberack_nest_50ml_conical
type: pylabrobot
opentrons_15_tuberack_falcon_15ml_conical:
description: Opentrons 15 tuberack falcon 15ml conical
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_15_tuberack_falcon_15ml_conical
type: pylabrobot
opentrons_24_tuberack_generic_2ml_screwcap:
description: Opentrons 24 tuberack generic 2ml screwcap
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_24_tuberack_generic_2ml_screwcap
type: pylabrobot
opentrons_96_well_aluminum_block:
description: Opentrons 96 well aluminum block
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_96_well_aluminum_block
type: pylabrobot
opentrons_24_aluminumblock_generic_2ml_screwcap:
description: Opentrons 24 aluminumblock generic 2ml screwcap
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_24_aluminumblock_generic_2ml_screwcap
type: pylabrobot
opentrons_24_aluminumblock_nest_1point5ml_snapcap:
description: Opentrons 24 aluminumblock nest 1.5ml snapcap
class:
module: pylabrobot.resources.opentrons.tube_racks:opentrons_24_aluminumblock_nest_1point5ml_snapcap
type: pylabrobot