Skip to content

Commit

Permalink
Merge pull request #133 from Exabyte-io/update/SOF-7390-lfs-1
Browse files Browse the repository at this point in the history
update/SOF 7390 lfs 1
  • Loading branch information
VsevolodX authored Jun 20, 2024
2 parents 54c5b4a + 473b97b commit 4b3c860
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ examples/workflow/get_workflows.ipynb !filter !diff !merge text
images/*.png filter=lfs diff=lfs merge=lfs -text
*.upf filter=lfs diff=lfs merge=lfs -text
examples/assets/bash_workflow_template.json filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
29 changes: 20 additions & 9 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ default:
packages_pyodide:
- lzma
- sqlite3
- https://files.mat3ra.com/uploads/pymatgen-2024.4.13-py3-none-any.whl
- https://files.mat3ra.com:44318/web/pyodide/spglib-2.0.2-py3-none-any.whl
- https://files.pythonhosted.org/packages/d9/0e/2a05efa11ea33513fbdf4a2e2576fe94fd8fa5ad226dbb9c660886390974/ruamel.yaml-0.17.32-py3-none-any.whl
- emfs:/drive/api-examples/packages/pymatgen-2024.4.13-py3-none-any.whl
- emfs:/drive/api-examples/packages/spglib-2.0.2-py3-none-any.whl
- emfs:/drive/api-examples/packages/ruamel.yaml-0.17.32-py3-none-any.whl
- networkx==3.2.1
- monty==2023.11.3
- scipy==1.11.2
Expand All @@ -32,8 +32,8 @@ notebooks:
packages_python:
packages_pyodide:
- annotated_types>=0.6.0
- https://files.mat3ra.com/uploads/pydantic_core-2.18.2-py3-none-any.whl
- https://files.mat3ra.com/uploads/pydantic-2.7.1-py3-none-any.whl
- emfs:/drive/api-examples/packages/pydantic_core-2.18.2-py3-none-any.whl
- emfs:/drive/api-examples/packages/pydantic-2.7.1-py3-none-any.whl
- mat3ra-esse
- mat3ra-made
- name: import_material_from_jarvis_db_entry.ipynb
Expand All @@ -45,8 +45,8 @@ notebooks:
- setuptools
packages_python:
packages_pyodide:
- https://files.mat3ra.com:44318/uploads/paginate-0.5.6-py3-none-any.whl
- https://files.mat3ra.com:44318/uploads/watchdog-2.3.1-py3-none-any.whl
- emfs:/drive/api-examples/packages/paginate-0.5.6-py3-none-any.whl
- emfs:/drive/api-examples/packages/watchdog-2.3.1-py3-none-any.whl
- name: import_materials_from_files.ipynb
packages_common:
- express-py==2024.2.2.post2
Expand All @@ -55,5 +55,16 @@ notebooks:
- setuptools
packages_python:
packages_pyodide:
- https://files.mat3ra.com:44318/uploads/paginate-0.5.6-py3-none-any.whl
- https://files.mat3ra.com:44318/uploads/watchdog-2.3.1-py3-none-any.whl
- emfs:/drive/api-examples/packages/paginate-0.5.6-py3-none-any.whl
- emfs:/drive/api-examples/packages/watchdog-2.3.1-py3-none-any.whl
- name: create_point_defect.ipynb
packages_common:
- ipywidgets
packages_python:
packages_pyodide:
- annotated_types>=0.6.0
- emfs:/drive/api-examples/packages/pydantic_core-2.18.2-py3-none-any.whl
- emfs:/drive/api-examples/packages/pydantic-2.7.1-py3-none-any.whl
- pymatgen-analysis-defects
- mat3ra-esse
- mat3ra-made
2 changes: 1 addition & 1 deletion other/materials_designer/create_point_defect.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
" import micropip\n",
" await micropip.install('mat3ra-api-examples', deps=False)\n",
" from utils.jupyterlite import install_packages\n",
" await install_packages(\"create_interface_with_min_strain_zsl.ipynb\", \"../../config.yml\")"
" await install_packages(\"create_point_defect.ipynb\", \"../../config.yml\")"
],
"metadata": {
"collapsed": false
Expand Down
Empty file added packages/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions packages/paginate-0.5.6-py3-none-any.whl
Git LFS file not shown
3 changes: 3 additions & 0 deletions packages/pydantic-2.7.1-py3-none-any.whl
Git LFS file not shown
3 changes: 3 additions & 0 deletions packages/pydantic_core-2.18.2-py3-none-any.whl
Git LFS file not shown
3 changes: 3 additions & 0 deletions packages/pymatgen-2024.4.13-py3-none-any.whl
Git LFS file not shown
3 changes: 3 additions & 0 deletions packages/ruamel.yaml-0.17.32-py3-none-any.whl
Git LFS file not shown
3 changes: 3 additions & 0 deletions packages/spglib-2.0.2-py3-none-any.whl
Git LFS file not shown
3 changes: 3 additions & 0 deletions packages/watchdog-2.3.1-py3-none-any.whl
Git LFS file not shown
21 changes: 11 additions & 10 deletions utils/jupyterlite.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
from enum import Enum
from typing import Any, Dict, Optional

from IPython.display import Javascript, display

Expand All @@ -24,22 +25,22 @@ class EnvironmentEnum(Enum):
import sys


async def install_package_pyodide(pkg, verbose=True):
async def install_package_pyodide(pkg: str, verbose=True):
"""
Install a package in a Pyodide environment.
Args:
pkg (string): The name of the package to install.
verbose (bool): Whether to print the name of the installed package.
"""
is_url = pkg.startswith("http://") or pkg.startswith("https://")
is_url = pkg.startswith("http://") or pkg.startswith("https://") or pkg.startswith("emfs:/")
are_dependencies_installed = not is_url
await micropip.install(pkg, deps=are_dependencies_installed)
pkg_name = pkg.split("/")[-1].split("-")[0] if is_url else pkg.split("==")[0]
if verbose:
print(f"Installed {pkg_name}")


def install_package_python(pkg, verbose=True):
def install_package_python(pkg: str, verbose=True):
"""
Install a package in a standard Python environment.
Args:
Expand All @@ -51,7 +52,7 @@ def install_package_python(pkg, verbose=True):
print(f"Installed {pkg}")


async def install_packages(notebook_name, requirements_path="config.yml", verbose=True):
async def install_packages(notebook_name: str, requirements_path="config.yml", verbose=True):
"""
Install the packages listed in the requirements file for the notebook with the given name.
Args:
Expand Down Expand Up @@ -113,7 +114,7 @@ async def install_packages(notebook_name, requirements_path="config.yml", verbos
os.environ["requirements_hash"] = requirements_hash


def set_data_pyodide(key, value):
def set_data_pyodide(key: str, value: Any):
"""
Take a Python object, serialize it to JSON, and send it to the host environment
through a JavaScript function defined in the JupyterLite extension `data_bridge`.
Expand All @@ -138,7 +139,7 @@ def set_data_pyodide(key, value):
set_data_python(key, value)


def set_data_python(key, value):
def set_data_python(key: str, value: Any):
"""
Write data to the `uploads` folder in a JupyterLab environment.
Args:
Expand All @@ -154,7 +155,7 @@ def set_data_python(key, value):
print(f"Data for {key} written to {file_path}")


def set_data(key, value):
def set_data(key: str, value: Any):
"""
Switch between the two functions `set_data_pyodide` and `set_data_python` based on the environment.
Args:
Expand All @@ -167,7 +168,7 @@ def set_data(key, value):
set_data_python(key, value)


def get_data_pyodide(key, globals_dict=None):
def get_data_pyodide(key: str, globals_dict: Optional[Dict] = None):
"""
Load data from the host environment into globals()[key] variable.
Args:
Expand All @@ -178,7 +179,7 @@ def get_data_pyodide(key, globals_dict=None):
globals_dict[key] = globals_dict["data_from_host"]


def get_data_python(key, globals_dict=None):
def get_data_python(key: str, globals_dict: Optional[Dict] = None):
"""
Read data from the `uploads` folder in a JupyterLab environment.
Args:
Expand All @@ -200,7 +201,7 @@ def get_data_python(key, globals_dict=None):
print("No data found in the 'uploads' folder.")


def get_data(key, globals_dict=None):
def get_data(key: str, globals_dict: Optional[Dict] = None):
"""
Switch between the two functions `get_data_pyodide` and `get_data_python` based on the environment.
Args:
Expand Down

0 comments on commit 4b3c860

Please sign in to comment.