Skip to content
Snippets Groups Projects
Commit 033b58d4 authored by Vuillaume's avatar Vuillaume
Browse files

Add script to update eossr codemeta and run it

parent 7215e908
No related branches found
No related tags found
1 merge request!173Add script to update eossr codemeta and run it
......@@ -2,7 +2,7 @@
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"name": "eossr",
"description": "<p><img alt=\"eOSSR\" src=\"docs/images/eossr_logo.png\" /></p><h2>The ESCAPE OSSR library</h2><p>The eOSSR Python library gathers all the developments made for the OSSR. In particular, it includes:- an API to programmatically access the OSSR, retrieve records and publish content- functions to map and crosswalk metadata between the CodeMeta schema adopted for the OSSR and Zenodo internal schema- functions to help developers automatically contribute to the OSSR, in particular using their continuous integration (see also code snippets)</p><p>Code: <a href=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr\">https://gitlab.in2p3.fr/escape2020/wp3/eossr</a> <br />Documentation: <a href=\"https://escape2020.pages.in2p3.fr/wp3/eossr/\">https://escape2020.pages.in2p3.fr/wp3/eossr/</a></p><p><a href=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/commits/master\"><img alt=\"pipeline status\" src=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/badges/master/pipeline.svg\" /></a><a href=\"https://opensource.org/licenses/MIT\"><img alt=\"License: MIT\" src=\"https://img.shields.io/badge/License-MIT-blue.svg\" /></a><a href=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/commits/master\"><img alt=\"coverage report\" src=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/badges/master/coverage.svg\" /></a><a href=\"https://doi.org/10.5281/zenodo.5524912\"><img alt=\"DOI\" src=\"https://zenodo.org/badge/DOI/10.5281/zenodo.5524912.svg\" /></a><a href=\"https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.in2p3.fr%2Fescape2020%2Fwp3%2Feossr/HEAD\"><img alt=\"Binder\" src=\"https://mybinder.org/badge_logo.svg\" /></a></p><h2>Stable versions</h2><ul><li>v0.3.3: <a href=\"https://doi.org/10.5281/zenodo.5592584\"><img alt=\"DOI\" src=\"https://zenodo.org/badge/DOI/10.5281/zenodo.5592584.svg\" /></a></li><li>v0.2 : <a href=\"https://doi.org/10.5281/zenodo.5524913\"><img alt=\"DOI\" src=\"https://zenodo.org/badge/DOI/10.5281/zenodo.5524913.svg\" /></a></li></ul><h2>Install</h2><p>Commands to be run in your terminal.</p><h3>For users</h3><pre><code>pip install eossr</code></pre><p>You can also run it with docker:</p><pre><code>docker run -it gitlab-registry.in2p3.fr/escape2020/wp3/eossr:latest</code></pre><p><a href=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/container_registry\">Visit our registry</a> to see the available docker containers.</p><p>Note that <code>latest</code> tag always point to the latest stable released container.</p><h3>For developers</h3><pre><code>git clone https://gitlab.in2p3.fr/escape2020/wp3/eossr.gitpip install -e eossr</code></pre><h4>Running tests</h4><p>To run tests locally, run:</p><pre><code>pip install pytestpytest eossr</code></pre><p>Some tests will be skiped if <code>SANDBOX_ZENODO_TOKEN</code> is not defined in your environment variables.If you want to run these tests, you will need to create a <a href=\"https://sandbox.zenodo.org/account/settings/applications/tokens/new/\">sandbox zenodo token</a> and add it to your env:</p><pre><code>export SANDBOX_ZENODO_TOKEN=&quot;your_sandbox_token&quot;</code></pre><h2>Cite</h2><p>To cite this library, use the cite module in <a href=\"https://zenodo.org/record/5524913#.YWBq79kzZB0\">the Zenodo page</a>.</p>",
"description": "<p align=\"left\"><img src=\"docs/images/eossr_logo.png\" width=\"400px\" ></p><h1>The ESCAPE OSSR library</h1><p>The eOSSR Python library gathers all the developments made for the OSSR. In particular, it includes:- an API to programmatically access the OSSR, retrieve records and publish content- functions to map and crosswalk metadata between the CodeMeta schema adopted for the OSSR and Zenodo internal schema- functions to help developers automatically contribute to the OSSR, in particular using their continuous integration (see also code snippets)</p><p>Code: <a href=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr\">https://gitlab.in2p3.fr/escape2020/wp3/eossr</a>Documentation: <a href=\"https://escape2020.pages.in2p3.fr/wp3/eossr/\">https://escape2020.pages.in2p3.fr/wp3/eossr/</a></p><p><a href=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/commits/master\"><img alt=\"\" src=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/badges/master/pipeline.svg\" /></a><a href=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/commits/master\"><img alt=\"\" src=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/badges/master/coverage.svg\" /></a><a href=\"https://opensource.org/licenses/MIT\"><img alt=\"\" src=\"https://img.shields.io/badge/License-MIT-blue.svg\" /></a><a href=\"https://doi.org/10.5281/zenodo.5524912\"><img alt=\"\" src=\"https://zenodo.org/badge/DOI/10.5281/zenodo.5524912.svg\" /></a><a href=\"https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.in2p3.fr%2Fescape2020%2Fwp3%2Feossr/HEAD\"><img alt=\"\" src=\"https://mybinder.org/badge_logo.svg\" /></a></p><h2>Former stable versions</h2><ul><li>v0.4: <a href=\"https://doi.org/10.5281/zenodo.6326454\"><img alt=\"DOI\" src=\"https://zenodo.org/badge/DOI/10.5281/zenodo.6326454.svg\" /></a></li><li>v0.3.3: <a href=\"https://doi.org/10.5281/zenodo.5592584\"><img alt=\"\" src=\"https://zenodo.org/badge/DOI/10.5281/zenodo.5592584.svg\" /></a></li><li>v0.2 : <a href=\"https://doi.org/10.5281/zenodo.5524913\"><img alt=\"\" src=\"https://zenodo.org/badge/DOI/10.5281/zenodo.5524913.svg\" /></a></li></ul><h2>Install</h2><p>Commands to be run in your terminal.</p><h3>For users</h3><pre><code>pip install eossr</code></pre><p>You can also run it with docker:</p><pre><code>docker run -it gitlab-registry.in2p3.fr/escape2020/wp3/eossr:latest</code></pre><p><a href=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/container_registry\">Visit our registry</a> to see the available docker containers.</p><p>Note that <code>latest</code> tag always point to the latest stable released container.</p><h3>For developers</h3><pre><code>git clone https://gitlab.in2p3.fr/escape2020/wp3/eossr.gitpip install -e &quot;./eossr&quot;</code></pre><h4>Running tests</h4><p>To run tests locally, run:</p><pre><code>pip install -e &quot;./eossr[tests]&quot;pytest eossr</code></pre><p>Some tests will be skiped if <code>SANDBOX_ZENODO_TOKEN</code> is not defined in your environment variables.If you want to run these tests, you will need to create a <a href=\"https://sandbox.zenodo.org/account/settings/applications/tokens/new/\">sandbox zenodo token</a> and add it to your env:</p><pre><code>export SANDBOX_ZENODO_TOKEN=&quot;your_sandbox_token&quot;</code></pre><h2>License</h2><p>See <a href=\"LICENSE\">LICENSE</a></p><h2>Cite</h2><p>To cite this library, use the cite section in <a href=\"https://zenodo.org/record/5592584#.YiALJRPMI-Q\">the Zenodo page</a> (rightcolumn, below the <code>Versions</code> section).</p>",
"license": "https://spdx.org/licenses/MIT",
"version": "0.5",
"softwareVersion": "0.5",
......@@ -43,11 +43,11 @@
"zenodo"
],
"runtimePlatform": "Python 3",
"downloadUrl": "https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/archive/v0.4/eossr-v0.4.zip",
"downloadUrl": "https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/archive/v0.5/eossr-v0.5.zip",
"releaseNotes": "eossr v0.5. Full changelog: https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/releases/v0.5",
"dateCreated": "2021-08-31",
"datePublished": "2022-03-14",
"dateModified": "2022-03-11",
"dateModified": "2022-03-14",
"operatingSystem": "",
"maintainer": {
"@type": "Person",
......
import json
from pathlib import Path
from warnings import warn
import pandas as pd
......@@ -74,3 +75,10 @@ class Codemeta:
def validate(self):
for error in self.error_generator():
raise error
def write(self, path='codemeta.json', overwrite=False):
if Path(path).exists() and not overwrite:
raise FileExistsError(f"File {path} exists. Use overwrite=True to overwrite")
else:
with open(path, 'w') as f:
json.dump(self.metadata, f, indent=4)
import tempfile
from os import path
from pathlib import Path
......@@ -35,3 +36,13 @@ def test_read_codemeta_crosswalk():
cw = codemeta.codemeta_crosswalk()
assert set(cw['OSSR Requirement Level'].values) == {'required', 'recommended', nan}
def test_codemeta_write():
metadata = {'name': 'Rick', 'version': 'v10'}
codemeta_handler = codemeta.Codemeta(metadata)
with tempfile.TemporaryDirectory() as tmpdirname:
filename = Path(tmpdirname, 'codemeta.json')
codemeta_handler.write(filename)
new_codemeta = codemeta.Codemeta.from_file(filename)
assert new_codemeta.metadata == metadata
import argparse
from pathlib import Path
from eossr import ROOT_DIR
from eossr import __version__ as eossr_version
from eossr.metadata import codemeta
from eossr.utils import update_codemeta
def build_argparser():
"""
Construct main argument parser for the ``codemet2zenodo`` script
:return:
argparser: `argparse.ArgumentParser`
"""
parser = argparse.ArgumentParser(description="Update Codemeta")
parser.add_argument(
'--codemeta_path',
'-c',
type=str,
dest='codemeta_path',
help='Path to codemeta.json',
default=Path(ROOT_DIR).joinpath('codemeta.json'),
required=False,
)
return parser
def update_version(codemeta_path):
codemeta_handler = codemeta.Codemeta.from_file(codemeta_path)
metadata = codemeta_handler.metadata
metadata[
'downloadUrl'
] = f'https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/archive/v{eossr_version}/eossr-v{eossr_version}.zip'
metadata['version'] = eossr_version
metadata['softwareVersion'] = eossr_version
codemeta_handler.write(path=codemeta_path, overwrite=True)
if __name__ == '__main__':
parser = build_argparser()
args = parser.parse_args()
html = update_codemeta(codemeta_path=args.codemeta_path)
update_version(args.codemeta_path)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment