diff --git a/examples/notebooks/Harvest_zenodo.ipynb b/examples/notebooks/Harvest_zenodo.ipynb index 06a835b530f6a8d2f770b1846a1c9a237f0eac99..40b8387ba6cfceae86171d59ac7a330d36dd6b30 100644 --- a/examples/notebooks/Harvest_zenodo.ipynb +++ b/examples/notebooks/Harvest_zenodo.ipynb @@ -5,7 +5,7 @@ "id": "b0fcf1bf", "metadata": {}, "source": [ - "<h1><center> <font size=\"36\"> How to harvest metadata from Zenodo </font> </center></h1>\n", + "<h1><center> <font size=\"36\"> Example of protocols to harvest metadata from Zenodo </font> </center></h1>\n", "\n", "---------------------\n", "#### Notebook outline \n", @@ -13,7 +13,6 @@ " - Zenodo REST API\n", " - Explore the REST API answer (payload) with the `request` library\n", " - Using `eossr` library\n", - " - Using `PyZenodo3` library\n", " - Pros and cons of both methods\n", " \n", "---------------------" @@ -191,16 +190,6 @@ "However, you would need to [create one](https://zenodo.org/account/settings/applications/) if you would like to write or publish through the API." ] }, - { - "cell_type": "code", - "execution_count": 4, - "id": "ddccf248", - "metadata": {}, - "outputs": [], - "source": [ - "token = ''" - ] - }, { "cell_type": "markdown", "id": "4cd8011b", @@ -441,16 +430,16 @@ " 'title': 'EOSC Symposium 2021 Report'},\n", " 'owners': [91736],\n", " 'revision': 8,\n", - " 'stats': {'downloads': 438.0,\n", - " 'unique_downloads': 374.0,\n", - " 'unique_views': 475.0,\n", - " 'version_downloads': 438.0,\n", - " 'version_unique_downloads': 374.0,\n", - " 'version_unique_views': 475.0,\n", - " 'version_views': 494.0,\n", - " 'version_volume': 724854084.0,\n", - " 'views': 494.0,\n", - " 'volume': 724854084.0},\n", + " 'stats': {'downloads': 479.0,\n", + " 'unique_downloads': 411.0,\n", + " 'unique_views': 514.0,\n", + " 'version_downloads': 479.0,\n", + " 'version_unique_downloads': 411.0,\n", + " 'version_unique_views': 514.0,\n", + " 'version_views': 537.0,\n", + " 'version_volume': 792705722.0,\n", + " 'views': 537.0,\n", + " 'volume': 792705722.0},\n", " 'updated': '2021-08-24T14:27:14.603504+00:00'}" ] }, @@ -676,227 +665,14 @@ "source": [ "## eossr\n", "\n", - "All these methods are implemented in the [Zenodo client](https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/blob/master/eossr/api/zenodo.py) (a REST API handler) of the [eossr library](https://gitlab.in2p3.fr/escape2020/wp3/eossr). \n", - "\n", - "The library is also in charge of automatise the project's uploads from GitLab to Zenodo (by the use of the GitLab-CI and the REST API handler)." - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "id": "6cd7f714", - "metadata": {}, - "outputs": [], - "source": [ - "# pip install https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/archive/master/eossr-master.zip" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "id": "0dbbbd64", - "metadata": {}, - "outputs": [], - "source": [ - "from eossr.api.zenodo import ZenodoAPI\n", - "z = ZenodoAPI(access_token=token, sandbox=False)" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "id": "2037338d", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "15" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "entries = z.fetch_community_entries(community_name='escape2020', \n", - " results_per_query=100)\n", - "entries.json()['hits']['total']" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "id": "3985383f", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "5176089 EOSC Symposium 2021 Report\n", - "5153369 agnpy: Modelling Active Galactic Nuclei radiative processes with python.\n", - "5093909 ESCAPE Data Science Summer School 2021\n", - "4923992 ESCAPE template project\n", - "4786641 ZenodoCI\n", - "4601451 gLike: numerical maximization of heterogeneous joint likelihood functions of a common free parameter plus nuisance parameters\n", - "4419866 IndexedConv/IndexedConv: v1.3\n", - "4044010 EOSC - a tool for enabling Open Science in Europe\n", - "3854976 FairRootGroup/DDS\n", - "3743489 ESCAPE the maze\n", - "3675081 ESFRI cluster projects - Position papers on expectations and planned contributions to the EOSC\n", - "3659184 ctapipe_io_mchdf5\n", - "3614662 FairRoot\n", - "3362435 FairMQ\n", - "3356656 A prototype for a real time pipeline for the detection of transient signals and their automatic classification\n" - ] - } - ], - "source": [ - "ids = z.fetch_community_entries_per_id(community_name='escape2020', \n", - " results_per_query=100)\n", - "\n", - "titles = z.fetch_community_entries_per_title(community_name='escape2020', \n", - " results_per_query=100)\n", - "\n", - "for id, title in zip(ids, titles):\n", - " print(id, title)" - ] - }, - { - "cell_type": "markdown", - "id": "595ba083", - "metadata": {}, - "source": [ - "## PyZenodo3\n", - "\n", - "Another equivalent example with the pyzenodo3 library" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "id": "91985172", - "metadata": {}, - "outputs": [], - "source": [ - "# pip install pyzenodo3" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "id": "7cd937b9", - "metadata": {}, - "outputs": [], - "source": [ - "import pyzenodo3\n", - "\n", - "zen = pyzenodo3.Zenodo()\n", - "records = zen.search('agnpy')" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "id": "815578d9", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'conceptdoi': '10.5281/zenodo.5174757',\n", - " 'conceptrecid': '5174757',\n", - " 'created': '2021-08-10T07:43:16.545873+00:00',\n", - " 'doi': '10.5281/zenodo.5174758',\n", - " 'files': [{'bucket': '4a6752c9-f922-45f5-a6e5-82f9a016ba87',\n", - " 'checksum': 'md5:516ae662f4d8a251a7d8b9fb41007e56',\n", - " 'key': 'cosimoNigro/agnpy_paper-v0.1.0.zip',\n", - " 'links': {'self': 'https://zenodo.org/api/files/4a6752c9-f922-45f5-a6e5-82f9a016ba87/cosimoNigro/agnpy_paper-v0.1.0.zip'},\n", - " 'size': 45740,\n", - " 'type': 'zip'}],\n", - " 'id': 5174758,\n", - " 'links': {'badge': 'https://zenodo.org/badge/doi/10.5281/zenodo.5174758.svg',\n", - " 'bucket': 'https://zenodo.org/api/files/4a6752c9-f922-45f5-a6e5-82f9a016ba87',\n", - " 'conceptbadge': 'https://zenodo.org/badge/doi/10.5281/zenodo.5174757.svg',\n", - " 'conceptdoi': 'https://doi.org/10.5281/zenodo.5174757',\n", - " 'doi': 'https://doi.org/10.5281/zenodo.5174758',\n", - " 'html': 'https://zenodo.org/record/5174758',\n", - " 'latest': 'https://zenodo.org/api/records/5174758',\n", - " 'latest_html': 'https://zenodo.org/record/5174758',\n", - " 'self': 'https://zenodo.org/api/records/5174758'},\n", - " 'metadata': {'access_right': 'open',\n", - " 'access_right_category': 'success',\n", - " 'creators': [{'affiliation': \"Institut de FÃsica d'Altes Energies (IFAE), The Barcelona Institute of Science and Technology, Campus UAB, 08193 Bellaterra (Barcelona), Spain\",\n", - " 'name': 'Cosimo Nigro',\n", - " 'orcid': '0000-0001-8375-1907'},\n", - " {'affiliation': 'University of Lodz, Faculty of Physics and Applied Informatics, Department of Astrophysics, 90-236 Lodz, Poland',\n", - " 'name': 'Julian Sitarek',\n", - " 'orcid': '0000-0002-1659-5374'},\n", - " {'affiliation': 'University of Lodz, Faculty of Physics and Applied Informatics, Department of Astrophysics, 90-236 Lodz, Poland',\n", - " 'name': 'PaweÅ‚ Gliwny',\n", - " 'orcid': '0000-0002-4183-391X'},\n", - " {'affiliation': \"Laboratoire d'Annecy de Physique des Particules, Univ. Grenoble Alpes, Univ. Savoie Mont Blanc, CNRS, LAPP, 74000 Annecy, France\",\n", - " 'name': 'David Sanchez'},\n", - " {'affiliation': 'Minnesota State University Moorhead, Moorhead, Minnesota, US',\n", - " 'name': 'Matthew Craig',\n", - " 'orcid': '0000-0002-4183-391X'}],\n", - " 'description': \"This repository contains the scripts to generate the figures included in the paper 'agnpy: an open-source python package modelling the radiative processes of jetted active galactic nuclei'.\",\n", - " 'doi': '10.5281/zenodo.5174758',\n", - " 'keywords': ['radiative processes',\n", - " 'blazars',\n", - " 'radio galaxies',\n", - " 'AGN',\n", - " 'jets',\n", - " 'MWL',\n", - " 'astropy',\n", - " 'numpy',\n", - " 'python'],\n", - " 'license': {'id': 'other-open'},\n", - " 'publication_date': '2021-08-10',\n", - " 'related_identifiers': [{'identifier': 'https://github.com/cosimoNigro/agnpy_paper/tree/v0.1.0',\n", - " 'relation': 'isSupplementTo',\n", - " 'scheme': 'url'},\n", - " {'identifier': '10.5281/zenodo.5174757',\n", - " 'relation': 'isVersionOf',\n", - " 'scheme': 'doi'}],\n", - " 'relations': {'version': [{'count': 1,\n", - " 'index': 0,\n", - " 'is_last': True,\n", - " 'last_child': {'pid_type': 'recid', 'pid_value': '5174758'},\n", - " 'parent': {'pid_type': 'recid', 'pid_value': '5174757'}}]},\n", - " 'resource_type': {'title': 'Software', 'type': 'software'},\n", - " 'title': 'agnpy: an open-source python package modelling the radiative processes of jetted active galactic nuclei',\n", - " 'version': '0.1.0'},\n", - " 'owners': [99841],\n", - " 'revision': 3,\n", - " 'stats': {'downloads': 0.0,\n", - " 'unique_downloads': 0.0,\n", - " 'unique_views': 12.0,\n", - " 'version_downloads': 0.0,\n", - " 'version_unique_downloads': 0.0,\n", - " 'version_unique_views': 12.0,\n", - " 'version_views': 13.0,\n", - " 'version_volume': 0.0,\n", - " 'views': 13.0,\n", - " 'volume': 0.0},\n", - " 'updated': '2021-08-10T13:48:43.185119+00:00'}" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "records[0].data" + "The eossr library uses Zenodo REST API.\n", + "See the [OSSR API notebook](ossr_search.ipynb) for an example on how to use it.\n" ] }, { "cell_type": "code", "execution_count": null, - "id": "a304d374", + "id": "563902f1", "metadata": {}, "outputs": [], "source": [] @@ -918,7 +694,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.10" + "version": "3.9.2" } }, "nbformat": 4, diff --git a/examples/notebooks/ossr_search.ipynb b/examples/notebooks/ossr_api.ipynb similarity index 93% rename from examples/notebooks/ossr_search.ipynb rename to examples/notebooks/ossr_api.ipynb index bd1793556f1b5653deb3842dc180d89cee75b7e1..c5d386f2624f11e52bdc703defc880589c3ba782 100644 --- a/examples/notebooks/ossr_search.ipynb +++ b/examples/notebooks/ossr_api.ipynb @@ -266,6 +266,37 @@ "metadata": {}, "outputs": [], "source": [] + }, + { + "cell_type": "markdown", + "id": "d5e9bc28", + "metadata": {}, + "source": [ + "# Upload records on the OSSR" + ] + }, + { + "cell_type": "markdown", + "id": "a4123841", + "metadata": {}, + "source": [ + "To upload records on the OSSR, you may use the [Zenodo client](https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/blob/master/eossr/api/zenodo.py).\n", + "\n", + "This is also used by the continuous integration to automatise project's uploads from GitLab to Zenodo.\n", + "\n", + "To do so, you will need to use your Zenodo token ([create one](https://zenodo.org/account/settings/applications/tokens/new/))." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "69c6f758", + "metadata": {}, + "outputs": [], + "source": [ + "from eossr.api.zenodo import ZenodoAPI\n", + "z = ZenodoAPI(access_token=token, sandbox=False)" + ] } ], "metadata": {