From 3611479f7c1108137d92e11b453c30f899047fb3 Mon Sep 17 00:00:00 2001
From: Luigi Sbailo <luigi.sbailo@physik.hu-berlin.de>
Date: Sat, 2 Apr 2022 18:12:19 +0200
Subject: [PATCH] Upgrade nomad API

---
 tetradymite_PRM2020.ipynb | 90 ++++++++++++++++++++++++++++-----------
 1 file changed, 66 insertions(+), 24 deletions(-)

diff --git a/tetradymite_PRM2020.ipynb b/tetradymite_PRM2020.ipynb
index 0b63a42..21e0dd1 100644
--- a/tetradymite_PRM2020.ipynb
+++ b/tetradymite_PRM2020.ipynb
@@ -80,8 +80,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2022-02-03T15:17:02.333397Z",
-     "start_time": "2022-02-03T15:17:02.326564Z"
+     "end_time": "2022-04-02T16:11:38.936835Z",
+     "start_time": "2022-04-02T16:11:38.929994Z"
     },
     "init_cell": true
    },
@@ -113,8 +113,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2022-02-03T15:17:02.340869Z",
-     "start_time": "2022-02-03T15:17:02.335388Z"
+     "end_time": "2022-04-02T16:11:38.944992Z",
+     "start_time": "2022-04-02T16:11:38.940335Z"
     },
     "init_cell": true
    },
@@ -134,20 +134,48 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-06-21T15:58:13.011817Z",
-     "start_time": "2021-06-21T15:58:01.884774Z"
+     "end_time": "2022-04-02T16:11:31.621762Z",
+     "start_time": "2022-04-02T16:11:30.061189Z"
     }
    },
    "outputs": [],
    "source": [
     "# The dataset is stored in the NOMAD Archive and can be accessed with this query.\n",
     "from nomad import client, config\n",
-    "config.client.url = 'http://nomad-lab.eu/prod/rae/api'\n",
-    "query = client.query_archive(query={\n",
-    "    'dataset_id': ['BjT-NFK0QdOx81_z5TmyeQ']},\n",
-    "                                  per_page=100,\n",
-    ")\n",
-    "print(query)\n"
+    "from nomad.client.archive import ArchiveQuery\n",
+    "from nomad.metainfo import units\n",
+    "import nest_asyncio\n",
+    "nest_asyncio.apply()\n",
+    "\n",
+    "query_param={\n",
+    "        \"datasets.dataset_id:any\": [\n",
+    "          \"BjT-NFK0QdOx81_z5TmyeQ\"\n",
+    "        ]\n",
+    "    }\n",
+    "\n",
+    "required={\n",
+    "        'workflow':{\n",
+    "            'calculation_result_ref':{\n",
+    "                'energy':{\n",
+    "                    'total':'*',\n",
+    "                },\n",
+    "                'system_ref':{\n",
+    "                    'chemical_composition_reduced': '*',\n",
+    "                    'atoms': {\n",
+    "                        'labels':'*',   \n",
+    "                        'positions':'*',\n",
+    "                        'lattice_vectors':'*',\n",
+    "                    },\n",
+    "                    'symmetry':{\n",
+    "                        'space_group_number': '*',                    \n",
+    "                    },                \n",
+    "                },\n",
+    "            },            \n",
+    "        }    \n",
+    "    }\n",
+    "max_entries=1000\n",
+    "query = ArchiveQuery(query=query_param, required=required, page_size=20, results_max=max_entries)\n",
+    "query.fetch()"
    ]
   },
   {
@@ -155,8 +183,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2022-02-03T15:17:02.357307Z",
-     "start_time": "2022-02-03T15:17:02.341830Z"
+     "end_time": "2022-04-02T16:11:38.965829Z",
+     "start_time": "2022-04-02T16:11:38.946398Z"
     },
     "init_cell": true
    },
@@ -165,6 +193,20 @@
     "df_train = pd.read_pickle('./data/tetradymite_PRM2020/training_set')"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2022-04-02T16:09:31.283833Z",
+     "start_time": "2022-04-02T16:09:31.252040Z"
+    }
+   },
+   "outputs": [],
+   "source": [
+    "df_train"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": null,
@@ -227,8 +269,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2022-02-03T15:17:02.426971Z",
-     "start_time": "2022-02-03T15:17:02.358431Z"
+     "end_time": "2022-04-02T16:11:39.006154Z",
+     "start_time": "2022-04-02T16:11:38.966910Z"
     },
     "init_cell": true
    },
@@ -271,8 +313,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2022-02-03T15:17:02.435420Z",
-     "start_time": "2022-02-03T15:17:02.428037Z"
+     "end_time": "2022-04-02T16:11:39.012351Z",
+     "start_time": "2022-04-02T16:11:39.007515Z"
     },
     "init_cell": true
    },
@@ -335,8 +377,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2022-02-03T15:17:02.446436Z",
-     "start_time": "2022-02-03T15:17:02.436346Z"
+     "end_time": "2022-04-02T16:11:39.060675Z",
+     "start_time": "2022-04-02T16:11:39.013346Z"
     },
     "init_cell": true
    },
@@ -471,8 +513,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2022-02-03T15:17:02.597783Z",
-     "start_time": "2022-02-03T15:17:02.447596Z"
+     "end_time": "2022-04-02T16:11:39.217140Z",
+     "start_time": "2022-04-02T16:11:39.061785Z"
     },
     "init_cell": true,
     "scrolled": false
@@ -562,7 +604,7 @@
  "metadata": {
   "celltoolbar": "Initialization Cell",
   "kernelspec": {
-   "display_name": "Python 3 (ipykernel)",
+   "display_name": "Python 3",
    "language": "python",
    "name": "python3"
   },
@@ -576,7 +618,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.9.7"
+   "version": "3.7.3"
   }
  },
  "nbformat": 4,
-- 
GitLab