Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep authored Nov 19, 2024
0 parents commit 947d181
Show file tree
Hide file tree
Showing 19 changed files with 488 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
time: "7:00"
open-pull-requests-limit: 10
36 changes: 36 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Linting

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --quiet -r requirements-ci.txt
- name: ruff
run: |
ruff --version
ruff check package
- name: black
run: |
black --version
black --check --diff --color package
- name: mypy
run: |
mypy --version
rm -rf .mypy_cache
mypy package
89 changes: 89 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Testing

on:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]
workflow_dispatch:
inputs:
task:
type: choice
options: [tests, release]
default: tests
description: Only run tests or release a new version to PyPI after tests pass.

jobs:
test:
strategy:
max-parallel: 20
matrix:
python-version: ["3.9", "3.10"]

runs-on: ubuntu-latest
env:
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: "python"

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: '**/requirements.txt'
- name: Install dependencies
run: |
pip install --quiet -r requirements.txt -r requirements-ci.txt
pip install -e .
- name: pytest
run: |
pytest --cov=package tests --color=yes
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v3
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

build:
needs: test
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: "3.11"
- run: python -m pip install build
- name: Build sdist
run: |
python -m build --sdist
python -m build --wheel
- uses: actions/upload-artifact@v3
with:
path: dist/*.*

release:
needs: build
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release')
runs-on: ubuntu-latest
permissions:
# For pypi trusted publishing
id-token: write
steps:
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Get build artifacts
uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
verbose: true
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
__pycache__/
.DS_Store
*.o
*.so
*.pyc
*.swp
*.swo
*.pyd
*.c
dist
_build
build
.project
.pydevproject
.settings
.externalToolBuilders
.idea
setuptools*
.ipynb_checkpoints
.cache
.tox
.eggs/
.coverage
.*_cache
# VS Code
.vscode/*
_site

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
47 changes: 47 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
exclude: ^(docs|.*test_files|cmd_line|tasks.py)

ci:
autoupdate_schedule: monthly
skip: [mypy]
autofix_commit_msg: pre-commit auto-fixes
autoupdate_commit_msg: pre-commit autoupdate

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.278
hooks:
- id: ruff
args: [--fix]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
exclude: pymatgen/analysis/vesta_cutoffs.yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
hooks:
- id: mypy

- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
- id: codespell
stages: [commit, commit-msg]
exclude_types: [html]
additional_dependencies: [tomli] # needed to read pyproject.toml below py3.11

- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.15.0
hooks:
- id: cython-lint
args: [--no-pycodestyle]
- id: double-quote-cython-strings
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2011-2012 MIT & The Regents of the University of California,
through Lawrence Berkeley National Laboratory

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[![GitHub license](https://img.shields.io/github/license/materialsvirtuallab/python_template)](https://github.com/materialsvirtuallab/python_template/blob/main/LICENSE)
[![Linting](https://github.com/materialsvirtuallab/python_template/workflows/Linting/badge.svg)](https://github.com/materialsvirtuallab/python_template/workflows/Linting/badge.svg)
[![Testing](https://github.com/materialsvirtuallab/python_template/workflows/Testing/badge.svg)](https://github.com/materialsvirtuallab/python_template/workflows/Testing/badge.svg)
<!--
[![Downloads](https://pepy.tech/badge/python_template)](https://pepy.tech/project/python_template)
[![codecov](https://codecov.io/gh/materialsvirtuallab/python_template/branch/main/graph/badge.svg?token=3V3O79GODQ)]
(https://codecov.io/gh/materialsvirtuallab/python_template)
-->

# Introduction

This is a template for setting up Python packages in the Materials Virtual Lab. It comes with the standard Github
workflows, pyproject and linting.
35 changes: 35 additions & 0 deletions docs/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
source "https://rubygems.org"
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
# bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
# gem "jekyll", "~> 4.3.2"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima", "~> 2.5"
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
gem "github-pages", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.12"
end

# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
# and associated library.
platforms :mingw, :x64_mingw, :mswin, :jruby do
gem "tzinfo", ">= 1", "< 3"
gem "tzinfo-data"
end

# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]

# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem
# do not have a Java counterpart.
gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby]

gem "webrick", "~> 1.8"
21 changes: 21 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
title: MVL template
email: [email protected]
description: >- # this means to ignore newlines until "baseurl:"
This is the template for MAVRL repos.
# twitter_username: jekyllrb
github_username: materialsvirtuallab

# Build settings
remote_theme: just-the-docs/just-the-docs
plugins:
- jekyll-feed

# favicon_ico: "/assets/favicon.ico"

nav_external_links:
- title: "GitHub"
url: "https://github.com/materialsvirtuallab/python_template"

aux_links:
"Materials Virtual Lab":
- "https://materialsvirtuallab.org"
1 change: 1 addition & 0 deletions docs/_includes/footer_custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<small>&copy; Copyright 2022, Materials Virtual Lab</small>
1 change: 1 addition & 0 deletions docs/_includes/nav_footer_custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<span class="site-footer">&copy; Copyright 2022, Materials Virtual Lab</span>
13 changes: 13 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[![GitHub license](https://img.shields.io/github/license/materialsvirtuallab/python_template)](https://github.com/materialsvirtuallab/python_template/blob/main/LICENSE)
[![Linting](https://github.com/materialsvirtuallab/python_template/workflows/Linting/badge.svg)](https://github.com/materialsvirtuallab/python_template/workflows/Linting/badge.svg)
[![Testing](https://github.com/materialsvirtuallab/python_template/workflows/Testing/badge.svg)](https://github.com/materialsvirtuallab/python_template/workflows/Testing/badge.svg)
<!--
[![Downloads](https://pepy.tech/badge/python_template)](https://pepy.tech/project/python_template)
[![codecov](https://codecov.io/gh/materialsvirtuallab/python_template/branch/main/graph/badge.svg?token=3V3O79GODQ)]
(https://codecov.io/gh/materialsvirtuallab/python_template)
-->

# Introduction

This is a template for setting up Python packages in the Materials Virtual Lab. It comes with the standard Github
workflows, pyproject.toml, docs, and linting.
1 change: 1 addition & 0 deletions package/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Root init file."""
Loading

0 comments on commit 947d181

Please sign in to comment.