Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
glass-ships committed Dec 11, 2023
2 parents 86cb839 + 35998f2 commit 7f48e37
Show file tree
Hide file tree
Showing 66 changed files with 15,700 additions and 19,176 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/build-and-deploy-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,18 @@ jobs:
with:
version: ">= 447.0.0"

- name: "Cache SSH Key"
uses: actions/cache@v3
with:
path: ~/.ssh/google_compute_engine
key: ${{ runner.os }}-ssh-key

- name: "Update API Service"
run: gcloud compute ssh --zone us-central1-a monarch-v3-dev-manager -- sudo docker service update monarch-v3_api --with-registry-auth --update-order=start-first --force --image us-central1-docker.pkg.dev/monarch-initiative/monarch-api/monarch-api:${{ github.sha }}
run: |
gcloud compute ssh --ssh-key-expiration 60m --zone us-central1-a monarch-v3-dev-manager -- sudo docker system prune -f
gcloud compute ssh --ssh-key-expiration 60m --zone us-central1-a monarch-v3-dev-manager -- sudo docker service update monarch-v3_api --with-registry-auth --update-order=start-first --force --image us-central1-docker.pkg.dev/monarch-initiative/monarch-api/monarch-api:${{ github.sha }}
- name: "Update UI Service"
run: gcloud compute ssh --zone us-central1-a monarch-v3-dev-manager -- sudo docker service update monarch-v3_nginx --with-registry-auth --update-order=start-first --force --image us-central1-docker.pkg.dev/monarch-initiative/monarch-api/monarch-ui:${{ github.sha }}
run: |
gcloud compute ssh --ssh-key-expiration 60m --zone us-central1-a monarch-v3-dev-manager -- sudo docker system prune -f
gcloud compute ssh --ssh-key-expiration 60m --zone us-central1-a monarch-v3-dev-manager -- sudo docker service update monarch-v3_nginx --with-registry-auth --update-order=start-first --force --image us-central1-docker.pkg.dev/monarch-initiative/monarch-api/monarch-ui:${{ github.sha }}
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ install-frontend:
model: install-backend
$(RUN) gen-pydantic $(SCHEMADIR)/model.yaml > $(SCHEMADIR)/model.py
$(RUN) gen-typescript $(SCHEMADIR)/model.yaml > frontend/src/api/model.ts
$(RUN) black $(SCHEMADIR)/model.py
make format


### Documentation ###
Expand Down Expand Up @@ -111,11 +111,20 @@ test-frontend:

.PHONY: fixtures
fixtures:
@echo "Generating fixtures..."
@echo "Generating fixtures and data..."
$(RUN) python scripts/generate_fixtures.py --all-fixtures
$(RUN) black -l 120 backend/tests/fixtures/
cd frontend && \
yarn lint
make format


.PHONY: data
data:
@echo "Generating frontpage metadata..."
$(RUN) python scripts/generate_fixtures.py --metadata
@echo "Generating publications data..."
$(RUN) python scripts/get_publications.py
@echo "Generating resources data..."
wget https://raw.githubusercontent.com/monarch-initiative/monarch-documentation/main/src/docs/resources/monarch-app-resources.json -O frontend/src/pages/resources/resources.json
make format-frontend

### Development ###

Expand Down
445 changes: 238 additions & 207 deletions backend/poetry.lock

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions backend/src/monarch_py/datamodels/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ class Entity(ConfiguredBaseModel):
category: Optional[str] = Field(None)
name: Optional[str] = Field(None)
full_name: Optional[str] = Field(None, description="""The long form name of an entity""")
deprecated: Optional[bool] = Field(
None,
description="""A boolean flag indicating that an entity is no longer considered current or valid.""",
)
description: Optional[str] = Field(None)
xref: Optional[List[str]] = Field(default_factory=list)
provided_by: Optional[str] = Field(None)
Expand Down Expand Up @@ -474,6 +478,10 @@ class Node(Entity):
category: Optional[str] = Field(None)
name: Optional[str] = Field(None)
full_name: Optional[str] = Field(None, description="""The long form name of an entity""")
deprecated: Optional[bool] = Field(
None,
description="""A boolean flag indicating that an entity is no longer considered current or valid.""",
)
description: Optional[str] = Field(None)
xref: Optional[List[str]] = Field(default_factory=list)
provided_by: Optional[str] = Field(None)
Expand Down Expand Up @@ -575,6 +583,10 @@ class SearchResult(Entity):
category: str = Field(...)
name: str = Field(...)
full_name: Optional[str] = Field(None, description="""The long form name of an entity""")
deprecated: Optional[bool] = Field(
None,
description="""A boolean flag indicating that an entity is no longer considered current or valid.""",
)
description: Optional[str] = Field(None)
xref: Optional[List[str]] = Field(default_factory=list)
provided_by: Optional[str] = Field(None)
Expand Down
8 changes: 8 additions & 0 deletions backend/src/monarch_py/datamodels/model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ classes:
- category
- name
- full_name
- deprecated
- description
- xref
- provided_by
Expand Down Expand Up @@ -304,6 +305,13 @@ slots:
The category of the counterpart entity in a given association,
eg. the category of the entity that is not the subject
range: string
deprecated:
description: >-
A boolean flag indicating that an entity is no longer considered current or valid.
range: boolean
exact_mappings:
- oboInOwl:ObsoleteClass

description:
range: string
direction:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def parse_association_counts(query_result: SolrQueryResult, entity: str) -> Asso
def parse_entity(solr_document: Dict) -> Entity:
try:
entity = Entity(**solr_document)

entity.uri = get_uri(entity.id)
except ValidationError:
logger.error(f"Validation error for {solr_document}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ def entity_boost():
"""Shared boost function between search and autocomplete"""
disease_boost = 'if(termfreq(category,"biolink:Disease"),10.0,1)'
human_gene_boost = 'if(and(termfreq(in_taxon,"NCBITaxon:9606"),termfreq(category,"biolink:Gene")),5.0,1)'
return f"product({disease_boost},{human_gene_boost})"
obsolete_unboost = 'if(termfreq(deprecated,"true"),0.1,1)'
return f"product({disease_boost},{human_gene_boost},{obsolete_unboost})"


def entity_query_fields():
Expand Down
6 changes: 2 additions & 4 deletions backend/src/monarch_py/service/curie_service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### make a singleton class that uses prefixmap and curies to expand curies

from curies import Converter
from prefixmaps.io.parser import load_multi_context
from prefixmaps import load_converter


class CurieService:
Expand All @@ -17,9 +17,7 @@ def __new__(cls):
def initialize(self):
# this is a magic keyword that represents the "merged" context from Chris M's algorithm
# (https://github.com/linkml/prefixmaps/blob/main/src/prefixmaps/data/merged.csv)
context = load_multi_context(["merged"])
extended_prefix_map = context.as_extended_prefix_map()
self.converter = Converter.from_extended_prefix_map(extended_prefix_map)
self.converter = load_converter(["merged"])

def expand(self, curie: str) -> str:
return self.converter.expand(curie)
4 changes: 2 additions & 2 deletions backend/src/monarch_py/service/solr_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get(self, id):
response.raise_for_status()
entity = response.json()["doc"]
try:
self._strip_json(entity, "_version_")
self._strip_json(entity, "_version_", "iri")
except TypeError: # if entity is None
return None
return entity
Expand All @@ -33,7 +33,7 @@ def query(self, q: SolrQuery) -> SolrQueryResult:
response.raise_for_status()
solr_query_result = SolrQueryResult.parse_obj(data)
for doc in solr_query_result.response.docs:
self._strip_json(doc, "_version_")
self._strip_json(doc, "_version_", "iri")

return solr_query_result

Expand Down
Loading

0 comments on commit 7f48e37

Please sign in to comment.