Skip to content

Commit

Permalink
Merge pull request #80 from Exabyte-io/feat/SOF-6720-1-style
Browse files Browse the repository at this point in the history
SOF-6720:  reformat `qe_scf_calculation.ipynb` notebook
  • Loading branch information
pranabdas committed Jul 4, 2023
2 parents ee886ce + ee22f57 commit 8f4e880
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 4 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,25 @@ NOTE: The Materials Project API key should be obtained from [https://legacy.mate

This is an open-source repository and we welcome contributions for other use cases. The original set of examples is only meant to demonstrate the capabilities and can be extended.

We suggest forking this repository and introducing the adjustments there. The changes in the fork can further be considered for merging into this repository as it is commonly used on Github. This process is explained in more details elsewhere online [[4](#links)].
We suggest forking this repository and introducing the adjustments there. The changes in the fork can further be considered for merging into this repository as it is commonly used on GitHub. This process is explained in more details elsewhere online [[4](#links)].

If you would like to add new examples or adjust existing ones, please consider the following:

1. Put examples into the corresponding directories by domain.

2. Walk the readers through the examples by providing step-by-step explanation similar to [this](examples/material/get_materials_by_formula.ipynb).
2. Walk the readers through the examples by providing step-by-step explanation similar to [this](examples/material/get_materials_by_formula.ipynb) example.

3. We use post-save hooks to automatically convert notebooks to python scripts. See [config](examples/config.py) file for more information. In order to facilitate code review, we exclude notebook sources from version control and store them in Git LFS [[3](#links)]. Please follow this convention.
3. We use post-save hooks to automatically convert notebooks to python scripts. See [config](examples/config.py) file for more information. In order to facilitate code review, we exclude notebook sources in the `other/` directory from version control and store them in Git LFS [[3](#links)]. Please follow this convention.

4. Apply code formatting by installing development requirements as follows:

```bash
pip install -e ."[dev]"
pre-commit install
pre-commit run --all-files
```

Check more details about `pre-commit` [here](https://pre-commit.com/).

## Links

Expand Down
61 changes: 61 additions & 0 deletions examples/workflow/qe_scf_calculation.ipynb
Original file line number Diff line number Diff line change
@@ -1,13 +1,74 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "e5d1a592",
"metadata": {},
"source": [
"<a href=\"https://colab.research.google.com/github/Exabyte-io/api-examples/blob/dev/examples/workflow/qe_scf_calculation.ipynb\" target=\"_parent\">\n",
"<img alt=\"Open in Google Colab\" src=\"https://user-images.githubusercontent.com/20477508/128780728-491fea90-9b23-495f-a091-11681150db37.jpeg\" width=\"150\" border=\"0\">\n",
"</a>"
]
},
{
"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
42 changes: 42 additions & 0 deletions examples/workflow/qe_scf_calculation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,51 @@
#!/usr/bin/env python
# coding: utf-8

# <a href="https://colab.research.google.com/github/Exabyte-io/api-examples/blob/dev/examples/workflow/qe_scf_calculation.ipynb" target="_parent">
# <img alt="Open in Google Colab" src="https://user-images.githubusercontent.com/20477508/128780728-491fea90-9b23-495f-a091-11681150db37.jpeg" width="150" border="0">
# </a>

# # 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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ localhost = [
]
dev = [
"pre-commit>=3.3.3",
"pip-compile>=6.13.0",
"pip-tools>=6.13.0",
]
docs = [
"mkdocs>=1.4.3",
Expand Down

0 comments on commit 8f4e880

Please sign in to comment.