From 06e469674eb3ce3563278009cbbace15849b5fea Mon Sep 17 00:00:00 2001 From: David Waroquiers Date: Mon, 25 Mar 2024 14:09:02 +0100 Subject: [PATCH] Initial commit --- .github/workflows/testing.yml | 34 +++++++ .github/workflows/update-precommit.yml | 31 ++++++ .gitignore | 129 +++++++++++++++++++++++++ .pre-commit-config.yaml | 70 ++++++++++++++ LICENSE | 37 +++++++ README.md | 10 ++ pyproject.toml | 87 +++++++++++++++++ src/atomate2/myaddon/__init__.py | 0 src/atomate2/myaddon/mymodule.py | 20 ++++ tests/test_myfunc.py | 5 + 10 files changed, 423 insertions(+) create mode 100644 .github/workflows/testing.yml create mode 100644 .github/workflows/update-precommit.yml create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 pyproject.toml create mode 100644 src/atomate2/myaddon/__init__.py create mode 100644 src/atomate2/myaddon/mymodule.py create mode 100644 tests/test_myfunc.py diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..9f79306 --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,34 @@ +name: testing + +on: + push: + + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + cache: pip + cache-dependency-path: pyproject.toml + + - name: Install dependencies & package + run: | + python -m pip install --upgrade pip + pip install .[strict,tests,dev] + pip install . + + - name: Lint + run: | + pre-commit run --all-files --show-diff-on-failure + + - name: Test + run: | + pytest tests diff --git a/.github/workflows/update-precommit.yml b/.github/workflows/update-precommit.yml new file mode 100644 index 0000000..79eeb88 --- /dev/null +++ b/.github/workflows/update-precommit.yml @@ -0,0 +1,31 @@ +name: pre-commit-auto-update + +on: + schedule: + - cron: '0 0 1,14,28 * *' + +jobs: + auto-update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.8 + + - name: Install pre-commit + run: pip install pre-commit + + - name: Run pre-commit autoupdate + run: pre-commit autoupdate + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + with: + branch: update/pre-commit-autoupdate + title: Auto-update pre-commit hooks + commit-message: Auto-update pre-commit hooks + body: Update versions of tools in pre-commit config to latest versions. + labels: dependencies diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b6e4761 --- /dev/null +++ b/.gitignore @@ -0,0 +1,129 @@ +# 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/ +pip-wheel-metadata/ +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/ + +# 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 +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.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 + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__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/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..133cb96 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,70 @@ +default_language_version: + python: python3 + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: fix-encoding-pragma + args: [--remove] + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://github.com/myint/autoflake + rev: v2.0.1 + hooks: + - id: autoflake +- repo: https://github.com/psf/black + rev: 22.12.0 + hooks: + - id: black +- repo: https://github.com/asottile/blacken-docs + rev: 1.13.0 + hooks: + - id: blacken-docs + additional_dependencies: [black] + exclude: README.md +- repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort +- repo: https://github.com/pycqa/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + entry: pflake8 + files: ^src/ + additional_dependencies: + - pyproject-flake8==6.0.0 + - flake8-bugbear==22.12.6 + - flake8-typing-imports==1.14.0 + - flake8-docstrings==1.6.0 + - flake8-rst-docstrings==0.3.0 + - flake8-rst==0.8.0 +- repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 + hooks: + - id: python-use-type-annotations + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.991 + hooks: + - id: mypy + files: ^src/ + additional_dependencies: + - tokenize-rt==4.1.0 + - types-pkg_resources==0.1.2 + - types-paramiko +- repo: https://github.com/codespell-project/codespell + rev: v2.2.2 + hooks: + - id: codespell + stages: [commit, commit-msg] + args: [--ignore-words-list, 'titel,statics,ba,nd,te'] +- repo: https://github.com/asottile/pyupgrade + rev: v3.3.1 + hooks: + - id: pyupgrade + args: [--py38-plus] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..662f729 --- /dev/null +++ b/LICENSE @@ -0,0 +1,37 @@ +atomate2-lammps Copyright (c) 2022, Matgenix SRL +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +(1) Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +(2) Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +(3) Neither the name of the Matgenix SRL, nor the names of its contributors may +be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +You are under no obligation whatsoever to provide any bug fixes, patches, or +upgrades to the features, functionality or performance of the source code +("Enhancements") to anyone; however, if you choose to make your Enhancements +available either publicly, or directly to Matgenix or its contributors, without +imposing a separate written license agreement for such Enhancements, then you +hereby grant the following license: a non-exclusive, royalty-free perpetual +license to install, use, modify, prepare derivative works, incorporate into +other computer software, distribute, and sublicense such enhancements or +derivative works thereof, in binary and source code form. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9a331fb --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# atomate2-addon-template + +This is an example add-on package for [atomate2](https://github.com/materialsproject/atomate2). + +It is heavily based on +the equivalent [add-on template for pymatgen](https://github.com/materialsproject/pymatgen-addon-template). + +## License + +This add-on is released under the same license as atomate2, modified BSD, the full text of which can be found in this repository. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..0a90898 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,87 @@ +[build-system] +requires = ["setuptools >= 42", "versioningit ~= 1.0", "wheel"] +build-backend = "setuptools.build_meta" + +[tools.setuptools] +packages = ["atomate2.myaddon"] +[tools.setuptools.find] +where = ["src"] + +[project] +name = "atomate2-myaddon" +description = "atomate2-myaddon is an example of a minimal atomate2 namespace add-on." +readme = "README.md" +license = { text = "modified BSD" } +authors = [{ name = "Matthew Evans", email = "matthew.evans@matgenix.com" }] +dynamic = ["version"] +classifiers = [ + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Science/Research", + "Intended Audience :: System Administrators", + "Intended Audience :: Information Technology", + "Operating System :: OS Independent", + "Topic :: Other/Nonlisted Topic", + "Topic :: Scientific/Engineering", +] +requires-python = ">=3.8" +dependencies =[ + "atomate2", + "pymatgen" +] + +[project.optional-dependencies] +dev = ["atomate2[dev]"] +docs = ["atomate2[docs]"] +tests = ["atomate2[tests]"] +strict = ["atomate2[strict]"] + +[project.urls] +repository = "https://github.com/matgenix/atomate2-addon-template" + +[tool.versioningit.vcs] +method = "git" +default-tag = "0.0.1" + +[tool.isort] +profile = "black" + +[tool.flake8] +max-line-length = 88 +max-doc-length = 88 +select = "C, E, F, W, B" +extend-ignore = "E203, W503, E501, F401, RST21" +min-python-version = "3.8.0" +docstring-convention = "numpy" +rst-roles = "class, func, ref, obj" + +[tool.mypy] +ignore_missing_imports = true +no_strict_optional = true + +[tool.coverage.run] +include = ["src/*"] +parallel = true +branch = true + +[tool.coverage.paths] +source = ["src/"] + +[tool.coverage.report] +skip_covered = true +show_missing = true +exclude_lines = [ + '^\s*assert False(,|$)', + 'if typing.TYPE_CHECKING:', + '^\s*@overload( |$)', +] + +[tool.autoflake] +in-place = true +remove-all-unused-imports = true +remove-unused-variables = true +ignore-init-module-imports = true +expand-star-imports = true diff --git a/src/atomate2/myaddon/__init__.py b/src/atomate2/myaddon/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/atomate2/myaddon/mymodule.py b/src/atomate2/myaddon/mymodule.py new file mode 100644 index 0000000..2437681 --- /dev/null +++ b/src/atomate2/myaddon/mymodule.py @@ -0,0 +1,20 @@ +""" +Example module of addon package. +""" + + +def myfunc(a: int, b: int) -> int: + """ + Example function in addon. + + Parameters + ---------- + a: The first number to add. + b: The second number to add. + + Returns + ------- + The two numbers added together. + + """ + return a + b diff --git a/tests/test_myfunc.py b/tests/test_myfunc.py new file mode 100644 index 0000000..84a83c1 --- /dev/null +++ b/tests/test_myfunc.py @@ -0,0 +1,5 @@ +from atomate2.myaddon.mymodule import myfunc + + +def test_myfunc(): + assert myfunc(1, 1) == 2