Skip to content

Commit

Permalink
MNT: produce .py from examples/workflow/qe_scf_calculation.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mrakitin committed Jul 4, 2023
1 parent c2b790a commit 0b106d9
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
50 changes: 50 additions & 0 deletions examples/workflow/qe_scf_calculation.ipynb
Original file line number Diff line number Diff line change
@@ -1,13 +1,63 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "92673fc2-8999-415b-a866-7692a3e7d682",
"metadata": {},
"source": [
"# Quantum Espresso SCF calcuation via API\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "41378265",
"metadata": {},
"source": [
"# Complete Authorization Form and Initialize Settings\n",
"\n",
"This will also determine environment and set all environment variables. We determine if we are using Jupyter Notebooks or Google Colab to run this tutorial.\n",
"\n",
"If you are running this notebook from Google Colab, Colab takes ~1 min to execute the following cell.\n",
"\n",
"ACCOUNT_ID and AUTH_TOKEN - Authentication parameters needed for when making requests to [Mat3ra.com's API Endpoints](https://docs.mat3ra.com/rest-api/endpoints/).\n",
"\n",
"MATERIALS_PROJECT_API_KEY - Authentication parameter needed for when making requests to [Material Project's API](https://materialsproject.org/open)\n",
"\n",
"ORGANIZATION_ID - Authentication parameter needed for when working with collaborative accounts https://docs.mat3ra.com/collaboration/organizations/overview/\n",
"\n",
"> <span style=\"color: orange\">**NOTE**</span>: If you are running this notebook from Jupyter, the variables ACCOUNT_ID, AUTH_TOKEN, MATERIALS_PROJECT_API_KEY, and ORGANIZATION_ID should be set in the file [settings.json](../../utils/settings.json) if you need to use these variables. To obtain API token parameters, please see the following link to the documentation explaining how to get them: https://docs.mat3ra.com/accounts/ui/preferences/api/"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "62f59cb7",
"metadata": {},
"outputs": [],
"source": [
"# @title Authorization Form\n",
"ACCOUNT_ID = \"ACCOUNT_ID\" # @param {type:\"string\"}\n",
"AUTH_TOKEN = \"AUTH_TOKEN\" # @param {type:\"string\"}\n",
"MATERIALS_PROJECT_API_KEY = \"MATERIALS_PROJECT_API_KEY\" # @param {type:\"string\"}\n",
"ORGANIZATION_ID = \"ORGANIZATION_ID\" # @param {type:\"string\"}\n",
"\n",
"import os\n",
"\n",
"if \"COLAB_JUPYTER_IP\" in os.environ:\n",
" os.environ.update(\n",
" dict(\n",
" ACCOUNT_ID=ACCOUNT_ID,\n",
" AUTH_TOKEN=AUTH_TOKEN,\n",
" MATERIALS_PROJECT_API_KEY=MATERIALS_PROJECT_API_KEY,\n",
" ORGANIZATION_ID=ORGANIZATION_ID,\n",
" )\n",
" )\n",
"\n",
" !GIT_BRANCH=\"dev\"; export GIT_BRANCH; curl -s \"https://raw.githubusercontent.com/Exabyte-io/api-examples/${GIT_BRANCH}/scripts/env.sh\" | bash"
]
},
{
"cell_type": "code",
"execution_count": 1,
Expand Down
38 changes: 38 additions & 0 deletions examples/workflow/qe_scf_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,44 @@
# # Quantum Espresso SCF calcuation via API
#

# # Complete Authorization Form and Initialize Settings
#
# This will also determine environment and set all environment variables. We determine if we are using Jupyter Notebooks or Google Colab to run this tutorial.
#
# If you are running this notebook from Google Colab, Colab takes ~1 min to execute the following cell.
#
# ACCOUNT_ID and AUTH_TOKEN - Authentication parameters needed for when making requests to [Mat3ra.com's API Endpoints](https://docs.mat3ra.com/rest-api/endpoints/).
#
# MATERIALS_PROJECT_API_KEY - Authentication parameter needed for when making requests to [Material Project's API](https://materialsproject.org/open)
#
# ORGANIZATION_ID - Authentication parameter needed for when working with collaborative accounts https://docs.mat3ra.com/collaboration/organizations/overview/
#
# > <span style="color: orange">**NOTE**</span>: If you are running this notebook from Jupyter, the variables ACCOUNT_ID, AUTH_TOKEN, MATERIALS_PROJECT_API_KEY, and ORGANIZATION_ID should be set in the file [settings.json](../../utils/settings.json) if you need to use these variables. To obtain API token parameters, please see the following link to the documentation explaining how to get them: https://docs.mat3ra.com/accounts/ui/preferences/api/

# In[ ]:


# @title Authorization Form
ACCOUNT_ID = "ACCOUNT_ID" # @param {type:"string"}
AUTH_TOKEN = "AUTH_TOKEN" # @param {type:"string"}
MATERIALS_PROJECT_API_KEY = "MATERIALS_PROJECT_API_KEY" # @param {type:"string"}
ORGANIZATION_ID = "ORGANIZATION_ID" # @param {type:"string"}

import os

if "COLAB_JUPYTER_IP" in os.environ:
os.environ.update(
dict(
ACCOUNT_ID=ACCOUNT_ID,
AUTH_TOKEN=AUTH_TOKEN,
MATERIALS_PROJECT_API_KEY=MATERIALS_PROJECT_API_KEY,
ORGANIZATION_ID=ORGANIZATION_ID,
)
)

get_ipython().system('GIT_BRANCH="dev"; export GIT_BRANCH; curl -s "https://raw.githubusercontent.com/Exabyte-io/api-examples/${GIT_BRANCH}/scripts/env.sh" | bash')


# In[1]:


Expand Down

0 comments on commit 0b106d9

Please sign in to comment.