From af068d6810f8c4bde2897d3f8bf8fb6277184b7d Mon Sep 17 00:00:00 2001 From: glass-ships Date: Tue, 22 Aug 2023 14:20:18 -0600 Subject: [PATCH] ran format --- backend/src/monarch_py/api/search.py | 1 - backend/src/monarch_py/datamodels/model.py | 176 ++++++--------------- backend/tests/unit/test_fixtures.py | 1 + 3 files changed, 45 insertions(+), 133 deletions(-) diff --git a/backend/src/monarch_py/api/search.py b/backend/src/monarch_py/api/search.py index 075d085c7..aab009c0c 100644 --- a/backend/src/monarch_py/api/search.py +++ b/backend/src/monarch_py/api/search.py @@ -4,7 +4,6 @@ from monarch_py.api.additional_models import PaginationParams from monarch_py.api.config import solr -from monarch_py.api.config import settings from monarch_py.datamodels.model import SearchResults router = APIRouter( diff --git a/backend/src/monarch_py/datamodels/model.py b/backend/src/monarch_py/datamodels/model.py index 3c5882793..2a62923aa 100644 --- a/backend/src/monarch_py/datamodels/model.py +++ b/backend/src/monarch_py/datamodels/model.py @@ -47,19 +47,13 @@ class Association(ConfiguredBaseModel): id: str = Field(...) subject: str = Field(...) original_subject: Optional[str] = Field(None) - subject_namespace: Optional[str] = Field( - None, description="""The namespace/prefix of the subject entity""" - ) - subject_category: Optional[str] = Field( - None, description="""The category of the subject entity""" - ) + subject_namespace: Optional[str] = Field(None, description="""The namespace/prefix of the subject entity""") + subject_category: Optional[str] = Field(None, description="""The category of the subject entity""") subject_closure: Optional[List[str]] = Field( default_factory=list, description="""Field containing subject id and the ids of all of it's ancestors""", ) - subject_label: Optional[str] = Field( - None, description="""the label or name for the first entity""" - ) + subject_label: Optional[str] = Field(None, description="""the label or name for the first entity""") subject_closure_label: Optional[List[str]] = Field( default_factory=list, description="""Field containing subject name and the names of all of it's ancestors""", @@ -69,19 +63,13 @@ class Association(ConfiguredBaseModel): predicate: str = Field(...) object: str = Field(...) original_object: Optional[str] = Field(None) - object_namespace: Optional[str] = Field( - None, description="""The namespace/prefix of the object entity""" - ) - object_category: Optional[str] = Field( - None, description="""The category of the object entity""" - ) + object_namespace: Optional[str] = Field(None, description="""The namespace/prefix of the object entity""") + object_category: Optional[str] = Field(None, description="""The category of the object entity""") object_closure: Optional[List[str]] = Field( default_factory=list, description="""Field containing object id and the ids of all of it's ancestors""", ) - object_label: Optional[str] = Field( - None, description="""the label or name for the second entity""" - ) + object_label: Optional[str] = Field(None, description="""the label or name for the second entity""") object_closure_label: Optional[List[str]] = Field( default_factory=list, description="""Field containing object name and the names of all of it's ancestors""", @@ -109,9 +97,7 @@ class Association(ConfiguredBaseModel): description="""count of supporting documents, evidence codes, and sources supplying evidence""", ) pathway: Optional[str] = Field(None) - frequency_qualifier_label: Optional[str] = Field( - None, description="""The name of the frequency_qualifier entity""" - ) + frequency_qualifier_label: Optional[str] = Field(None, description="""The name of the frequency_qualifier entity""") frequency_qualifier_namespace: Optional[str] = Field( None, description="""The namespace/prefix of the frequency_qualifier entity""" ) @@ -126,15 +112,11 @@ class Association(ConfiguredBaseModel): default_factory=list, description="""Field containing frequency_qualifier name and the names of all of it's ancestors""", ) - onset_qualifier_label: Optional[str] = Field( - None, description="""The name of the onset_qualifier entity""" - ) + onset_qualifier_label: Optional[str] = Field(None, description="""The name of the onset_qualifier entity""") onset_qualifier_namespace: Optional[str] = Field( None, description="""The namespace/prefix of the onset_qualifier entity""" ) - onset_qualifier_category: Optional[str] = Field( - None, description="""The category of the onset_qualifier entity""" - ) + onset_qualifier_category: Optional[str] = Field(None, description="""The category of the onset_qualifier entity""") onset_qualifier_closure: Optional[List[str]] = Field( default_factory=list, description="""Field containing onset_qualifier id and the ids of all of it's ancestors""", @@ -143,15 +125,11 @@ class Association(ConfiguredBaseModel): default_factory=list, description="""Field containing onset_qualifier name and the names of all of it's ancestors""", ) - sex_qualifier_label: Optional[str] = Field( - None, description="""The name of the sex_qualifier entity""" - ) + sex_qualifier_label: Optional[str] = Field(None, description="""The name of the sex_qualifier entity""") sex_qualifier_namespace: Optional[str] = Field( None, description="""The namespace/prefix of the sex_qualifier entity""" ) - sex_qualifier_category: Optional[str] = Field( - None, description="""The category of the sex_qualifier entity""" - ) + sex_qualifier_category: Optional[str] = Field(None, description="""The category of the sex_qualifier entity""") sex_qualifier_closure: Optional[List[str]] = Field( default_factory=list, description="""Field containing sex_qualifier id and the ids of all of it's ancestors""", @@ -160,15 +138,11 @@ class Association(ConfiguredBaseModel): default_factory=list, description="""Field containing sex_qualifier name and the names of all of it's ancestors""", ) - stage_qualifier_label: Optional[str] = Field( - None, description="""The name of the stage_qualifier entity""" - ) + stage_qualifier_label: Optional[str] = Field(None, description="""The name of the stage_qualifier entity""") stage_qualifier_namespace: Optional[str] = Field( None, description="""The namespace/prefix of the stage_qualifier entity""" ) - stage_qualifier_category: Optional[str] = Field( - None, description="""The category of the stage_qualifier entity""" - ) + stage_qualifier_category: Optional[str] = Field(None, description="""The category of the stage_qualifier entity""") stage_qualifier_closure: Optional[List[str]] = Field( default_factory=list, description="""Field containing stage_qualifier id and the ids of all of it's ancestors""", @@ -225,19 +199,13 @@ class DirectionalAssociation(Association): id: str = Field(...) subject: str = Field(...) original_subject: Optional[str] = Field(None) - subject_namespace: Optional[str] = Field( - None, description="""The namespace/prefix of the subject entity""" - ) - subject_category: Optional[str] = Field( - None, description="""The category of the subject entity""" - ) + subject_namespace: Optional[str] = Field(None, description="""The namespace/prefix of the subject entity""") + subject_category: Optional[str] = Field(None, description="""The category of the subject entity""") subject_closure: Optional[List[str]] = Field( default_factory=list, description="""Field containing subject id and the ids of all of it's ancestors""", ) - subject_label: Optional[str] = Field( - None, description="""the label or name for the first entity""" - ) + subject_label: Optional[str] = Field(None, description="""the label or name for the first entity""") subject_closure_label: Optional[List[str]] = Field( default_factory=list, description="""Field containing subject name and the names of all of it's ancestors""", @@ -247,19 +215,13 @@ class DirectionalAssociation(Association): predicate: str = Field(...) object: str = Field(...) original_object: Optional[str] = Field(None) - object_namespace: Optional[str] = Field( - None, description="""The namespace/prefix of the object entity""" - ) - object_category: Optional[str] = Field( - None, description="""The category of the object entity""" - ) + object_namespace: Optional[str] = Field(None, description="""The namespace/prefix of the object entity""") + object_category: Optional[str] = Field(None, description="""The category of the object entity""") object_closure: Optional[List[str]] = Field( default_factory=list, description="""Field containing object id and the ids of all of it's ancestors""", ) - object_label: Optional[str] = Field( - None, description="""the label or name for the second entity""" - ) + object_label: Optional[str] = Field(None, description="""the label or name for the second entity""") object_closure_label: Optional[List[str]] = Field( default_factory=list, description="""Field containing object name and the names of all of it's ancestors""", @@ -287,9 +249,7 @@ class DirectionalAssociation(Association): description="""count of supporting documents, evidence codes, and sources supplying evidence""", ) pathway: Optional[str] = Field(None) - frequency_qualifier_label: Optional[str] = Field( - None, description="""The name of the frequency_qualifier entity""" - ) + frequency_qualifier_label: Optional[str] = Field(None, description="""The name of the frequency_qualifier entity""") frequency_qualifier_namespace: Optional[str] = Field( None, description="""The namespace/prefix of the frequency_qualifier entity""" ) @@ -304,15 +264,11 @@ class DirectionalAssociation(Association): default_factory=list, description="""Field containing frequency_qualifier name and the names of all of it's ancestors""", ) - onset_qualifier_label: Optional[str] = Field( - None, description="""The name of the onset_qualifier entity""" - ) + onset_qualifier_label: Optional[str] = Field(None, description="""The name of the onset_qualifier entity""") onset_qualifier_namespace: Optional[str] = Field( None, description="""The namespace/prefix of the onset_qualifier entity""" ) - onset_qualifier_category: Optional[str] = Field( - None, description="""The category of the onset_qualifier entity""" - ) + onset_qualifier_category: Optional[str] = Field(None, description="""The category of the onset_qualifier entity""") onset_qualifier_closure: Optional[List[str]] = Field( default_factory=list, description="""Field containing onset_qualifier id and the ids of all of it's ancestors""", @@ -321,15 +277,11 @@ class DirectionalAssociation(Association): default_factory=list, description="""Field containing onset_qualifier name and the names of all of it's ancestors""", ) - sex_qualifier_label: Optional[str] = Field( - None, description="""The name of the sex_qualifier entity""" - ) + sex_qualifier_label: Optional[str] = Field(None, description="""The name of the sex_qualifier entity""") sex_qualifier_namespace: Optional[str] = Field( None, description="""The namespace/prefix of the sex_qualifier entity""" ) - sex_qualifier_category: Optional[str] = Field( - None, description="""The category of the sex_qualifier entity""" - ) + sex_qualifier_category: Optional[str] = Field(None, description="""The category of the sex_qualifier entity""") sex_qualifier_closure: Optional[List[str]] = Field( default_factory=list, description="""Field containing sex_qualifier id and the ids of all of it's ancestors""", @@ -338,15 +290,11 @@ class DirectionalAssociation(Association): default_factory=list, description="""Field containing sex_qualifier name and the names of all of it's ancestors""", ) - stage_qualifier_label: Optional[str] = Field( - None, description="""The name of the stage_qualifier entity""" - ) + stage_qualifier_label: Optional[str] = Field(None, description="""The name of the stage_qualifier entity""") stage_qualifier_namespace: Optional[str] = Field( None, description="""The namespace/prefix of the stage_qualifier entity""" ) - stage_qualifier_category: Optional[str] = Field( - None, description="""The category of the stage_qualifier entity""" - ) + stage_qualifier_category: Optional[str] = Field(None, description="""The category of the stage_qualifier entity""") stage_qualifier_closure: Optional[List[str]] = Field( default_factory=list, description="""Field containing stage_qualifier id and the ids of all of it's ancestors""", @@ -374,15 +322,11 @@ class Entity(ConfiguredBaseModel): id: str = Field(...) category: Optional[str] = Field(None) name: Optional[str] = Field(None) - full_name: Optional[str] = Field( - None, description="""The long form name of an entity""" - ) + full_name: Optional[str] = Field(None, description="""The long form name of an entity""") description: Optional[str] = Field(None) xref: Optional[List[str]] = Field(default_factory=list) provided_by: Optional[str] = Field(None) - in_taxon: Optional[str] = Field( - None, description="""The biolink taxon that the entity is in the closure of.""" - ) + in_taxon: Optional[str] = Field(None, description="""The biolink taxon that the entity is in the closure of.""") in_taxon_label: Optional[str] = Field( None, description="""The label of the biolink taxon that the entity is in the closure of.""", @@ -434,9 +378,7 @@ class Node(Entity): UI container class extending Entity with additional information """ - in_taxon: Optional[str] = Field( - None, description="""The biolink taxon that the entity is in the closure of.""" - ) + in_taxon: Optional[str] = Field(None, description="""The biolink taxon that the entity is in the closure of.""") in_taxon_label: Optional[str] = Field( None, description="""The label of the biolink taxon that the entity is in the closure of.""", @@ -454,9 +396,7 @@ class Node(Entity): id: str = Field(...) category: Optional[str] = Field(None) name: Optional[str] = Field(None) - full_name: Optional[str] = Field( - None, description="""The long form name of an entity""" - ) + full_name: Optional[str] = Field(None, description="""The long form name of an entity""") description: Optional[str] = Field(None) xref: Optional[List[str]] = Field(default_factory=list) provided_by: Optional[str] = Field(None) @@ -513,24 +453,16 @@ class EntityResults(Results): class SearchResult(Entity): - highlight: Optional[str] = Field( - None, description="""matching text snippet containing html tags""" - ) - score: Optional[str] = Field( - None, description="""Abstract base slot for different kinds of scores""" - ) + highlight: Optional[str] = Field(None, description="""matching text snippet containing html tags""") + score: Optional[str] = Field(None, description="""Abstract base slot for different kinds of scores""") id: str = Field(...) category: str = Field(...) name: str = Field(...) - full_name: Optional[str] = Field( - None, description="""The long form name of an entity""" - ) + full_name: Optional[str] = Field(None, description="""The long form name of an entity""") description: Optional[str] = Field(None) xref: Optional[List[str]] = Field(default_factory=list) provided_by: Optional[str] = Field(None) - in_taxon: Optional[str] = Field( - None, description="""The biolink taxon that the entity is in the closure of.""" - ) + in_taxon: Optional[str] = Field(None, description="""The biolink taxon that the entity is in the closure of.""") in_taxon_label: Optional[str] = Field( None, description="""The label of the biolink taxon that the entity is in the closure of.""", @@ -571,41 +503,21 @@ class TermPairwiseSimilarity(PairwiseSimilarity): A simple pairwise similarity between two atomic concepts/terms """ - subject_id: str = Field( - ..., description="""The first of the two entities being compared""" - ) - subject_label: Optional[str] = Field( - None, description="""the label or name for the first entity""" - ) - subject_source: Optional[str] = Field( - None, description="""the source for the first entity""" - ) - object_id: Optional[str] = Field( - None, description="""The second of the two entities being compared""" - ) - object_label: Optional[str] = Field( - None, description="""the label or name for the second entity""" - ) - object_source: Optional[str] = Field( - None, description="""the source for the second entity""" - ) + subject_id: str = Field(..., description="""The first of the two entities being compared""") + subject_label: Optional[str] = Field(None, description="""the label or name for the first entity""") + subject_source: Optional[str] = Field(None, description="""the source for the first entity""") + object_id: Optional[str] = Field(None, description="""The second of the two entities being compared""") + object_label: Optional[str] = Field(None, description="""the label or name for the second entity""") + object_source: Optional[str] = Field(None, description="""the source for the second entity""") ancestor_id: Optional[str] = Field( None, description="""the most recent common ancestor of the two compared entities. If there are multiple MRCAs then the most informative one is selected""", ) - ancestor_label: Optional[str] = Field( - None, description="""the name or label of the ancestor concept""" - ) + ancestor_label: Optional[str] = Field(None, description="""the name or label of the ancestor concept""") ancestor_source: Optional[str] = Field(None) - object_information_content: Optional[float] = Field( - None, description="""The IC of the object""" - ) - subject_information_content: Optional[float] = Field( - None, description="""The IC of the subject""" - ) - ancestor_information_content: Optional[float] = Field( - None, description="""The IC of the object""" - ) + object_information_content: Optional[float] = Field(None, description="""The IC of the object""") + subject_information_content: Optional[float] = Field(None, description="""The IC of the subject""") + ancestor_information_content: Optional[float] = Field(None, description="""The IC of the object""") jaccard_similarity: Optional[float] = Field( None, description="""The number of concepts in the intersection divided by the number in the union""", diff --git a/backend/tests/unit/test_fixtures.py b/backend/tests/unit/test_fixtures.py index e88856865..23597dedf 100644 --- a/backend/tests/unit/test_fixtures.py +++ b/backend/tests/unit/test_fixtures.py @@ -16,6 +16,7 @@ def test_autocomplete(autocomplete): def test_compare(compare): tsps = TermSetPairwiseSimilarity(**compare) import pprint + pprint.PrettyPrinter(indent=2).pprint(tsps.dict()) assert len(tsps.subject_best_matches) != 0