Skip to content

Commit

Permalink
fix: avoid "is not in struct" error
Browse files Browse the repository at this point in the history
  • Loading branch information
JPXKQX committed Nov 24, 2024
1 parent 7de0b44 commit 9ecde98
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/anemoi/graphs/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def update_graph(self, graph: HeteroData) -> HeteroData:

for edges_cfg in self.config.get("edges", {}):

# Remove in a future version
if "edge_builder" in edges_cfg:
warn(
"This format will be deprecated. The key 'edge_builder' is renamed to 'edge_builders' and takes a list of edge builders. In addition, the source_mask_attr_name & target_mask_attr_name fields are moved under the each edge builder.",
Expand All @@ -66,11 +67,14 @@ def update_graph(self, graph: HeteroData) -> HeteroData:

edge_builder_cfg = edges_cfg.get("edge_builder")
if edge_builder_cfg is not None:
edge_builder_cfg = DotDict(edge_builder_cfg)
edge_builder_cfg.source_mask_attr_name = edges_cfg.get("source_mask_attr_name", None)
edge_builder_cfg.target_mask_attr_name = edges_cfg.get("target_mask_attr_name", None)
edges_cfg.edge_builders = [edge_builder_cfg]
edge_builders = [edge_builder_cfg]
else:
edge_builders = edges_cfg.edge_builders

for edge_builder_cfg in edges_cfg.edge_builders:
for edge_builder_cfg in edge_builders:
edge_builder = instantiate(
edge_builder_cfg, source_name=edges_cfg.source_name, target_name=edges_cfg.target_name
)
Expand Down

0 comments on commit 9ecde98

Please sign in to comment.