mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 21:11:12 +00:00
save resource get data. allow empty value for layout and cross_section_type
This commit is contained in:
@@ -126,12 +126,16 @@ class HTTPClient:
|
|||||||
Returns:
|
Returns:
|
||||||
Dict[str, str]: 旧UUID到新UUID的映射关系 {old_uuid: new_uuid}
|
Dict[str, str]: 旧UUID到新UUID的映射关系 {old_uuid: new_uuid}
|
||||||
"""
|
"""
|
||||||
|
with open(os.path.join(BasicConfig.working_dir, "req_resource_tree_get.json"), "w", encoding="utf-8") as f:
|
||||||
|
f.write(json.dumps({"uuids": uuid_list, "with_children": with_children}, indent=4))
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
f"{self.remote_addr}/edge/material/query",
|
f"{self.remote_addr}/edge/material/query",
|
||||||
json={"uuids": uuid_list, "with_children": with_children},
|
json={"uuids": uuid_list, "with_children": with_children},
|
||||||
headers={"Authorization": f"Lab {self.auth}"},
|
headers={"Authorization": f"Lab {self.auth}"},
|
||||||
timeout=100,
|
timeout=100,
|
||||||
)
|
)
|
||||||
|
with open(os.path.join(BasicConfig.working_dir, "res_resource_tree_get.json"), "w", encoding="utf-8") as f:
|
||||||
|
f.write(f"{response.status_code}" + "\n" + response.text)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
res = response.json()
|
res = response.json()
|
||||||
if "code" in res and res["code"] != 0:
|
if "code" in res and res["code"] != 0:
|
||||||
@@ -187,12 +191,16 @@ class HTTPClient:
|
|||||||
Returns:
|
Returns:
|
||||||
Dict: 返回的资源数据
|
Dict: 返回的资源数据
|
||||||
"""
|
"""
|
||||||
|
with open(os.path.join(BasicConfig.working_dir, "req_resource_get.json"), "w", encoding="utf-8") as f:
|
||||||
|
f.write(json.dumps({"id": id, "with_children": with_children}, indent=4))
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
f"{self.remote_addr}/lab/material",
|
f"{self.remote_addr}/lab/material",
|
||||||
params={"id": id, "with_children": with_children},
|
params={"id": id, "with_children": with_children},
|
||||||
headers={"Authorization": f"Lab {self.auth}"},
|
headers={"Authorization": f"Lab {self.auth}"},
|
||||||
timeout=20,
|
timeout=20,
|
||||||
)
|
)
|
||||||
|
with open(os.path.join(BasicConfig.working_dir, "req_resource_get.json"), "w", encoding="utf-8") as f:
|
||||||
|
f.write(f"{response.status_code}" + "\n" + response.text)
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def resource_del(self, id: str) -> requests.Response:
|
def resource_del(self, id: str) -> requests.Response:
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class ResourceDictPositionObject(BaseModel):
|
|||||||
class ResourceDictPosition(BaseModel):
|
class ResourceDictPosition(BaseModel):
|
||||||
size: ResourceDictPositionSize = Field(description="Resource size", default_factory=ResourceDictPositionSize)
|
size: ResourceDictPositionSize = Field(description="Resource size", default_factory=ResourceDictPositionSize)
|
||||||
scale: ResourceDictPositionScale = Field(description="Resource scale", default_factory=ResourceDictPositionScale)
|
scale: ResourceDictPositionScale = Field(description="Resource scale", default_factory=ResourceDictPositionScale)
|
||||||
layout: Literal["2d", "x-y", "z-y", "x-z"] = Field(description="Resource layout", default="x-y")
|
layout: Literal["2d", "x-y", "z-y", "x-z", ""] = Field(description="Resource layout", default="x-y")
|
||||||
position: ResourceDictPositionObject = Field(
|
position: ResourceDictPositionObject = Field(
|
||||||
description="Resource position", default_factory=ResourceDictPositionObject
|
description="Resource position", default_factory=ResourceDictPositionObject
|
||||||
)
|
)
|
||||||
@@ -42,7 +42,7 @@ class ResourceDictPosition(BaseModel):
|
|||||||
rotation: ResourceDictPositionObject = Field(
|
rotation: ResourceDictPositionObject = Field(
|
||||||
description="Resource rotation", default_factory=ResourceDictPositionObject
|
description="Resource rotation", default_factory=ResourceDictPositionObject
|
||||||
)
|
)
|
||||||
cross_section_type: Literal["rectangle", "circle", "rounded_rectangle"] = Field(description="Cross section type", default="rectangle")
|
cross_section_type: Literal["rectangle", "circle", "rounded_rectangle", ""] = Field(description="Cross section type", default="rectangle")
|
||||||
|
|
||||||
|
|
||||||
# 统一的资源字典模型,parent 自动序列化为 parent_uuid,children 不序列化
|
# 统一的资源字典模型,parent 自动序列化为 parent_uuid,children 不序列化
|
||||||
@@ -311,12 +311,16 @@ class ResourceTreeSet(object):
|
|||||||
"plate": "plate",
|
"plate": "plate",
|
||||||
"well": "well",
|
"well": "well",
|
||||||
"deck": "deck",
|
"deck": "deck",
|
||||||
|
"tip_rack": "tip_rack",
|
||||||
|
"tip_spot": "tip_spot",
|
||||||
|
"tube": "tube",
|
||||||
|
"bottle_carrier": "bottle_carrier",
|
||||||
}
|
}
|
||||||
if source in replace_info:
|
if source in replace_info:
|
||||||
return replace_info[source]
|
return replace_info[source]
|
||||||
else:
|
else:
|
||||||
print("转换pylabrobot的时候,出现未知类型", source)
|
print("转换pylabrobot的时候,出现未知类型", source)
|
||||||
return "container"
|
return source
|
||||||
|
|
||||||
def build_uuid_mapping(res: "PLRResource", uuid_list: list):
|
def build_uuid_mapping(res: "PLRResource", uuid_list: list):
|
||||||
"""递归构建uuid映射字典"""
|
"""递归构建uuid映射字典"""
|
||||||
@@ -402,7 +406,7 @@ class ResourceTreeSet(object):
|
|||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
# 类型映射
|
# 类型映射
|
||||||
TYPE_MAP = {"plate": "Plate", "well": "Well", "deck": "Deck"}
|
TYPE_MAP = {"plate": "Plate", "well": "Well", "deck": "Deck", "container": "RegularContainer"}
|
||||||
|
|
||||||
def collect_node_data(node: ResourceDictInstance, name_to_uuid: dict, all_states: dict):
|
def collect_node_data(node: ResourceDictInstance, name_to_uuid: dict, all_states: dict):
|
||||||
"""一次遍历收集 name_to_uuid 和 all_states"""
|
"""一次遍历收集 name_to_uuid 和 all_states"""
|
||||||
|
|||||||
Reference in New Issue
Block a user