Skip to content

Commit c677d48

Browse files
author
Shyue Ping Ong
committed
Initial commit.
1 parent bc57ec1 commit c677d48

File tree

12 files changed

+393
-27
lines changed

12 files changed

+393
-27
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: pip
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "7:00"
8+
open-pull-requests-limit: 10

.github/workflows/linting.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Linting
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
max-parallel: 4
10+
matrix:
11+
python-version: ["3.10"]
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install dependencies
22+
run: |
23+
pip install --quiet -r requirements-ci.txt
24+
- name: ruff
25+
run: |
26+
ruff --version
27+
ruff check package
28+
- name: black
29+
run: |
30+
black --version
31+
black --check --diff --color package
32+
- name: mypy
33+
run: |
34+
mypy --version
35+
rm -rf .mypy_cache
36+
mypy package

.github/workflows/testing.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Testing
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
release:
9+
types: [published]
10+
workflow_dispatch:
11+
inputs:
12+
task:
13+
type: choice
14+
options: [tests, release]
15+
default: tests
16+
description: Only run tests or release a new version to PyPI after tests pass.
17+
18+
jobs:
19+
test:
20+
strategy:
21+
max-parallel: 20
22+
matrix:
23+
python-version: ["3.9", "3.10"]
24+
25+
runs-on: ubuntu-latest
26+
env:
27+
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: "python"
28+
29+
steps:
30+
- uses: actions/checkout@v3
31+
- name: Set up Python ${{ matrix.python-version }}
32+
uses: actions/setup-python@v4
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
cache: pip
36+
cache-dependency-path: '**/requirements.txt'
37+
- name: Install dependencies
38+
run: |
39+
pip install --quiet -r requirements.txt -r requirements-ci.txt
40+
pip install -e .
41+
- name: pytest
42+
run: |
43+
pytest --cov=package tests --color=yes
44+
- name: Coveralls
45+
uses: coverallsapp/github-action@v2
46+
47+
build:
48+
needs: test
49+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release')
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v3
53+
- uses: actions/setup-python@v4
54+
name: Install Python
55+
with:
56+
python-version: "3.11"
57+
- run: python -m pip install build
58+
- name: Build sdist
59+
run: |
60+
python -m build --sdist
61+
python -m build --wheel
62+
- uses: actions/upload-artifact@v3
63+
with:
64+
path: dist/*.*
65+
66+
release:
67+
needs: build
68+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release')
69+
runs-on: ubuntu-latest
70+
permissions:
71+
# For pypi trusted publishing
72+
id-token: write
73+
steps:
74+
- name: Set up Python 3.11
75+
uses: actions/setup-python@v4
76+
with:
77+
python-version: 3.11
78+
- name: Get build artifacts
79+
uses: actions/download-artifact@v3
80+
with:
81+
name: artifact
82+
path: dist
83+
- name: Publish to PyPi
84+
uses: pypa/gh-action-pypi-publish@release/v1
85+
with:
86+
skip-existing: true
87+
verbose: true

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
__pycache__/
2+
.DS_Store
3+
*.o
4+
*.so
5+
*.pyc
6+
*.swp
7+
*.swo
8+
*.pyd
9+
*.c
10+
dist
11+
_build
12+
build
13+
.project
14+
.pydevproject
15+
.settings
16+
.externalToolBuilders
17+
.idea
18+
setuptools*
19+
.ipynb_checkpoints
20+
.cache
21+
.tox
22+
.eggs/
23+
.coverage
24+
.*_cache
25+
# VS Code
26+
.vscode/*
27+
28+
# Environments
29+
.env
30+
.venv
31+
env/
32+
venv/
33+
ENV/
34+
env.bak/
35+
venv.bak/

LICENSE

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
1-
BSD 3-Clause License
1+
The MIT License (MIT)
2+
Copyright (c) 2011-2012 MIT & The Regents of the University of California,
3+
through Lawrence Berkeley National Laboratory
24

3-
Copyright (c) 2023, Materials Virtual Lab
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
411

5-
Redistribution and use in source and binary forms, with or without
6-
modification, are permitted provided that the following conditions are met:
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
714

8-
1. Redistributions of source code must retain the above copyright notice, this
9-
list of conditions and the following disclaimer.
10-
11-
2. Redistributions in binary form must reproduce the above copyright notice,
12-
this list of conditions and the following disclaimer in the documentation
13-
and/or other materials provided with the distribution.
14-
15-
3. Neither the name of the copyright holder nor the names of its
16-
contributors may be used to endorse or promote products derived from
17-
this software without specific prior written permission.
18-
19-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
# python_template
2-
A template repository for setting up new python packages
1+
# Introduction
2+
3+
This is a template for setting up Python packages in the Materials Virtual Lab. It comes with the standard Github
4+
workflows, pyproject and linting.

package/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
Root init file.
3+
"""

pyproject.toml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
[build-system]
2+
requires = [
3+
# pin NumPy version used in the build
4+
"oldest-supported-numpy",
5+
"setuptools>=65.0.0",
6+
]
7+
build-backend = "setuptools.build_meta"
8+
9+
[tool.versioningit.vcs]
10+
method = "git"
11+
default-tag = "0.0.1"
12+
13+
[tool.black]
14+
line-length = 120
15+
16+
[tool.ruff]
17+
target-version = "py38"
18+
line-length = 120
19+
select = [
20+
"B", # flake8-bugbear
21+
"C4", # flake8-comprehensions
22+
"D", # pydocstyle
23+
"E", # pycodestyle error
24+
"EXE", # flake8-executable
25+
"F", # pyflakes
26+
"FA", # flake8-future-annotations
27+
"FLY", # flynt
28+
"I", # isort
29+
"ICN", # flake8-import-conventions
30+
"ISC", # flake8-implicit-str-concat
31+
"PD", # pandas-vet
32+
"PERF", # perflint
33+
"PIE", # flake8-pie
34+
"PL", # pylint
35+
"PT", # flake8-pytest-style
36+
"PYI", # flakes8-pyi
37+
"Q", # flake8-quotes
38+
"RET", # flake8-return
39+
"RSE", # flake8-raise
40+
"RUF", # Ruff-specific rules
41+
"SIM", # flake8-simplify
42+
"SLOT", # flake8-slots
43+
"TCH", # flake8-type-checking
44+
"TID", # tidy imports
45+
"TID", # flake8-tidy-imports
46+
"UP", # pyupgrade
47+
"W", # pycodestyle warning
48+
"YTT", # flake8-2020
49+
]
50+
ignore = [
51+
"B023", # Function definition does not bind loop variable
52+
"B028", # No explicit stacklevel keyword argument found
53+
"B904", # Within an except clause, raise exceptions with ...
54+
"C408", # unnecessary-collection-call
55+
"D105", # Missing docstring in magic method
56+
"D205", # 1 blank line required between summary line and description
57+
"D212", # Multi-line docstring summary should start at the first line
58+
"PD901", # pandas-df-variable-name
59+
"PERF203", # try-except-in-loop
60+
"PERF401", # manual-list-comprehension (TODO fix these or wait for autofix)
61+
"PLR", # pylint refactor
62+
"PLW2901", # Outer for loop variable overwritten by inner assignment target
63+
"PT013", # pytest-incorrect-pytest-import
64+
"RUF012", # Disable checks for mutable class args. This is a non-problem.
65+
"SIM105", # Use contextlib.suppress(OSError) instead of try-except-pass
66+
]
67+
pydocstyle.convention = "google"
68+
isort.required-imports = ["from __future__ import annotations"]
69+
isort.split-on-trailing-comma = false
70+
71+
[tool.ruff.per-file-ignores]
72+
"__init__.py" = ["F401"]
73+
"*/tests/*" = ["D"]
74+
"tasks.py" = ["D"]
75+
"pymatgen/analysis/*" = ["D"]
76+
"pymatgen/vis/*" = ["D"]
77+
"pymatgen/io/*" = ["D"]
78+
"dev_scripts/*" = ["D"]
79+
80+
[tool.pytest.ini_options]
81+
addopts = "--durations=30 --quiet -r xXs --color=yes -p no:warnings --import-mode=importlib"
82+
83+
[tool.coverage.run]
84+
omit = ["pymatgen/cli"]
85+
relative_files = true
86+
87+
[tool.coverage.report]
88+
exclude_lines = [
89+
"@deprecated",
90+
"def __repr__",
91+
"if 0:",
92+
"if __name__ == .__main__.:",
93+
"if self.debug:",
94+
"if settings.DEBUG",
95+
"pragma: no cover",
96+
"raise AssertionError",
97+
"raise NotImplementedError",
98+
]
99+
100+
[tool.mypy]
101+
ignore_missing_imports = true
102+
namespace_packages = true
103+
explicit_package_bases = true
104+
no_implicit_optional = false
105+
106+
[[tool.mypy.overrides]]
107+
module = ["requests.*", "tabulate.*"]
108+
ignore_missing_imports = true
109+
110+
[tool.codespell]
111+
ignore-words-list = """
112+
titel,alls,ans,nd,mater,nwo,te,hart,ontop,ist,ot,fo,nax,coo,coul,ser,leary,thre,
113+
fase,rute,reson,titels,ges,scalr,strat,struc,hda,nin,ons,pres,kno,loos,lamda,lew
114+
"""
115+
check-filenames = true

requirements-ci.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ase>=3.22.1
2+
chemview>=0.6
3+
netCDF4>=1.5.8
4+
fdint>=2.0.2
5+
phonopy>=2.16.3
6+
h5py>=3.8.0
7+
BoltzTraP2>=22.3.2
8+
f90nml>=1.4.3
9+
# hiphive>=0.6
10+
seekpath>=2.0.1
11+
jarvis-tools>=2022.9.16
12+
galore>=0.7.0
13+
matgl>=0.5.1

requirements.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
numpy==1.24.3
2+
sympy==1.11.1
3+
requests==2.29.0
4+
monty==2022.9.9
5+
ruamel.yaml==0.17.32
6+
scipy==1.9.0
7+
tabulate==0.9.0
8+
matplotlib==3.5.2
9+
palettable==3.3.0
10+
spglib==2.0.2
11+
pandas==2.0.3
12+
networkx==2.8.8
13+
plotly==5.11.0
14+
beautifulsoup4==4.12.2
15+
uncertainties==3.1.7
16+
Cython==3.0.0
17+
pybtex==0.24.0
18+
mp-api==0.33.3
19+
tqdm==4.65.0
20+
joblib==1.3.1

0 commit comments

Comments
 (0)