From 18e50d3d6fb4d72da68ac9665435fcb668ce40c2 Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Fri, 18 Aug 2023 15:58:47 +0200 Subject: [PATCH 1/2] Improve trackability of committer --- src/biomappings/resources/__init__.py | 5 ++++- src/biomappings/testing.py | 5 ++++- src/biomappings/wsgi.py | 7 ++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/biomappings/resources/__init__.py b/src/biomappings/resources/__init__.py index 24208a16..47665fc2 100644 --- a/src/biomappings/resources/__init__.py +++ b/src/biomappings/resources/__init__.py @@ -477,9 +477,12 @@ def _standardize_mapping(mapping): return mapping +CURATORS_PATH = get_resource_file_path("curators.tsv") + + def load_curators(): """Load the curators table.""" - return _load_table(get_resource_file_path("curators.tsv")) + return _load_table(CURATORS_PATH) def filter_predictions(custom_filter: Mapping[str, Mapping[str, Mapping[str, str]]]) -> None: diff --git a/src/biomappings/testing.py b/src/biomappings/testing.py index 42d08cad..11c04b80 100644 --- a/src/biomappings/testing.py +++ b/src/biomappings/testing.py @@ -9,6 +9,7 @@ import bioregistry from biomappings.resources import ( + CURATORS_PATH, Mappings, MappingTuple, PredictionTuple, @@ -126,7 +127,9 @@ def test_contributors(self): for mapping in itt.chain(self.mappings, self.incorrect, self.unsure): source = mapping["source"] if not source.startswith("orcid:"): - continue + self.assertTrue(source.startswith("web-")) + ss = source[len("web-")] + self.fail(msg=f'Add an entry with "{ss}" and your ORCID to {CURATORS_PATH}') self.assertIn(source[len("orcid:") :], contributor_orcids) def test_cross_redundancy(self): diff --git a/src/biomappings/wsgi.py b/src/biomappings/wsgi.py index 306e409f..6e44fa65 100644 --- a/src/biomappings/wsgi.py +++ b/src/biomappings/wsgi.py @@ -132,11 +132,12 @@ def get_app( KNOWN_USERS = {record["user"]: record["orcid"] for record in load_curators()} -def _manual_source(): - known_user = KNOWN_USERS.get(getpass.getuser()) +def _manual_source() -> str: + usr = getpass.getuser() + known_user = KNOWN_USERS.get(usr) if known_user: return f"orcid:{known_user}" - return "web" + return f"web-{usr}" class Controller: From c7c93160d6cbafd939a8ef8b3ad70cc99f4f519c Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Fri, 18 Aug 2023 15:59:25 +0200 Subject: [PATCH 2/2] Update testing.py --- src/biomappings/testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/biomappings/testing.py b/src/biomappings/testing.py index 11c04b80..6e86550d 100644 --- a/src/biomappings/testing.py +++ b/src/biomappings/testing.py @@ -128,7 +128,7 @@ def test_contributors(self): source = mapping["source"] if not source.startswith("orcid:"): self.assertTrue(source.startswith("web-")) - ss = source[len("web-")] + ss = source[len("web-") :] self.fail(msg=f'Add an entry with "{ss}" and your ORCID to {CURATORS_PATH}') self.assertIn(source[len("orcid:") :], contributor_orcids)