Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:Exabyte-io/api-examples into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
timurbazhirov committed Apr 1, 2024
2 parents 3149f07 + 69352b9 commit 40f831c
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 102 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/cicd.yml
Expand Up @@ -28,6 +28,31 @@ jobs:
python -m pip install pre-commit
pre-commit run --all-files --show-diff-on-failure
publish-py-package:
needs: [run-linter]
runs-on: ubuntu-latest
if: github.ref_name == 'dev'

steps:
- name: Checkout this repository
uses: actions/checkout@v4
with:
lfs: true

- name: Checkout actions repository
uses: actions/checkout@v4
with:
repository: Exabyte-io/actions
token: ${{ secrets.BOT_GITHUB_TOKEN }}
path: actions

- name: Publish python release
uses: ./actions/py/publish
with:
python-version: 3.8.x
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}
pypi-api-token: ${{ secrets.PYPI_API_TOKEN }}

# TODO: Add back when when fixed.
# build-and-deploy-docs:
# runs-on: ubuntu-20.04
Expand Down
14 changes: 10 additions & 4 deletions other/jupyterlite/utils.py
Expand Up @@ -69,22 +69,28 @@ async def install_packages(notebook_name, requirements_path="config.yml", verbos
requirements_hash = str(hash(json.dumps(requirements)))
if os.environ.get("requirements_hash") != requirements_hash:
packages_default_common = requirements.get("default", {}).get("packages_common", []) or []
packages_default_environment_specific = requirements.get("default", {}).get(f"packages_{ENVIRONMENT.value}", []) or []
packages_default_environment_specific = (
requirements.get("default", {}).get(f"packages_{ENVIRONMENT.value}", []) or []
)

notebook_requirements = next(
(cfg for cfg in requirements.get("notebooks", []) if cfg.get("name") == notebook_name), None
)
if notebook_requirements:
packages_notebook_common = notebook_requirements.get("packages_common", []) or []
packages_notebook_environment_specific= notebook_requirements.get(f"packages_{ENVIRONMENT.value}", []) or []
packages_notebook_environment_specific = (
notebook_requirements.get(f"packages_{ENVIRONMENT.value}", []) or []
)
else:
raise ValueError(f"No packages found for notebook {notebook_name}")

# Note: environment specific packages have to be installed first,
# because in Pyodide common packages might depend on them
packages = [
*packages_default_common,
*packages_default_environment_specific,
*packages_notebook_common,
*packages_notebook_environment_specific,
*packages_default_common,
*packages_notebook_common,
]

for pkg in packages:
Expand Down
92 changes: 52 additions & 40 deletions other/materials_designer/create_interface_with_min_strain_zsl.ipynb
Expand Up @@ -10,8 +10,7 @@
"\n",
"<h2 style=\"color:green\">Usage</h2>\n",
"\n",
"0. Make sure to select Input Materials\n",
"1. Execute \"Run first: ...\" cell below to load Input Materials into the current kernel\n",
"1. Make sure to select Input Materials\n",
"2. Set Input Parameters (e.g. `MILLER_INDICES`, `THICKNESS`, `MAX_AREA`) below or use the default values\n",
"3. Click \"Run\" > \"Run All Cells\" to run all cells\n",
"4. Wait for the run to complete (depending on the area, it can take 1-2 min or more). Scroll down to view cell results.\n",
Expand All @@ -31,25 +30,6 @@
"3. When the strain matching is finished, the interface with the lowest strain (and the smallest number of atoms) is selected. We create the corresponding supercells and place them at a specified distance from each other (note no shift is performed currently).\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 style=\"color:red\">Run first: load input materials in current kernel</h2>\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from jupyterlite.utils import get_data\n",
"\n",
"# Get the list of input materials and load them into `materials_in` variable\n",
"get_data(\"materials_in\", globals())"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -75,7 +55,9 @@
" \"MATERIAL_INDEX\": 1, # the index of the material in the materials_in list\n",
" \"MILLER_INDICES\": (0, 0, 1), # the miller indices of the interfacial plane\n",
" \"THICKNESS\": 1, # in layers\n",
"}"
"}\n",
"\n",
"USE_CONVENTIONAL_CELL = True # if True, the surface plane is constructed using miller indices of the conventional cell"
]
},
{
Expand Down Expand Up @@ -143,12 +125,45 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3. Create interfaces\n",
"## 3. Load and prepare input Materials\n"
]
},
{
"cell_type": "code",
"outputs": [],
"source": [
"from jupyterlite.utils import get_data\n",
"from pymatgen.analysis.structure_analyzer import SpacegroupAnalyzer\n",
"from src.utils import to_pymatgen\n",
"\n",
"# Get the list of input materials and load them into `materials_in` variable\n",
"get_data(\"materials_in\", globals())\n",
"\n",
"if \"materials_in\" in globals():\n",
" pymatgen_materials = [to_pymatgen(item) for item in materials_in]\n",
" if USE_CONVENTIONAL_CELL: pymatgen_materials = [SpacegroupAnalyzer(item).get_conventional_standard_structure() for\n",
" item in pymatgen_materials]\n",
"\n",
" for material in pymatgen_materials:\n",
" print(material, \"\\n\")"
],
"metadata": {
"collapsed": false
},
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"## 4. Create interfaces\n",
"\n",
"### 3.1. Extract Interfaces and Terminations\n",
"### 4.1. Extract Interfaces and Terminations\n",
"\n",
"Extract all possible layer/substrate supercell combinations within the maximum area including different terminations."
]
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
Expand All @@ -160,14 +175,11 @@
"outputs": [],
"source": [
"from src.pymatgen_coherent_interface_builder import CoherentInterfaceBuilder, ZSLGenerator\n",
"from src.utils import to_pymatgen\n",
"\n",
"if \"materials_in\" in globals():\n",
" pymatgen_materials = [to_pymatgen(item) for item in materials_in]\n",
"for material in pymatgen_materials:\n",
" print(material, \"\\n\")\n",
"\n",
"from src.utils import translate_to_bottom\n",
"\n",
"# Translate the materials to the bottom of the cell to allow for multilayer heterostructures creation\n",
"pymatgen_materials = [translate_to_bottom(item) for item in pymatgen_materials]\n",
" \n",
"def create_interfaces(settings):\n",
" print(\"Creating interfaces...\")\n",
" zsl = ZSLGenerator(\n",
Expand Down Expand Up @@ -221,7 +233,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### 3.2. Print out the interfaces and terminations"
"### 5.2. Print out the interfaces and terminations"
]
},
{
Expand All @@ -239,9 +251,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4. Sort interfaces by strain\n",
"## 5. Sort interfaces by strain\n",
"\n",
"### 4.1. Sort all interfaces"
"### 5.1. Sort all interfaces"
]
},
{
Expand Down Expand Up @@ -271,7 +283,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### 4.2. Print out interfaces with lowest strain for each termination"
"### 5.2. Print out interfaces with lowest strain for each termination"
]
},
{
Expand All @@ -291,7 +303,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 5. Plot the results\n",
"## 6. Plot the results\n",
"\n",
"Plot the number of atoms vs strain. Adjust the parameters as needed.\n"
]
Expand Down Expand Up @@ -367,9 +379,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 6. Select the interface to pass outside this kernel\n",
"## 7. Select the interface to pass outside this kernel\n",
"\n",
"### 6.1. Select the interface with the desired termination and strain\n",
"### 7.1. Select the interface with the desired termination and strain\n",
"\n",
"The data in `sorted_interfaces` now contains an object with the following structure:\n",
"\n",
Expand Down Expand Up @@ -409,7 +421,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### 6.2. Pass data to the outside runtime\n"
"### 7.2. Pass data to the outside runtime\n"
]
},
{
Expand Down

0 comments on commit 40f831c

Please sign in to comment.