diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 0000000..c7564fd --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,89 @@ +# Work in progress, needs `camsai/actions` repository to be present +name: Continuous Testing and Publication + +on: [push] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + run-py-linter: + runs-on: ubuntu-22.04 + strategy: + matrix: + python-version: + - 3.10.x + + steps: + - name: Checkout this repository + uses: actions/checkout@v4 + with: + lfs: true + + - name: Checkout actions repository + uses: actions/checkout@v4 + with: + repository: camsai/actions + token: ${{ secrets.GITHUB_TOKEN }} + path: actions + + - name: Run ruff linter + uses: ./actions/py/lint + with: + python-version: ${{ matrix.python-version }} + + run-py-tests: + needs: run-py-linter + runs-on: ubuntu-22.04 + strategy: + matrix: + python-version: + - 3.10.x + - 3.11.x + + steps: + - name: Checkout this repository + uses: actions/checkout@v4 + with: + lfs: true + + - name: Checkout actions repository + uses: actions/checkout@v4 + with: + repository: camsai/actions + token: ${{ secrets.GITHUB_TOKEN }} + path: actions + + - name: Run python unit tests + uses: ./actions/py/pytest + with: + python-version: ${{ matrix.python-version }} + unit-test-directory: tests/ + + publish-py-package: + needs: + - run-py-tests + - run-py-linter + runs-on: ubuntu-latest + if: (github.ref_name == 'main') + + steps: + - name: Checkout this repository + uses: actions/checkout@v4 + with: + lfs: true + + - name: Checkout actions repository + uses: actions/checkout@v4 + with: + repository: camsai/actions + token: ${{ secrets.GITHUB_TOKEN }} + path: actions + + - name: Publish python release + uses: ./actions/py/publish + with: + python-version: 3.10.12 + github-token: ${{ secrets.GITHUB_TOKEN }} + pypi-api-token: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..53e0f31 --- /dev/null +++ b/.gitignore @@ -0,0 +1,163 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control +.pdm.toml +.pdm-python +.pdm-build/ + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +.idea/ +.python-version diff --git a/README.ipynb b/README.ipynb new file mode 100644 index 0000000..941e11f --- /dev/null +++ b/README.ipynb @@ -0,0 +1,60 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# CAMSAI Notebooks\n", + "\n", + "## 1. Overview.\n", + "\n", + "This repository contains a collection of Jupyter notebooks that demonstrate how to use the CAMSAI toolchain.\n", + "\n", + "## 2. Generic Functionality.\n", + "\n", + "The following notebooks are available:\n", + "\n", + "- [validate_data](validate_data.ipynb): This notebook provides an introduction to data standards.\n", + "\n", + "## 3. Specific Functionality.\n", + "\n", + "Below, we list the contents per provider.\n", + "\n", + "| File | Description |\n", + "|----------------------------------------------------|---------------------------------------------------- |\n", + "| [mat3ra/introduction](mat3ra/introduction.ipynb) | Mat3ra Introduction.\n", + "| [Examples/Workflow](jarvisnist/introduction.ipynb) | JARVIS NIST Introduction. |\n", + "\n", + "\n", + "## Links\n", + "\n", + "- [Mat3ra API Documentation](https://docs.mat3ra.com/)\n", + "- [JARVIS NIST](https://jarvis.nist.gov/)\n" + ], + "metadata": { + "collapsed": false + }, + "id": "ca988675356058" + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..41e3949 --- /dev/null +++ b/config.yml @@ -0,0 +1,14 @@ +# This manifest file is used to install the required packages for the corresponding notebook. +# The following types of kernels are supported: +# 1. python +# 2. pyodide +# Accordingly, the packages are installed using the kernel type, e.g., packages_pyodide. +# The default packages are installed for all the notebooks. +default: + packages_common: [] + packages_python: [] + packages_pyodide: [] +notebooks: + - name: validate_data.ipynb + packages_common: + - mat3ra-esse diff --git a/jarvisnist/introduction.ipynb b/jarvisnist/introduction.ipynb new file mode 100644 index 0000000..42c50c3 --- /dev/null +++ b/jarvisnist/introduction.ipynb @@ -0,0 +1,41 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Introduction\n", + "\n", + "## 1. Overview.\n", + "\n", + "A brief overview of the notebooks in this folder.\n", + "\n", + "TBA." + ], + "metadata": { + "collapsed": false + }, + "id": "ca988675356058" + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/mat3ra/introduction.ipynb b/mat3ra/introduction.ipynb new file mode 100644 index 0000000..42c50c3 --- /dev/null +++ b/mat3ra/introduction.ipynb @@ -0,0 +1,41 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Introduction\n", + "\n", + "## 1. Overview.\n", + "\n", + "A brief overview of the notebooks in this folder.\n", + "\n", + "TBA." + ], + "metadata": { + "collapsed": false + }, + "id": "ca988675356058" + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ee1b053 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,94 @@ +[project] +name = "camsai-notebooks" +dynamic = ["version"] +description = "CAMSAI notebooks" +readme = "README.md" +requires-python = ">=3.10" +license = {file = "LICENSE.md"} +authors = [ + {name = "CAMSAI", email = "info@camsai.org"} +] +classifiers = [ + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Development Status :: 3 - Alpha", + "Topic :: Software Development", +] +dependencies = [ + # general requirements + "numpy", + # "pydantic", # included in mat3ra-esse[dev] + # "jsonschema", + # specific requirements + "mat3ra-utils[jupyterlite]", +] + +[project.optional-dependencies] +tests = [ + "coverage[toml]>=5.3", + "pre-commit", + "black", + "ruff", + "isort", + "mypy", + "pip-tools", + # Testing + "pytest", + "pytest-cov", + "pytest-mock", + "pytest-asyncio", +] +all = ["camsai-notebooks[tests]"] + +# Entrypoint scripts can be defined here, see examples below. +[project.scripts] +# my-script = "my_package.my_module:my_function" + + +[build-system] +requires = [ + "setuptools>=42", + "setuptools-scm[toml]>=3.4" +] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +git_describe_command = "git describe --tags --long" + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-data] +src = ["config.yml"] + + +[tool.black] +line-length = 120 +target-version = ['py310'] +# 'extend-exclude' excludes files or directories in addition to the defaults +extend-exclude = ''' +( + examples\/.*\/.*\.py + | other\/.*\/.*\.(py|ipynb) +) +''' + +[tool.ruff] +# Exclude a variety of commonly ignored directories. +extend-exclude = [ + "src/js" +] +line-length = 120 +target-version = "py310" + +[tool.ruff.per-file-ignores] +"__init__.py" = ["F401"] + +[tool.isort] +profile = "black" +multi_line_output = 3 +include_trailing_comma = true + +# to avoid `warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))` +[tool.pytest.ini_options] +asyncio_default_fixture_loop_scope = "function" diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/camsai/__init__.py b/src/camsai/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/camsai/notebooks/__init__.py b/src/camsai/notebooks/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/camsai/notebooks/utils/__init__.py b/src/camsai/notebooks/utils/__init__.py new file mode 100644 index 0000000..b4007a2 --- /dev/null +++ b/src/camsai/notebooks/utils/__init__.py @@ -0,0 +1 @@ +from mat3ra.utils.jupyterlite.packages import install_packages diff --git a/tests/test_install_packages.py b/tests/test_install_packages.py new file mode 100644 index 0000000..15086ab --- /dev/null +++ b/tests/test_install_packages.py @@ -0,0 +1,7 @@ +import pytest +from camsai.notebooks.utils import install_packages + +@pytest.mark.asyncio +async def test_install_packages(): + await install_packages("validate_data.ipynb", "./config.yml") + assert True diff --git a/validate_data.ipynb b/validate_data.ipynb new file mode 100644 index 0000000..ba4d786 --- /dev/null +++ b/validate_data.ipynb @@ -0,0 +1,150 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Validate Data.\n", + "\n", + "Validate the data in the input materials.\n", + "\n", + "