forked from enviPath/enviPy
[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 <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#351
This commit is contained in:
@ -94,6 +94,8 @@ class SimpleObject(Schema):
|
|||||||
return "reviewed" if obj.compound.package.reviewed else "unreviewed"
|
return "reviewed" if obj.compound.package.reviewed else "unreviewed"
|
||||||
elif isinstance(obj, Node) or isinstance(obj, Edge):
|
elif isinstance(obj, Node) or isinstance(obj, Edge):
|
||||||
return "reviewed" if obj.pathway.package.reviewed else "unreviewed"
|
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:
|
else:
|
||||||
raise ValueError("Object has no package")
|
raise ValueError("Object has no package")
|
||||||
|
|
||||||
@ -1464,7 +1466,7 @@ class PathwayEdge(Schema):
|
|||||||
|
|
||||||
class PathwayNode(Schema):
|
class PathwayNode(Schema):
|
||||||
atomCount: int = Field(None, alias="atom_count")
|
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")
|
dt50s: List[Dict[str, str]] = Field([], alias="dt50s")
|
||||||
engineeredIntermediate: bool = Field(None, alias="engineered_intermediate")
|
engineeredIntermediate: bool = Field(None, alias="engineered_intermediate")
|
||||||
id: str = Field(None, alias="url")
|
id: str = Field(None, alias="url")
|
||||||
@ -1805,7 +1807,7 @@ class EdgeSchema(Schema):
|
|||||||
startNodes: List["EdgeNode"] = Field([], alias="start_nodes")
|
startNodes: List["EdgeNode"] = Field([], alias="start_nodes")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resolve_review_status(obj: Node):
|
def resolve_review_status(obj: Edge):
|
||||||
return "reviewed" if obj.pathway.package.reviewed else "unreviewed"
|
return "reviewed" if obj.pathway.package.reviewed else "unreviewed"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2344,7 +2344,10 @@ class Edge(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMixin)
|
|||||||
"reaction_probability": self.kv.get("probability"),
|
"reaction_probability": self.kv.get("probability"),
|
||||||
"start_node_urls": [x.url for x in self.start_nodes.all()],
|
"start_node_urls": [x.url for x in self.start_nodes.all()],
|
||||||
"end_node_urls": [x.url for x in self.end_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():
|
for n in self.start_nodes.all():
|
||||||
|
|||||||
Reference in New Issue
Block a user