From a7ae0fcd02c0a06ca71bd6f605093eb0e20b38f3 Mon Sep 17 00:00:00 2001
From: vuillaut <thomas.vuillaume@gmail.com>
Date: Fri, 10 Sep 2021 16:30:49 +0200
Subject: [PATCH] adding example notebook

---
 examples/notebooks/ossr_search.ipynb | 295 +++++++++++++++++++++++++++
 1 file changed, 295 insertions(+)
 create mode 100644 examples/notebooks/ossr_search.ipynb

diff --git a/examples/notebooks/ossr_search.ipynb b/examples/notebooks/ossr_search.ipynb
new file mode 100644
index 00000000..e727ea40
--- /dev/null
+++ b/examples/notebooks/ossr_search.ipynb
@@ -0,0 +1,295 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "id": "4a25feec",
+   "metadata": {},
+   "source": [
+    "# Find ESCAPE OSSR records"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "id": "dbde9b19",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from eossr.api import Ossr, get_all_ossr_records, pprint_record"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "id": "2fe017bc",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "ossr_records = get_all_ossr_records()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 3,
+   "id": "5eb34293",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "15"
+      ]
+     },
+     "execution_count": 3,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "len(ossr_records)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "93b033a0",
+   "metadata": {},
+   "source": [
+    "Records are objects containing data and metadata sent by Zenodo API"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "id": "f88ebfd3",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "{'conceptdoi': '10.5281/zenodo.5176088', 'conceptrecid': '5176088', 'created': '2021-08-16T07:21:15.005975+00:00', 'doi': '10.5281/zenodo.5176089', 'files': [{'bucket': '409f3f8e-cb73-4a10-b718-3b8fc238a616', 'checksum': 'md5:eab8fbaa4c318cbd75629eb6a7719ecb', 'key': 'EOSC_SYMPOSIUM_2021_Report.pdf', 'links': {'self': 'https://zenodo.org/api/files/409f3f8e-cb73-4a10-b718-3b8fc238a616/EOSC_SYMPOSIUM_2021_Report.pdf'}, 'size': 1654918, 'type': 'pdf'}], 'id': 5176089, 'links': {'badge': 'https://zenodo.org/badge/doi/10.5281/zenodo.5176089.svg', 'bucket': 'https://zenodo.org/api/files/409f3f8e-cb73-4a10-b718-3b8fc238a616', 'conceptbadge': 'https://zenodo.org/badge/doi/10.5281/zenodo.5176088.svg', 'conceptdoi': 'https://doi.org/10.5281/zenodo.5176088', 'doi': 'https://doi.org/10.5281/zenodo.5176089', 'html': 'https://zenodo.org/record/5176089', 'latest': 'https://zenodo.org/api/records/5176089', 'latest_html': 'https://zenodo.org/record/5176089', 'self': 'https://zenodo.org/api/records/5176089'}, 'metadata': {'access_right': 'open', 'access_right_category': 'success', 'communities': [{'id': 'envri'}, {'id': 'eosc_synergy'}, {'id': 'eoscsecretariat'}, {'id': 'escape2020'}, {'id': 'expands'}, {'id': 'ni4os-europe'}, {'id': 'sshoc'}], 'contributors': [{'affiliation': 'Trust-IT Services', 'name': 'Ferguson, Nicholas', 'orcid': '0000-0001-5523-6430', 'type': 'WorkPackageLeader'}], 'creators': [{'affiliation': 'Technopolis Group Belgium', 'name': 'Bertacchini, Veronica'}, {'affiliation': 'Trust-IT Services', 'name': 'Drago, Federico', 'orcid': '0000-0002-1333-4478'}, {'affiliation': 'TU Wien', 'name': 'Flicker, Katharina', 'orcid': '0000-0001-6040-2798'}, {'affiliation': 'KIT', 'name': 'Gebreyesus, Netsanet'}, {'affiliation': 'GÉANT', 'name': 'Grant, Annabel'}, {'affiliation': 'CERN', 'name': 'Jones, Bob', 'orcid': '0000-0001-9092-4589'}, {'affiliation': 'CSC-IT Center for Science', 'name': 'Liinamaa, Iiris'}, {'affiliation': 'CSC-IT Center for Science', 'name': 'Märkälä, Anu'}, {'affiliation': 'Athena Research Center', 'name': 'Marinos-Kouris, Christos'}, {'affiliation': 'GO FAIR Foundation', 'name': 'Meerman, Bert', 'orcid': '0000-0002-0071-2660'}, {'affiliation': 'TU Wien', 'name': 'Saurugger, Bernd', 'orcid': '0000-0001-5730-3983'}, {'affiliation': 'Trust-IT Services', 'name': 'Smith, Zachary', 'orcid': '0000-0002-9984-008X'}], 'description': '<p>The EOSC Symposium 2021 provided a key engagement opportunity for the EOSC community after the European Open Science Cloud finally entered its highly-anticipated implementation phase in 2021. Delivered online to just under 1,000 EOSC stakeholders from over 63 different countries, this was not only the largest EOSC Symposium yet, but it was also an essential opportunity for convergence and alignment on principles and priorities.</p>\\n\\n<p>The EOSC Association will play an important role in this phase. With already over 210 member and observer organisations from across Europe, the Association represents a single voice for the advocacy and representation of the broader EOSC Stakeholder community in Europe, promoting alignment of EU research policy and priorities.</p>\\n\\n<p>The Association will continuously develop the EOSC Strategic Research and Innovation Agenda (SRIA) which will influence future EOSC activities at institutional, national and EU level (including the EOSC-related work programmes in Horizon Europe). This living document will adapt to the changing EOSC ecosystem and the needs of EOSC stakeholders. The Association is setting up a series of Advisory Groups (AG) with Task Forces (TF) to engage with the EOSC community around priority areas, namely:</p>\\n\\n<ul>\\n\\t<li>Implementation of EOSC</li>\\n\\t<li>Metadata and Data Quality</li>\\n\\t<li>Research Careers and Curricula</li>\\n\\t<li>Sustaining&nbsp;EOSC</li>\\n\\t<li>Technical Challenges on EOSC</li>\\n</ul>\\n\\n<p>The Symposium was the first opportunity for the Association to present the draft charters of the Task Forces. A key objective of the event was also for the Association to understand what work has been carried out, is in progress, or is planned on the topics of the AGs and TFs. A call for contributions ran throughout May 2021, with a total of 137 applications received. Through presentations, lightning talks, and panels, over 70 community members were able to highlight key findings and recommendations for the AGs and TFs to take into consideration for their work.</p>', 'doi': '10.5281/zenodo.5176089', 'grants': [{'acronym': 'EOSCsecretariat.eu', 'code': '831644', 'funder': {'acronyms': [], 'doi': '10.13039/501100000780', 'links': {'self': 'https://zenodo.org/api/funders/10.13039/501100000780'}, 'name': 'European Commission'}, 'links': {'self': 'https://zenodo.org/api/grants/10.13039/501100000780::831644'}, 'program': 'H2020', 'title': 'EOSCsecretariat.eu'}], 'keywords': ['EOSC', 'Open Science', 'Horizon Europe', 'Interoperability'], 'language': 'eng', 'license': {'id': 'CC-BY-4.0'}, 'publication_date': '2021-08-10', 'related_identifiers': [{'identifier': '10.5281/zenodo.5176088', 'relation': 'isVersionOf', 'scheme': 'doi'}], 'relations': {'version': [{'count': 1, 'index': 0, 'is_last': True, 'last_child': {'pid_type': 'recid', 'pid_value': '5176089'}, 'parent': {'pid_type': 'recid', 'pid_value': '5176088'}}]}, 'resource_type': {'subtype': 'report', 'title': 'Report', 'type': 'publication'}, 'title': 'EOSC Symposium 2021 Report'}, 'owners': [91736], 'revision': 8, 'stats': {'downloads': 462.0, 'unique_downloads': 395.0, 'unique_views': 498.0, 'version_downloads': 462.0, 'version_unique_downloads': 395.0, 'version_unique_views': 498.0, 'version_views': 519.0, 'version_volume': 764572116.0, 'views': 519.0, 'volume': 764572116.0}, 'updated': '2021-08-24T14:27:14.603504+00:00'}\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(ossr_records[0])"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "cb5f905e",
+   "metadata": {},
+   "source": [
+    "You can use `pprint_record` to display minimal information about a `Record`:"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 5,
+   "id": "a9ec3d38",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "=== Record #5176089 : EOSC Symposium 2021 Report ===\n",
+      "<p>The EOSC Symposium 2021 provided a key engagement opportunity for the EOSC community after the European Open Science Cloud finally entered its highly-anticipated implementation phase in 2021. Delivered online to just under 1,000 EOSC stakeholders from over 63 different countries, this was not only the largest EOSC Symposium yet, but it was also an essential opportunity for convergence and alignment on principles and priorities.</p>\n",
+      "\n",
+      "<p>The EOSC Association will play an important role in this phase. With already over 210 member and observer organisations from across Europe, the Association represents a single voice for the advocacy and representation of the broader EOSC Stakeholder community in Europe, promoting alignment of EU research policy and priorities.</p>\n",
+      "\n",
+      "<p>The Association will continuously develop the EOSC Strategic Research and Innovation Agenda (SRIA) which will influence future EOSC activities at institutional, national and EU level (including the EOSC-related work programmes in Horizon Europe). This living document will adapt to the changing EOSC ecosystem and the needs of EOSC stakeholders. The Association is setting up a series of Advisory Groups (AG) with Task Forces (TF) to engage with the EOSC community around priority areas, namely:</p>\n",
+      "\n",
+      "<ul>\n",
+      "\t<li>Implementation of EOSC</li>\n",
+      "\t<li>Metadata and Data Quality</li>\n",
+      "\t<li>Research Careers and Curricula</li>\n",
+      "\t<li>Sustaining&nbsp;EOSC</li>\n",
+      "\t<li>Technical Challenges on EOSC</li>\n",
+      "</ul>\n",
+      "\n",
+      "<p>The Symposium was the first opportunity for the Association to present the draft charters of the Task Forces. A key objective of the event was also for the Association to understand what work has been carried out, is in progress, or is planned on the topics of the AGs and TFs. A call for contributions ran throughout May 2021, with a total of 137 applications received. Through presentations, lightning talks, and panels, over 70 community members were able to highlight key findings and recommendations for the AGs and TFs to take into consideration for their work.</p>\n",
+      "\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "pprint_record(ossr_records[0])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "301723f4",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  },
+  {
+   "cell_type": "markdown",
+   "id": "0a8049f9",
+   "metadata": {},
+   "source": [
+    "## Specific OSSR search\n",
+    "\n",
+    "To make a specific OSSR search, you can use the `Ossr` class"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "id": "e88cac03",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "ossr = Ossr()"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "868c10b5",
+   "metadata": {},
+   "source": [
+    "### Based on a string"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 7,
+   "id": "0dad88b3",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "records = ossr.search('template')"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 8,
+   "id": "5e1d8124",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "1"
+      ]
+     },
+     "execution_count": 8,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "len(records)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 9,
+   "id": "f5a15764",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "=== Record #4923992 : ESCAPE template project ===\n",
+      "<p>An example of software project template for the ESCAPE 2020 European project</p>\n",
+      "\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "pprint_record(records[0])"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "c4b08fde",
+   "metadata": {},
+   "source": [
+    "### Using keywords:"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 10,
+   "id": "f5cb8f77",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "2"
+      ]
+     },
+     "execution_count": 10,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "cta_records = ossr.search('', keywords='CTA')\n",
+    "len(cta_records)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 11,
+   "id": "019f21eb",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "=== Record #4419866 : IndexedConv/IndexedConv: v1.3 ===\n",
+      "<p>Update for PyTorch 1.7</p>\n",
+      "\n",
+      "\n",
+      "=== Record #3659184 : ctapipe_io_mchdf5 ===\n",
+      "<p>ctapipe plugin for reading and converting Monte-Carlo files (contains the same information as Simtel files)</p>\n",
+      "\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "for record in cta_records:\n",
+    "    pprint_record(record)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "5f304419",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.9.2"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
-- 
GitLab