From e0764126e3adfdc72b7b250c31f66e9627d9c1f1 Mon Sep 17 00:00:00 2001 From: jebus Date: Thu, 12 Mar 2026 08:28:20 +1300 Subject: [PATCH] [Fix] Scenario Review Status + Depth issues (#351) https://envipath.org/api/legacy/package/32de3cf4-e3e6-4168-956e-32fa5ddb0ce1/pathway/1d537657-298c-496b-9e6f-2bec0cbe0678 -> Node.depth can be float for Dummynodes -> Scenarios in Edge.d3_json were lacking a reviewed flag Co-authored-by: Tim Lorsbach Reviewed-on: https://git.envipath.com/enviPath/enviPy/pulls/351 --- epdb/legacy_api.py | 6 ++++-- epdb/models.py | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/epdb/legacy_api.py b/epdb/legacy_api.py index f55a6c82..4d2538af 100644 --- a/epdb/legacy_api.py +++ b/epdb/legacy_api.py @@ -94,6 +94,8 @@ class SimpleObject(Schema): return "reviewed" if obj.compound.package.reviewed else "unreviewed" elif isinstance(obj, Node) or isinstance(obj, Edge): return "reviewed" if obj.pathway.package.reviewed else "unreviewed" + elif isinstance(obj, dict) and "review_status" in obj: + return "reviewed" if obj.get("review_status") else "unreviewed" else: raise ValueError("Object has no package") @@ -1464,7 +1466,7 @@ class PathwayEdge(Schema): class PathwayNode(Schema): atomCount: int = Field(None, alias="atom_count") - depth: int = Field(None, alias="depth") + depth: float = Field(None, alias="depth") dt50s: List[Dict[str, str]] = Field([], alias="dt50s") engineeredIntermediate: bool = Field(None, alias="engineered_intermediate") id: str = Field(None, alias="url") @@ -1805,7 +1807,7 @@ class EdgeSchema(Schema): startNodes: List["EdgeNode"] = Field([], alias="start_nodes") @staticmethod - def resolve_review_status(obj: Node): + def resolve_review_status(obj: Edge): return "reviewed" if obj.pathway.package.reviewed else "unreviewed" diff --git a/epdb/models.py b/epdb/models.py index 02416265..87bac4af 100644 --- a/epdb/models.py +++ b/epdb/models.py @@ -2344,7 +2344,10 @@ class Edge(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMixin) "reaction_probability": self.kv.get("probability"), "start_node_urls": [x.url for x in self.start_nodes.all()], "end_node_urls": [x.url for x in self.end_nodes.all()], - "scenarios": [{"name": s.get_name(), "url": s.url} for s in self.scenarios.all()], + "scenarios": [ + {"name": s.get_name(), "url": s.url, "review_status": s.package.reviewed} + for s in self.scenarios.all() + ], } for n in self.start_nodes.all():