Skip to content

Commit afcf6b5

Browse files
committed
maint(zenodo): bring update_zenodo.py script from Nipype and run it [skip ci]
1 parent 39e2eeb commit afcf6b5

File tree

3 files changed

+107
-25
lines changed

3 files changed

+107
-25
lines changed

.mailmap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
3+
Ariel Rokem <[email protected]>
4+
5+
Garikoitz Lerma-Usabiaga <[email protected]> garikoitz <[email protected]>
6+
Michael Joseph <[email protected]> mjoseph <[email protected]>
7+
Oscar Esteban <[email protected]>
8+
9+
Oscar Esteban <[email protected]> oesteban <[email protected]>

.maintenance/update_zenodo.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env python3
2+
"""Update and sort the creators list of the zenodo record."""
3+
import sys
4+
import shutil
5+
from pathlib import Path
6+
import json
7+
from fuzzywuzzy import fuzz, process
8+
import subprocess as sp
9+
10+
# These ORCIDs should go last
11+
CREATORS_LAST = ['Rokem, Ariel', 'Esteban, Oscar']
12+
# for entries not found in line-contributions
13+
MISSING_ENTRIES = [
14+
]
15+
16+
if __name__ == '__main__':
17+
contrib_file = Path('line-contributors.txt')
18+
lines = []
19+
if contrib_file.exists():
20+
print('WARNING: Reusing existing line-contributors.txt file.', file=sys.stderr)
21+
lines = contrib_file.read_text().splitlines()
22+
23+
git_line_summary_path = shutil.which('git-line-summary')
24+
if not lines and git_line_summary_path:
25+
print("Running git-line-summary on nipype repo")
26+
lines = sp.check_output([git_line_summary_path]).decode().splitlines()
27+
contrib_file.write_text('\n'.join(lines))
28+
29+
if not lines:
30+
raise RuntimeError("""\
31+
Could not find line-contributors from git repository.%s""" % """ \
32+
git-line-summary not found, please install git-extras. """ * (git_line_summary_path is None))
33+
34+
data = [' '.join(line.strip().split()[1:-1]) for line in lines if '%' in line]
35+
36+
# load zenodo from master
37+
zenodo_file = Path('.zenodo.json')
38+
zenodo = json.loads(zenodo_file.read_text())
39+
zen_names = [' '.join(val['name'].split(',')[::-1]).strip()
40+
for val in zenodo['creators']]
41+
total_names = len(zen_names) + len(MISSING_ENTRIES)
42+
43+
name_matches = []
44+
position = 1
45+
for ele in data:
46+
matches = process.extract(ele, zen_names, scorer=fuzz.token_sort_ratio,
47+
limit=2)
48+
# matches is a list [('First match', % Match), ('Second match', % Match)]
49+
if matches[0][1] > 80:
50+
val = zenodo['creators'][zen_names.index(matches[0][0])]
51+
else:
52+
# skip unmatched names
53+
print("No entry to sort:", ele)
54+
continue
55+
56+
if val not in name_matches:
57+
if val['name'] not in CREATORS_LAST:
58+
val['position'] = position
59+
position += 1
60+
else:
61+
val['position'] = total_names + CREATORS_LAST.index(val['name'])
62+
name_matches.append(val)
63+
64+
for missing in MISSING_ENTRIES:
65+
missing['position'] = position
66+
position += 1
67+
name_matches.append(missing)
68+
69+
zenodo['creators'] = sorted(name_matches, key=lambda k: k['position'])
70+
# Remove position
71+
for creator in zenodo['creators']:
72+
del creator['position']
73+
74+
zenodo_file.write_text('%s\n' % json.dumps(zenodo, indent=2, sort_keys=True))

.zenodo.json

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
1-
21
{
3-
"title": "dMRIPrep: a robust preprocessing pipeline for diffusion MRI",
4-
"description": "<p>dMRIPrep is a robust and easy-to-use pipeline for preprocessing of diverse dMRI data. The transparent workflow dispenses of manual intervention, thereby ensuring the reproducibility of the results.</p>",
5-
"creators": [
2+
"contributors": [
63
{
7-
"affiliation": "The University of Washington eScience Institute",
8-
"name": "Keshavan, Anisha",
9-
"orcid": "0000-0003-3554-043X"
4+
"affiliation": "Department of Psychology, Stanford University, CA, USA",
5+
"name": "Lerma-Usabiaga, Garikoitz",
6+
"orcid": "0000-0001-9800-4816",
7+
"type": "Researcher"
8+
},
9+
{
10+
"name": "nrajamani3",
11+
"type": "Researcher"
1012
},
13+
{
14+
"affiliation": "Department of Psychology, Stanford University",
15+
"name": "Poldrack, Russell A.",
16+
"orcid": "0000-0001-6755-0259",
17+
"type": "Researcher"
18+
}
19+
],
20+
"creators": [
1121
{
1222
"affiliation": "The University of Washington eScience Institute",
1323
"name": "Richie-Halford, Adam",
1424
"orcid": "0000-0001-9276-9084"
1525
},
26+
{
27+
"affiliation": "The University of Washington eScience Institute",
28+
"name": "Keshavan, Anisha",
29+
"orcid": "0000-0003-3554-043X"
30+
},
1631
{
1732
"affiliation": "The Centre for Addiction and Mental Health",
1833
"name": "Joseph, Michael",
@@ -29,24 +44,7 @@
2944
"orcid": "0000-0001-8435-6191"
3045
}
3146
],
32-
"contributors": [
33-
{
34-
"affiliation": "Department of Psychology, Stanford University, CA, USA",
35-
"name": "Lerma-Usabiaga, Garikoitz",
36-
"orcid": "0000-0001-9800-4816",
37-
"type": "Researcher"
38-
},
39-
{
40-
"name": "nrajamani3",
41-
"type": "Researcher"
42-
},
43-
{
44-
"name": "Poldrack, Russell A.",
45-
"affiliation": "Department of Psychology, Stanford University",
46-
"orcid": "0000-0001-6755-0259",
47-
"type": "Researcher"
48-
},
49-
],
47+
"description": "<p>dMRIPrep is a robust and easy-to-use pipeline for preprocessing of diverse dMRI data. The transparent workflow dispenses of manual intervention, thereby ensuring the reproducibility of the results.</p>",
5048
"keywords": [
5149
"neuroimaging",
5250
"workflow",
@@ -68,5 +66,6 @@
6866
"scheme": "doi"
6967
}
7068
],
69+
"title": "dMRIPrep: a robust preprocessing pipeline for diffusion MRI",
7170
"upload_type": "software"
7271
}

0 commit comments

Comments
 (0)