mirror of
https://github.com/deepmodeling/Uni-Lab-OS
synced 2026-04-29 02:40:01 +00:00
优化资源分配逻辑,避免在反序列化时因名称冲突导致的错误处理
This commit is contained in:
@@ -179,6 +179,11 @@ class ItemizedCarrier(ResourcePLR):
|
|||||||
idx = i
|
idx = i
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if idx is None:
|
||||||
|
# 反序列化时无法匹配 site(名称或坐标均不符),退回父类默认分配,不更新 site 跟踪
|
||||||
|
super().assign_child_resource(resource, location=location, reassign=reassign)
|
||||||
|
return
|
||||||
|
|
||||||
if not reassign and self.sites[idx] is not None:
|
if not reassign and self.sites[idx] is not None:
|
||||||
raise ValueError(f"a site with index {idx} already exists")
|
raise ValueError(f"a site with index {idx} already exists")
|
||||||
location = list(self.child_locations.values())[idx]
|
location = list(self.child_locations.values())[idx]
|
||||||
|
|||||||
@@ -611,9 +611,10 @@ class ResourceTreeSet(object):
|
|||||||
}
|
}
|
||||||
if has_model:
|
if has_model:
|
||||||
d["model"] = res.config.get("model", None)
|
d["model"] = res.config.get("model", None)
|
||||||
# 防止 Deck 子类在 __init__ 中调用 setup() 预分配子资源,
|
# 仅当 PLR dict 中含有子节点时才禁用 setup(),
|
||||||
# 与 PLR deserialize 从 children 列表再次分配同名资源产生命名冲突
|
# 防止 setup() 预分配子资源后 PLR deserialize 再次分配同名资源产生命名冲突。
|
||||||
if "setup" in d:
|
# 若 children 为空,则保留 setup=True,依赖 setup() 来初始化仓库。
|
||||||
|
if "setup" in d and d.get("children"):
|
||||||
d["setup"] = False
|
d["setup"] = False
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user