-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
346 additions
and
52 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
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,87 @@ | ||
#!/usr/bin/env python | ||
"""Synchronize authors and contributor metadata. | ||
This script synchronizes the metadata provided in the CITATION.cff and | ||
the contributors.yaml file with the metadata stored in the .zenodo.json | ||
file. | ||
All authors should be listed in the CITATION.cff file, while contributors | ||
should be listed in the contributors.yaml file. | ||
Both files use the [citation file-format][1] for [person objects][2]. | ||
[1] https://citation-file-format.github.io/ | ||
[2] https://citation-file-format.github.io/1.0.3/specifications/#/person-objects | ||
""" | ||
from dataclasses import dataclass | ||
|
||
import click | ||
import json | ||
from ruamel.yaml import load, Loader | ||
|
||
|
||
@dataclass | ||
class Contributor: | ||
last_names: str | ||
first_names: str | ||
affiliation: str | ||
orcid: str = None | ||
|
||
@classmethod | ||
def from_citation_author(cls, **citation): | ||
return cls( | ||
last_names=citation.pop('family-names'), | ||
first_names=citation.pop('given-names'), | ||
**citation) | ||
|
||
def as_zenodo_creator(self): | ||
ret = dict( | ||
name='{} {}'.format(self.first_names, self.last_names), | ||
affiliation=self.affiliation) | ||
if self.orcid: | ||
ret['orcid'] = self.orcid.lstrip('https://orcid.org/') | ||
return ret | ||
|
||
|
||
@click.command() | ||
@click.pass_context | ||
@click.option('--check', default=False, is_flag=True, | ||
help="Return with non-zero exit code if metadata needs to be updated.") | ||
@click.option('-i', '--in-place', type=bool, is_flag=True, | ||
help="Modify metadata in place.") | ||
def sync(ctx, in_place=False, check=True): | ||
|
||
with open('CITATION.cff', 'rb') as file: | ||
citation = load(file.read(), Loader=Loader) | ||
authors = [ | ||
Contributor.from_citation_author(**author) | ||
for author in citation['authors']] | ||
|
||
with open('contributors.yaml', 'rb') as file: | ||
contributors = load(file.read(), Loader=Loader)['contributors'] | ||
contributors = [Contributor.from_citation_author( | ||
**contributor) for contributor in contributors] | ||
|
||
with open('.zenodo.json', 'rb') as file: | ||
zenodo = json.loads(file.read()) | ||
zenodo_updated = zenodo.copy() | ||
zenodo_updated['creators'] = [a.as_zenodo_creator() for a in authors] | ||
zenodo_updated['contributors'] = [c.as_zenodo_creator() | ||
for c in contributors if c not in authors] | ||
for key in ('version', 'keywords'): | ||
zenodo_updated[key] = citation[key] | ||
|
||
modified = json.dumps(zenodo, sort_keys=True) != json.dumps(zenodo_updated, sort_keys=True) | ||
if modified: | ||
if in_place: | ||
with open('.zenodo.json', 'wb') as file: | ||
file.write(json.dumps(zenodo_updated, indent=4, sort_keys=True).encode('utf-8')) | ||
else: | ||
click.echo(json.dumps(zenodo_updated, indent=4, sort_keys=True)) | ||
if check: | ||
ctx.exit(1) | ||
else: | ||
click.echo("No changes.", err=True) | ||
|
||
|
||
if __name__ == '__main__': | ||
sync() |
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,44 +1,78 @@ | ||
{ | ||
"description": "<p>The signac framework aids in the management of large and heterogeneous data spaces. It provides a simple and robust data model to create a well-defined indexable storage layout for data and metadata. This makes it easier to operate on large data spaces, streamlines post-processing and analysis and makes data collectively accessible.</p>", | ||
"license": "BSD-3-Clause", | ||
"upload_type": "software", | ||
"creators": [ | ||
"contributors": [ | ||
{ | ||
"affiliation": "University of Michigan", | ||
"name": "Carl S. Adorf" | ||
"name": "Benjamin Swerdlow", | ||
"orcid": "0000-0001-6240-1430" | ||
}, | ||
{ | ||
"affiliation": "University of Michigan", | ||
"name": "Paul M. Dodd" | ||
"name": "Jens Glaser", | ||
"orcid": "0000-0003-1852-3849" | ||
}, | ||
{ | ||
"affiliation": "University of Michigan", | ||
"name": "Vyas Ramasubramani" | ||
"name": "Timothy Moore", | ||
"orcid": "0000-0002-5709-7259" | ||
}, | ||
{ | ||
"affiliation": "University of Michigan", | ||
"name": "Benjamin Swerdlow" | ||
"name": "Yuan Zhou" | ||
}, | ||
{ | ||
"affiliation": "University of Michigan", | ||
"name": "Jens Glaser" | ||
"affiliation": "Air Force Science and Technology Fellowship Program", | ||
"name": "Eric Harper", | ||
"orcid": "0000-0002-7058-1686" | ||
}, | ||
{ | ||
"affiliation": "University of Michigan", | ||
"name": "Bradley Dice" | ||
"name": "Kelly Wang" | ||
} | ||
], | ||
"access_right": "open", | ||
"related_identifiers": [ | ||
"creators": [ | ||
{ | ||
"affiliation": "University of Michigan", | ||
"name": "Carl Simon Adorf", | ||
"orcid": "0000-0003-4962-2495" | ||
}, | ||
{ | ||
"affiliation": "University of Michigan", | ||
"name": "Vyas Ramasubramani", | ||
"orcid": "0000-0001-5181-9532" | ||
}, | ||
{ | ||
"scheme": "url", | ||
"identifier": "https://dx.doi.org/10.1016/j.commatsci.2018.01.035", | ||
"relation": "isSupplementedBy" | ||
"affiliation": "University of Michigan", | ||
"name": "Bradley D. Dice", | ||
"orcid": "0000-0002-9983-0770" | ||
}, | ||
{ | ||
"affiliation": "Boise State University", | ||
"name": "Mike Henry", | ||
"orcid": "0000-0002-3870-9993" | ||
}, | ||
{ | ||
"affiliation": "University of Michigan", | ||
"name": "Paul M. Dodd" | ||
}, | ||
{ | ||
"scheme": "url", | ||
"identifier": "arXiv://1611.03543 [cs.DB]", | ||
"relation": "isSupplementedBy" | ||
"affiliation": "University of Michigan", | ||
"name": "Sharon C. Glotzer", | ||
"orcid": "0000-0002-7197-0085" | ||
} | ||
] | ||
} | ||
], | ||
"description": "The signac framework helps users manage and scale file-based workflows, facilitating data reuse, sharing, and reproducibility.\n\nIt provides a simple and robust data model to create a well-defined indexable storage layout for data and metadata. This makes it easier to operate on large data spaces, streamlines post-processing and analysis and makes data collectively accessible.", | ||
"doi": "10.5281/zenodo.2581327", | ||
"keywords": [ | ||
"python", | ||
"data management", | ||
"reproducibility", | ||
"sharability", | ||
"workflow", | ||
"scientific computing" | ||
], | ||
"license": { | ||
"id": "http://www.opensource.org/licenses/BSD-3-Clause" | ||
}, | ||
"title": "signac", | ||
"version": "1.1.0" | ||
} |
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,87 @@ | ||
# YAML 1.2 | ||
--- | ||
cff-version: "1.0.3" | ||
title: signac | ||
version: 1.1.0 | ||
abstract: | | ||
The signac framework helps users manage and scale file-based workflows, facilitating data | ||
reuse, sharing, and reproducibility. It provides a simple and robust data model to create | ||
a well-defined indexable storage layout for data and metadata. This makes it easier to | ||
operate on large data spaces, streamlines post-processing and analysis and makes data | ||
collectively accessible. | ||
doi: 10.5281/zenodo.2581327 | ||
authors: | ||
- | ||
family-names: Adorf | ||
given-names: "Carl Simon" | ||
affiliation: "University of Michigan" | ||
orcid: "https://orcid.org/0000-0003-4962-2495" | ||
- | ||
family-names: Ramasubramani | ||
given-names: Vyas | ||
affiliation: "University of Michigan" | ||
orcid: "https://orcid.org/0000-0001-5181-9532" | ||
- | ||
family-names: Dice | ||
given-names: "Bradley D." | ||
affiliation: "University of Michigan" | ||
orcid: "https://orcid.org/0000-0002-9983-0770" | ||
- | ||
family-names: Henry | ||
given-names: Mike | ||
affiliation: "Boise State University" | ||
orcid: "https://orcid.org/0000-0002-3870-9993" | ||
- | ||
family-names: Dodd | ||
given-names: "Paul M." | ||
affiliation: "University of Michigan" | ||
- | ||
family-names: Glotzer | ||
given-names: "Sharon C." | ||
affiliation: "University of Michigan" | ||
orcid: "https://orcid.org/0000-0002-7197-0085" | ||
keywords: | ||
- python | ||
- "data management" | ||
- reproducibility | ||
- sharability | ||
- workflow | ||
- "scientific computing" | ||
license: "http://www.opensource.org/licenses/BSD-3-Clause" | ||
message: > | ||
Development and deployment supported by MICCoM, as part of the Computational | ||
Materials Sciences Program funded by the U.S. Department of Energy, Office of | ||
Science, Basic Energy Sciences, Materials Sciences and Engineering Division, | ||
under Subcontract No. 6F-30844. Project conceptualization and implementation | ||
supported by the National Science Foundation, Award # DMR 1409620. | ||
repository-code: https://github.com/glotzerlab/signac | ||
references: | ||
- type: article | ||
- authors: | ||
- | ||
family-names: Adorf | ||
given-names: "Carl Simon" | ||
affiliation: "University of Michigan" | ||
orcid: "https://orcid.org/0000-0003-4962-2495" | ||
- | ||
family-names: Dodd | ||
given-names: "Paul M." | ||
affiliation: "University of Michigan" | ||
- | ||
family-names: Ramasubramani | ||
given-names: Vyas | ||
affiliation: "University of Michigan" | ||
orcid: "https://orcid.org/0000-0001-5181-9532" | ||
- | ||
family-names: Glotzer | ||
given-names: "Sharon C." | ||
affiliation: "University of Michigan" | ||
orcid: "https://orcid.org/0000-0002-7197-0085" | ||
- title: "Simple data and workflow management with the signac framework" | ||
- journal: "Comput. Mater. Sci." | ||
- volume: 146 | ||
- number: C | ||
- year: 2018 | ||
- pages: 9 | ||
- doi: "10.1016/j.commatsci.2018.01.035" | ||
... |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.