Skip to content

Commit f1f6424

Browse files
cthoytbalhoffwdduncan
authored
Update display of alumni (OBOFoundry#2150)
* Add alumni updater * Add additional alumni metadata Closes OBOFoundry#2134 and automatically enriches information from wikidata Co-Authored-By: Jim Balhoff <[email protected]> Co-Authored-By: Bill Duncan <[email protected]> * Improve alumni display * Update update_operations_metadata.py * Update * Update cli.py * Make github tag optional * Update alumni.yml Co-authored-by: Jim Balhoff <[email protected]> Co-authored-by: Bill Duncan <[email protected]>
1 parent bfc8cd9 commit f1f6424

File tree

8 files changed

+87
-35
lines changed

8 files changed

+87
-35
lines changed

_data/alumni.yml

+38-12
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,61 @@
11
members:
22
- name: Michael Ashburner
33
orcid: 0000-0002-6962-2807
4-
- name: Colin Batchelor
4+
wikidata: Q6828277
5+
- github: batchelorc
6+
name: Colin Batchelor
57
orcid: 0000-0001-5985-7429
6-
- name: Mathias Brochhausen
8+
wikidata: Q28923515
9+
- github: mbrochhausen
10+
name: Mathias Brochhausen
711
orcid: 0000-0003-1834-3856
8-
- name: Melanie Courtot
12+
wikidata: Q57161944
13+
- github: mcourtot
914
link: http://purl.org/net/mcourtot
15+
name: Melanie Courtot
1016
orcid: 0000-0002-9551-6370
11-
- name: Eric Douglass
12-
- name: Janna Hastings
17+
wikidata: Q23809262
18+
- github: dougli1sqrd
19+
name: Eric Douglass
20+
orcid: 0000-0001-6946-1807
21+
wikidata: Q114403167
22+
- github: jannahastings
23+
name: Janna Hastings
1324
orcid: 0000-0002-3469-4923
14-
- name: Simon Jupp
25+
wikidata: Q27902110
26+
- github: simonjupp
27+
name: Simon Jupp
1528
note: OBO Industry Liaison
1629
orcid: 0000-0002-0643-3144
17-
- name: Suzanna Lewis
30+
wikidata: Q54303148
31+
- github: suzialeksander
1832
link: https://github.com/selewis
33+
name: Suzanna Lewis
1934
orcid: 0000-0002-8343-612X
20-
- name: James Malone
35+
wikidata: Q7650732
36+
- github: jamesmalone
37+
name: James Malone
2138
note: OBO Industry Liaison
2239
orcid: 0000-0002-1615-2899
23-
- name: Gareth Owen
24-
- name: Susanna-Assunta Sansone
40+
wikidata: Q47502894
41+
- github: G-Owen
42+
name: Gareth Owen
43+
orcid: 0000-0001-7265-5776
44+
wikidata: Q55095454
45+
- github: SusannaSansone
46+
name: Susanna-Assunta Sansone
2547
orcid: 0000-0001-5306-5690
26-
- name: Carlo Tornial
48+
wikidata: Q28913668
49+
- github: carlotorniai
50+
name: Carlo Tornial
51+
orcid: 0000-0002-3734-1859
52+
wikidata: Q114403193
2753
- affiliation: La Jolla Institute for Immunology, La Jolla, CA
2854
country: USA
55+
departed: 2022-10-04
2956
github: hectorguzor
3057
groups:
3158
- outreach
3259
name: Hector Guzman-Orozco
3360
orcid: 0000-0003-3430-8997
3461
wikidata: Q114354576
35-
departed: 2022-10-04

docs/Membership.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,19 @@ New members: follow the instructions on the [onboarding doc](https://docs.google
4747
<tr>
4848
<th role="columnheader">Name</th>
4949
<th role="columnheader">ORCID</th>
50+
<th role="columnheader">GitHub</th>
51+
<th role="columnheader">Departed</th>
5052
<th role="columnheader">Note</th>
5153
</tr>
5254
</thead>
5355
<tbody>
54-
{% for member in site.data.alumni.members %}
56+
{% assign alumni_members = site.data.alumni.members | sort: "name" %}
57+
{% for member in alumni_members %}
5558
<tr>
5659
<td>{% if member.link %}<a href="{{ member.link }}">{{ member.name }}</a>{% else %}{{ member.name }}{% endif %}</td>
57-
<td>{% if member.orcid %}<a href="https://orcid.org/{{ member.orcid }}">{{ member.orcid }}</a>{% endif %}</td>
60+
<td><a href="https://orcid.org/{{ member.orcid }}">{{ member.orcid }}</a></td>
61+
<td>{% if member.github %}<a href="https://github.com/{{ member.github }}">{{ member.github }}</a>{% endif %}</td>
62+
<td>{% if member.departed %}{{ member.departed }}{% endif %}</td>
5863
<td>{% if member.note %}{{ member.note }}{% endif %}</td>
5964
</tr>
6065
{% endfor %}

src/obofoundry/cli.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import click
1515

16-
from . import update_operations_metadata
16+
from . import standardize_metadata, update_operations_metadata
1717

1818
__all__ = [
1919
"main",
@@ -25,6 +25,7 @@ def main():
2525
"""CLI for the OBO Foundry."""
2626

2727

28+
main.add_command(standardize_metadata.main)
2829
main.add_command(update_operations_metadata.main)
2930

3031
if __name__ == "__main__":

src/obofoundry/constants.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
DATA_DIRECTORY = ROOT.joinpath("_data")
99
#: Path to the file containing metadata about members of the OBO Operations Committee
1010
OPERATIONS_METADATA_PATH = DATA_DIRECTORY.joinpath("operations.yml")
11+
ALUMNI_METADATA_PATH = DATA_DIRECTORY.joinpath("alumni.yml")

src/obofoundry/update_operations_metadata.py

+10-18
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,25 @@
11
"""Run this script to update the operations metadata."""
22

3+
from pathlib import Path
34
from textwrap import dedent
45

56
import click
6-
import requests
77
import yaml
88
from tqdm import tqdm
99

10-
from obofoundry.constants import OPERATIONS_METADATA_PATH
11-
12-
#: WikiData SPARQL endpoint. See https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service#Interfacing
13-
WIKIDATA_SPARQL = "https://query.wikidata.org/bigdata/namespace/wdq/sparql"
14-
15-
16-
def query_wikidata(query: str):
17-
"""Query the Wikidata SPARQL endpoint and return JSON."""
18-
res = requests.get(
19-
WIKIDATA_SPARQL,
20-
params={"query": query, "format": "json"},
21-
)
22-
res.raise_for_status()
23-
res_json = res.json()
24-
return res_json["results"]["bindings"]
10+
from obofoundry.constants import ALUMNI_METADATA_PATH, OPERATIONS_METADATA_PATH
11+
from obofoundry.utils import query_wikidata
2512

2613

2714
@click.command(name="update-operations-metadata")
2815
def main():
2916
"""Update the operations committee members metadata file by querying Wikidata."""
30-
operations_metadata = yaml.safe_load(OPERATIONS_METADATA_PATH.read_text())
17+
_main(ALUMNI_METADATA_PATH)
18+
_main(OPERATIONS_METADATA_PATH)
19+
20+
21+
def _main(path: Path):
22+
operations_metadata = yaml.safe_load(path.read_text())
3123
for member in tqdm(operations_metadata["members"]):
3224
orcid = member["orcid"]
3325
if "wikidata" not in member or "github" not in member:
@@ -51,7 +43,7 @@ def main():
5143
github = res[0].get("github")
5244
if github:
5345
member["github"] = github["value"]
54-
OPERATIONS_METADATA_PATH.write_text(
46+
path.write_text(
5547
yaml.safe_dump(
5648
operations_metadata,
5749
sort_keys=True,

src/obofoundry/utils.py

+17
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
"""Test data integrity, beyond what's possible with the JSON schema."""
22

3+
import requests
34
import yaml
45

56
from obofoundry.constants import ONTOLOGY_DIRECTORY
67

78
__all__ = [
89
"get_data",
10+
"query_wikidata",
911
]
1012

1113

@@ -24,3 +26,18 @@ def get_data():
2426
data["long_description"] = "".join(lines[idx:])
2527
ontologies[data["id"]] = data
2628
return ontologies
29+
30+
31+
#: WikiData SPARQL endpoint. See https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service#Interfacing
32+
WIKIDATA_SPARQL = "https://query.wikidata.org/bigdata/namespace/wdq/sparql"
33+
34+
35+
def query_wikidata(query: str):
36+
"""Query the Wikidata SPARQL endpoint and return JSON."""
37+
headers = {"User-Agent": "obofoundry/1.0 (https://obofoundry.org)"}
38+
res = requests.get(
39+
WIKIDATA_SPARQL, params={"query": query, "format": "json"}, headers=headers
40+
)
41+
res.raise_for_status()
42+
res_json = res.json()
43+
return res_json["results"]["bindings"]

tests/test_memberships.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import yaml
99
from pydantic import BaseModel
1010

11+
from obofoundry.constants import ALUMNI_METADATA_PATH, OPERATIONS_METADATA_PATH
12+
1113
HERE = Path(__file__).parent.resolve()
1214
ROOT = HERE.parent.resolve()
1315
DATA = ROOT.joinpath("_data")
@@ -36,9 +38,16 @@ class TestMembershipData(unittest.TestCase):
3638

3739
def test_data(self):
3840
"""Test the working group data is clean."""
39-
path = DATA.joinpath("operations").with_suffix(".yml")
40-
res = Group.parse_obj(yaml.safe_load(path.read_text()))
41+
res = Group.parse_obj(yaml.safe_load(OPERATIONS_METADATA_PATH.read_text()))
4142
self.assertIsNotNone(res)
4243
counter = Counter(member.orcid for member in res.members if member.orcid)
4344
counter = {orcid for orcid, count in counter.items() if count > 1}
4445
self.assertEqual(0, len(counter), msg=f"Duplicate: {counter}")
46+
47+
def test_alumni(self):
48+
"""Test the alumni data."""
49+
data = yaml.safe_load(ALUMNI_METADATA_PATH.read_text())["members"]
50+
for i, member in enumerate(data):
51+
with self.subTest(row=i):
52+
self.assertIn("name", member)
53+
self.assertIn("orcid", member)

tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ envlist =
1414
py
1515

1616
[testenv]
17+
usedevelop = true
1718
extras =
1819
tests
1920
commands =

0 commit comments

Comments
 (0)