Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ lint-frontend:

.PHONY: lint-backend
lint-backend:
$(RUN) ruff check --diff --exit-zero .
$(RUN) black --check --diff -l 120 src tests
-$(RUN) ruff check --diff .
-$(RUN) ruff format --diff .


.PHONY: format
Expand All @@ -208,8 +208,8 @@ format: format-frontend format-backend

.PHONY: format-backend
format-backend:
$(RUN) ruff check --fix --exit-zero .
$(RUN) black -l 120 src tests
-$(RUN) ruff check --fix .
-$(RUN) ruff format .


.PHONY: format-frontend
Expand Down
4 changes: 4 additions & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ pythonpath = [".", "src"]

[tool.ruff]
line-length = 120
exclude = ["tests/fixtures/*.py", "src/monarch_py/datamodels/model.py"]
# per-file-ignores = {"" = ""}

[tool.ruff.lint]
ignore = [
"F541", # f-strings with no placeholders
]
Expand Down
2 changes: 1 addition & 1 deletion backend/src/monarch_py/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Settings(BaseModel):

semsim_server_host: str = os.getenv("SEMSIM_SERVER_HOST", "127.0.0.1")
semsim_server_port: str = os.getenv("SEMSIM_SERVER_PORT", 9999)

monarch_kg_version: str = os.getenv("MONARCH_KG_VERSION", "unknown")
monarch_api_version: str = os.getenv("MONARCH_API_VERSION", "unknown")
monarch_kg_source: str = os.getenv("MONARCH_KG_SOURCE", "unknown")
Expand Down
2 changes: 1 addition & 1 deletion backend/src/monarch_py/api/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async def autocomplete(
default="*:*",
title="Query string to autocomplete against",
examples=["fanc", "ehler"],
)
),
) -> SearchResults:
"""Autocomplete for entities by label

Expand Down
4 changes: 2 additions & 2 deletions backend/src/monarch_py/api/semsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def _compare(
print(
f"""
Running semsim compare:
subjects: {subjects.split(',')}
objects: {objects.split(',')}
subjects: {subjects.split(",")}
objects: {objects.split(",")}
metric: {metric}
"""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def build_association_query(
offset: int = 0,
limit: int = 20,
) -> SolrQuery:

entity_fields = ["subject", "object", "disease_context_qualifier"]
"""Populate a SolrQuery object with association filters"""
query = SolrQuery(start=offset, rows=limit)
Expand Down
2 changes: 1 addition & 1 deletion backend/src/monarch_py/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ def get_release_metadata(release: str, dev: bool = False):

def print_release_info(release_info: Release):
for key, value in release_info.model_dump().items():
console.print(f"{key+' ':—<12} {value}")
console.print(f"{key + ' ':—<12} {value}")
1 change: 0 additions & 1 deletion backend/tests/integration/test_solr_association.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def test_entity():
assert response
assert response.total > 50
for association in response.items:

if (
association.subject_closure is None or len(association.subject_closure) == 0
) and association.disease_context_qualifier is None:
Expand Down
1 change: 0 additions & 1 deletion backend/tests/unit/test_oak_semsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

@pytest.mark.skip(reason="This is a long running test")
def test_semsim_compare():

subject_ids = ["MP:0010771"]
object_ids = ["HP:0004325"]

Expand Down
6 changes: 3 additions & 3 deletions backend/tests/unit/test_solr_entity_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def test_get_counterpart_entity(association, this_entity, other_entity):
"""Test that the get_counterpart_entity function returns the correct entity"""
si = SolrImplementation()
associated_entity = si._get_counterpart_entity(association, this_entity)
assert (
associated_entity == other_entity
), f"Associated entity is not as expected. Expected: {other_entity}, got: {associated_entity}"
assert associated_entity == other_entity, (
f"Associated entity is not as expected. Expected: {other_entity}, got: {associated_entity}"
)


def test_entity_boost_with_empty_calls_blank_search_boost():
Expand Down
30 changes: 15 additions & 15 deletions backend/tests/unit/test_solr_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ def test_parse_associations_compact(association_response, associations_compact):
association_response["response"]["numFound"] = association_response["response"].pop("num_found")
solr_response = SolrQueryResult(**association_response)
parsed = parse_associations(solr_response, compact=True).model_dump()
assert (
parsed == associations_compact
), f"Parsed result is not as expected. Difference: {dict_diff(parsed, associations_compact)}"
assert parsed == associations_compact, (
f"Parsed result is not as expected. Difference: {dict_diff(parsed, associations_compact)}"
)


def test_parse_association_counts(association_counts_response, association_counts, node):
association_counts_response["response"]["numFound"] = association_counts_response["response"].pop("num_found")
solr_response = SolrQueryResult(**association_counts_response)
parsed = parse_association_counts(solr_response, entity=Node(**node).id).model_dump()
assert (
parsed == association_counts
), f"Parsed result is not as expected. Difference: {dict_diff(parsed, association_counts)}"
assert parsed == association_counts, (
f"Parsed result is not as expected. Difference: {dict_diff(parsed, association_counts)}"
)


def test_parse_association_table(association_table_response, association_table, node):
association_table_response["response"]["numFound"] = association_table_response["response"].pop("num_found")
solr_response = SolrQueryResult(**association_table_response)
parsed = parse_association_table(solr_response, entity=[Node(**node).id], offset=0, limit=5).model_dump()
assert (
parsed == association_table
), f"Parsed result is not as expected. Difference: {dict_diff(parsed, association_table)}"
assert parsed == association_table, (
f"Parsed result is not as expected. Difference: {dict_diff(parsed, association_table)}"
)


def test_parse_entity(entity_response, node):
Expand All @@ -64,9 +64,9 @@ def test_parse_search(search_response, search):
solr_response = SolrQueryResult(**search_response)
parsed = parse_search(solr_response).model_dump()
# assert that top level keys are the same
assert set(parsed.keys()) == set(
search.keys()
), f"Parsed result keys are not as expected. Difference: {dict_diff(parsed, search)}"
assert set(parsed.keys()) == set(search.keys()), (
f"Parsed result keys are not as expected. Difference: {dict_diff(parsed, search)}"
)
# compare the first document (parsed.items[0]), assert that all of the keys in expected search (search.items[0])
for key in search["items"][0].keys():
assert key in parsed["items"][0], f"Key {key} not found in parsed result."
Expand All @@ -77,9 +77,9 @@ def test_parse_autocomplete(autocomplete_response, autocomplete):
solr_response = SolrQueryResult(**autocomplete_response)
parsed = parse_autocomplete(solr_response).model_dump()
# assert that top level keys are the same
assert set(parsed.keys()) == set(
autocomplete.keys()
), f"Parsed result keys are not as expected. Difference: {dict_diff(parsed, autocomplete)}"
assert set(parsed.keys()) == set(autocomplete.keys()), (
f"Parsed result keys are not as expected. Difference: {dict_diff(parsed, autocomplete)}"
)
# compare the first document (parsed.items[0]), assert that all of the keys in expected autocomplete (autocomplete.items[0])
for key in autocomplete["items"][0].keys():
assert key in parsed["items"][0], f"Key {key} not found in parsed result."
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/unit/test_solr_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def test_build_association_multiple_predicates():
)
assert len(query.filter_queries) > 0, "filter_queries is empty"
predicate_filter = [fq for fq in query.filter_queries if fq.startswith("predicate:")][0]
assert (
predicate_filter == "predicate:biolink\\:has_phenotype OR predicate:biolink\\:expressed_in"
), "multiple predicate filter is not as expected"
assert predicate_filter == "predicate:biolink\\:has_phenotype OR predicate:biolink\\:expressed_in", (
"multiple predicate filter is not as expected"
)


def test_build_association_multiple_entites():
Expand Down