-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tests, refactor updates (more parallelism too). See CHANGELOG.md
- Loading branch information
Showing
27 changed files
with
537 additions
and
569 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
2023-12-16 | ||
- Fix tests | ||
- Refactor the download of CSVs | ||
- Parallelize the download of CSVs | ||
- Add parameters to the update script | ||
you can run with `--only xxx`, `--stop xxx` or `--skip xxx` to: | ||
- only execute xxx | ||
- stop before xxx | ||
- skip xxx | ||
Where xxx can be a task or a group name | ||
Task/Groups descriptions can be listed with `--list` | ||
- Fix a potential abuse if taxon contains a comma in `generate_database_taxo.py` |
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
name = "lotus_search" | ||
version = "0.1.2" | ||
description = "" | ||
authors = ["Jonathan Bisson <[email protected]>"] | ||
authors = ["Jonathan Bisson <[email protected]>", "Adriano Rutz <[email protected]>"] | ||
packages = [{include = "*.py", from = ""}] | ||
readme = "README.md" | ||
|
||
|
@@ -17,14 +17,16 @@ gunicorn = "^21.2.0" | |
orjson = "^3.9.10" | ||
pandas = "^2.1.3" | ||
pydantic = "^2.5.1" | ||
pytest = "^6.0.0" | ||
pytest-mock = "*" | ||
requests = "^2.31.0" | ||
requests_mock = "*" | ||
rdkit = "^2023.9.2" | ||
sqlalchemy = "^2.0.23" | ||
uvicorn = "^0.23.2" | ||
|
||
[tool.poetry.dev-dependencies] | ||
pytest = "^6.0.0" | ||
pytest-mock = "*" | ||
requests_mock = "*" | ||
|
||
[tool.poetry.scripts] | ||
start = "app:main" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
import pytest | ||
import requests_mock | ||
|
||
from update.common import remove_wd_entity_prefix, wd_sparql_to_csv | ||
from update.common import remove_wd_entity_prefix, sparql_to_csv | ||
|
||
|
||
def test_wd_sparql_to_csv_returns_expected_csv(): | ||
with requests_mock.Mocker() as m: | ||
m.get("https://query.wikidata.org/sparql", text="expected_csv") | ||
result = wd_sparql_to_csv("query") | ||
assert result == "expected_csv" | ||
class TestWdSparqlToCsv: | ||
def test_returns_expected_csv(self): | ||
with requests_mock.Mocker() as m: | ||
m.get("https://query.wikidata.org/sparql", text="expected_csv") | ||
result = sparql_to_csv("query") | ||
assert result == "expected_csv" | ||
|
||
def test_uses_provided_url(self): | ||
with requests_mock.Mocker() as m: | ||
m.get("https://other.url/sparql", text="expected_csv") | ||
result = sparql_to_csv("query", "https://other.url/sparql") | ||
assert result == "expected_csv" | ||
|
||
def test_wd_sparql_to_csv_uses_provided_url(): | ||
with requests_mock.Mocker() as m: | ||
m.get("https://other.url/sparql", text="expected_csv") | ||
result = wd_sparql_to_csv("query", "https://other.url/sparql") | ||
assert result == "expected_csv" | ||
|
||
class TestRemoveWdEntityPrefix: | ||
def test_removes_prefix(self): | ||
result = remove_wd_entity_prefix("http://www.wikidata.org/entity/Q123") | ||
assert result == "123" | ||
|
||
def test_remove_wd_entity_prefix_removes_prefix(): | ||
result = remove_wd_entity_prefix("http://www.wikidata.org/entity/Q123") | ||
assert result == "123" | ||
|
||
|
||
def test_remove_wd_entity_prefix_does_not_remove_other_text(): | ||
result = remove_wd_entity_prefix("http://www.wikidata.org/entity/Q123/other") | ||
assert result == "123/other" | ||
def test_does_not_remove_other_text(self): | ||
result = remove_wd_entity_prefix("http://www.wikidata.org/entity/Q123/other") | ||
assert result == "123/other" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
from update.download_query_as_csv import run | ||
|
||
|
||
class TestRunQueryToCSV: | ||
@pytest.fixture(autouse=True) | ||
def setup(self, tmp_path): | ||
self.query_file = tmp_path / "query.sparql" | ||
self.query_file.write_text("SELECT ?item WHERE {?item wdt:P31 wd:Q5.} LIMIT 1") | ||
self.output_file = tmp_path / "output.csv" | ||
|
||
def test_retries_on_timeout(self): | ||
with patch('update.download_query_as_csv.sparql_to_csv') as mock_sparql_to_csv: | ||
mock_sparql_to_csv.side_effect = ['java.util.concurrent.TimeoutException', 'valid result'] | ||
run(self.query_file, self.output_file) | ||
assert mock_sparql_to_csv.call_count == 2 | ||
assert self.output_file.read_text() == 'valid result' | ||
|
||
def test_writes_expected_result(self): | ||
with patch('update.download_query_as_csv.sparql_to_csv') as mock_sparql_to_csv, \ | ||
patch('update.download_query_as_csv.remove_wd_entity_prefix') as mock_remove_wd_entity_prefix: | ||
mock_sparql_to_csv.return_value = 'valid result' | ||
mock_remove_wd_entity_prefix.return_value = 'expected result' | ||
run(self.query_file, self.output_file) | ||
assert self.output_file.read_text() == 'expected result' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.