mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 21:11:12 +00:00
增加handle检测,增加material edge关系上传
This commit is contained in:
@@ -258,7 +258,7 @@ def main():
|
|||||||
print_unilab_banner(args_dict)
|
print_unilab_banner(args_dict)
|
||||||
|
|
||||||
# 注册表
|
# 注册表
|
||||||
build_registry(args_dict["registry_path"], False, args_dict["upload_registry"])
|
lab_registry = build_registry(args_dict["registry_path"], False, args_dict["upload_registry"])
|
||||||
if args_dict["graph"] is None:
|
if args_dict["graph"] is None:
|
||||||
request_startup_json = http_client.request_startup_json()
|
request_startup_json = http_client.request_startup_json()
|
||||||
if not request_startup_json:
|
if not request_startup_json:
|
||||||
@@ -279,6 +279,27 @@ def main():
|
|||||||
|
|
||||||
graph_res.physical_setup_graph = graph
|
graph_res.physical_setup_graph = graph
|
||||||
resource_edge_info = modify_to_backend_format(data["links"])
|
resource_edge_info = modify_to_backend_format(data["links"])
|
||||||
|
materials = lab_registry.obtain_registry_resource_info()
|
||||||
|
materials.extend(lab_registry.obtain_registry_device_info())
|
||||||
|
materials = {k["id"]: k for k in materials}
|
||||||
|
nodes = {k["id"]: k for k in data["nodes"]}
|
||||||
|
|
||||||
|
for ind, i in enumerate(resource_edge_info[::-1]):
|
||||||
|
source_node = nodes[i["source"]]
|
||||||
|
target_node = nodes[i["target"]]
|
||||||
|
source_handle = i["sourceHandle"]
|
||||||
|
target_handle = i["targetHandle"]
|
||||||
|
source_handler_keys = [h["handler_key"] for h in materials[source_node["class"]]["handles"] if h["io_type"] == 'source']
|
||||||
|
target_handler_keys = [h["handler_key"] for h in materials[target_node["class"]]["handles"] if h["io_type"] == 'target']
|
||||||
|
if not source_handle in source_handler_keys:
|
||||||
|
print_status(f"节点 {source_node['id']} 的source端点 {source_handle} 不存在,请检查,支持的端点 {source_handler_keys}", "error")
|
||||||
|
resource_edge_info.pop(-ind - 1)
|
||||||
|
continue
|
||||||
|
if not target_handle in target_handler_keys:
|
||||||
|
print_status(f"节点 {target_node['id']} 的target端点 {target_handle} 不存在,请检查,支持的端点 {target_handler_keys}", "error")
|
||||||
|
resource_edge_info.pop(-ind - 1)
|
||||||
|
continue
|
||||||
|
|
||||||
devices_and_resources = dict_from_graph(graph_res.physical_setup_graph)
|
devices_and_resources = dict_from_graph(graph_res.physical_setup_graph)
|
||||||
# args_dict["resources_config"] = initialize_resources(list(deepcopy(devices_and_resources).values()))
|
# args_dict["resources_config"] = initialize_resources(list(deepcopy(devices_and_resources).values()))
|
||||||
args_dict["resources_config"] = list(devices_and_resources.values())
|
args_dict["resources_config"] = list(devices_and_resources.values())
|
||||||
|
|||||||
@@ -58,10 +58,12 @@ class HTTPClient:
|
|||||||
headers={"Authorization": f"{'lab' if not self.backend_go else 'Lab'} {self.auth}"},
|
headers={"Authorization": f"{'lab' if not self.backend_go else 'Lab'} {self.auth}"},
|
||||||
timeout=100,
|
timeout=100,
|
||||||
)
|
)
|
||||||
|
if self.backend_go and response.status_code == 200:
|
||||||
|
res = response.json()
|
||||||
|
if "code" in res and res["code"] != 0:
|
||||||
|
logger.error(f"添加物料关系失败: {response.text}")
|
||||||
if response.status_code != 200 and response.status_code != 201:
|
if response.status_code != 200 and response.status_code != 201:
|
||||||
logger.error(f"添加物料关系失败: {response.status_code}, {response.text}")
|
logger.error(f"添加物料关系失败: {response.status_code}, {response.text}")
|
||||||
elif self.backend_go:
|
|
||||||
logger.info(f"添加物料关系 {response.text}")
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def resource_add(self, resources: List[Dict[str, Any]], database_process_later: bool) -> requests.Response:
|
def resource_add(self, resources: List[Dict[str, Any]], database_process_later: bool) -> requests.Response:
|
||||||
@@ -80,10 +82,12 @@ class HTTPClient:
|
|||||||
headers={"Authorization": f"{'lab' if not self.backend_go else 'Lab'} {self.auth}"},
|
headers={"Authorization": f"{'lab' if not self.backend_go else 'Lab'} {self.auth}"},
|
||||||
timeout=100,
|
timeout=100,
|
||||||
)
|
)
|
||||||
|
if self.backend_go and response.status_code == 200:
|
||||||
|
res = response.json()
|
||||||
|
if "code" in res and res["code"] != 0:
|
||||||
|
logger.error(f"添加物料失败: {response.text}")
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
logger.error(f"添加物料失败: {response.text}")
|
logger.error(f"添加物料失败: {response.text}")
|
||||||
elif self.backend_go:
|
|
||||||
logger.info(f"添加物料 {response.text}")
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def resource_get(self, id: str, with_children: bool = False) -> Dict[str, Any]:
|
def resource_get(self, id: str, with_children: bool = False) -> Dict[str, Any]:
|
||||||
|
|||||||
Reference in New Issue
Block a user