Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/rkingsbury/pyEQL into de…
Browse files Browse the repository at this point in the history
…velop
  • Loading branch information
rkingsbury committed Aug 1, 2023
2 parents c7155ed + 426d5c9 commit 781ad4a
Show file tree
Hide file tree
Showing 40 changed files with 725 additions and 986 deletions.
29 changes: 29 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Summary

Major changes:

- feature 1: ...
- fix 1: ...

## Todos

If this is work in progress, what else needs to be done?

- feature 2: ...
- fix 2:

## Checklist

- [ ] Google format doc strings added.
- [ ] Code linted with `ruff`. (For guidance in fixing rule violates, see [rule list](https://beta.ruff.rs/docs/rules/))
- [ ] Type annotations included. Check with `mypy`.
- [ ] Tests added for new features/fixes.
- [ ] I have run the tests locally and they passed.
<!-- - [ ] If applicable, new classes/functions/modules have [`duecredit`](https://github.com/duecredit/duecredit) `@due.dcite` decorators to reference relevant papers by DOI ([example](https://github.com/materialsproject/pymatgen/blob/91dbe6ee9ed01d781a9388bf147648e20c6d58e0/pymatgen/core/lattice.py#L1168-L1172)) -->

Tip: Install `pre-commit` hooks to auto-check types and linting before every commit:

```sh
pip install -U pre-commit
pre-commit install
```
26 changes: 26 additions & 0 deletions .github/workflows/post-process.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Post-process

on:
workflow_run:
types:
- completed
workflows:
# List all required workflow names here.
- 'testing'

jobs:
# https://github.com/marketplace/actions/tag-release-on-push-action
auto-gen-release:
name: Tag/Release on merge of labeled PRs
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- # It is often a desired behavior to merge only when a workflow execution
# succeeds. This can be changed as needed.
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: rymndhng/[email protected]
with:
# loonly release when PRs with release:major/minor/patch labels are merged
bump_version_scheme: norelease
use_github_release_notes: true
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: release

on:
release:
types: [published]

jobs:
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes

deploy:
runs-on: ubuntu-latest
environment: publish

steps:
- uses: actions/checkout@v3


- uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools setuptools_scm wheel tox
- name: Build packages for distribution
run: |
tox -e build
- name: Upload to PyPi
uses: pypa/[email protected]
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
24 changes: 13 additions & 11 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,28 @@ on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
steps:
- uses: actions/checkout@v3
- name: Setup Python
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install tox
python-version: 3.11
cache: pip
- name: Run pre-commit
run: |
python -m pip install tox
- name: Lint
run: tox -e lint
pip install pre-commit
pre-commit run
test:
needs: lint
strategy:
max-parallel: 6
matrix:
python:
- "3.8"
- "3.9"
- "3.10"
# - "3.11"
python-version: ["3.8", "3.9", "3.10", "3.11"]
platform:
- ubuntu-latest
- macos-latest
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/upgrade_dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# https://www.oddbird.net/2022/06/01/dependabot-single-pull-request/
# https://github.com/materialsproject/MPContribs/blob/master/.github/workflows/upgrade-dependencies.yml
name: upgrade dependencies

on:
workflow_dispatch: # Allow running on-demand
schedule:
# Runs every Monday at 8:00 UTC (4:00 Eastern)
- cron: '0 8 * * 1'

jobs:
upgrade:
name: ${{ matrix.package }} (${{ matrix.os }}/py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
package: ["."]
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Upgrade Python dependencies
shell: bash
run: |
python -m pip install --upgrade pip pip-tools
cd ${{ matrix.package }}
python -m piptools compile -q --upgrade --resolver=backtracking -o requirements/${{ matrix.os }}_py${{ matrix.python-version }}.txt
python -m piptools compile -q --upgrade --resolver=backtracking --all-extras -o requirements/${{ matrix.os }}_py${{ matrix.python-version }}_extras.txt
- name: Detect changes
id: changes
shell: bash
run: |
#git diff-index HEAD ${{ matrix.package }}/requirements/${{ matrix.os }}_py${{ matrix.python-version }}*.txt | awk '{print $4}' | sort -u
#sha1=$(git diff-index HEAD ${{ matrix.package }}/requirements/${{ matrix.os }}_py${{ matrix.python-version }}*.txt | awk '{print $4}' | sort -u | head -n1)
#[[ $sha1 == "0000000000000000000000000000000000000000" ]] && git update-index --really-refresh ${{ matrix.package }}/requirements/${{ matrix.os }}_py${{ matrix.python-version }}*.txt
echo "count=$(git diff-index HEAD ${{ matrix.package }}/requirements/${{ matrix.os }}_py${{ matrix.python-version }}*.txt | wc -l | xargs)" >> $GITHUB_OUTPUT
echo "files=$(git ls-files --exclude-standard --others ${{ matrix.package }}/requirements/${{ matrix.os }}_py${{ matrix.python-version }}*.txt | wc -l | xargs)" >> $GITHUB_OUTPUT
- name: commit & push changes
if: steps.changes.outputs.count > 0 || steps.changes.outputs.files > 0
shell: bash
run: |
git config user.name github-actions
git config user.email [email protected]
git add ${{ matrix.package }}/requirements
git commit -m "update dependencies for ${{ matrix.package }} (${{ matrix.os }}/py${{ matrix.python-version }})"
git push -f origin ${{ github.ref_name }}:auto-dependency-upgrades-${{ matrix.package }}-${{ matrix.os }}-py${{ matrix.python-version }}
pull_request:
name: Merge all branches and open PR
runs-on: ubuntu-latest
needs: upgrade
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: detect auto-upgrade-dependency branches
id: changes
run: echo "count=$(git branch -r | grep auto-dependency-upgrades- | wc -l | xargs)" >> $GITHUB_OUTPUT
- name: merge all auto-dependency-upgrades branches
if: steps.changes.outputs.count > 0
run: |
git config user.name github-actions
git config user.email [email protected]
git checkout -b auto-dependency-upgrades
git branch -r | grep auto-dependency-upgrades- | xargs -I {} git merge {}
git rebase ${GITHUB_REF##*/}
git push -f origin auto-dependency-upgrades
git branch -r | grep auto-dependency-upgrades- | cut -d/ -f2 | xargs -I {} git push origin :{}
- name: Open pull request if needed
if: steps.changes.outputs.count > 0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Only open a PR if the branch is not attached to an existing one
run: |
PR=$(gh pr list --head auto-dependency-upgrades --json number -q '.[0].number')
if [ -z $PR ]; then
gh pr create \
--head auto-dependency-upgrades \
--title "Automated dependency upgrades" \
--body "Full log: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
else
echo "Pull request already exists, won't create a new one."
fi
101 changes: 37 additions & 64 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,69 +1,42 @@
exclude: '^docs/conf.py'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
exclude_types: [tsv]
- id: check-added-large-files
- id: check-ast
- id: check-json
- id: check-merge-conflict
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: mixed-line-ending
args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows

## If you want to avoid flake8 errors due to unused vars or imports:
# - repo: https://github.com/myint/autoflake
# rev: v1.4
# hooks:
# - id: autoflake
# args: [
# --in-place,
# --remove-all-unused-imports,
# --remove-unused-variables,
# ]

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
default_stages: [commit]

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
language_version: python3
default_install_hook_types: [pre-commit, commit-msg]

## If like to embrace black styles even in the docs:
# - repo: https://github.com/asottile/blacken-docs
# rev: v1.12.0
# hooks:
# - id: blacken-docs
# additional_dependencies: [black]
ci:
autoupdate_schedule: monthly
# skip: [mypy]
autofix_commit_msg: pre-commit auto-fixes
autoupdate_commit_msg: pre-commit autoupdate

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
## You can add flake8 plugins via `additional_dependencies`:
# additional_dependencies: [flake8-bugbear]

ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: []
submodules: false
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.280
hooks:
- id: ruff
args: [--fix, --ignore, "D,E501"]

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

- 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/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-case-conflict
- id: check-symlinks
- id: destroyed-symlinks
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
exclude: ".tsv"
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- Add more comprehensive platform testing via `tox`
- Replace `water_properties.py` with [iapws](https://github.com/jjgomera/iapws) package
- Replace elements.py with `pymatgen.core.periodic_table`
- Add `pymatgen` as a depedency
- Add `pymatgen` as a dependency
- Migrate all tests to `pytest`
- Add pre-commit configuration and lint with `black`
- Update packaging to use [pyscaffold](https://pyscaffold.org/en/stable/index.html)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pyEQL is a Python library that provides tools for modeling aqueous electrolyte
solutions. It allows the user to manipulate solutions as Python
objects, providing methods to populate them with solutes, calculate
species-specific properties (such as activity and diffusion coefficients),
and retreive bulk properties (such as density, conductivity, or volume).
and retrieve bulk properties (such as density, conductivity, or volume).

![pyeql demo](pyeql-demo.png)

Expand Down
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# serve to show the default.

import os
import sys
import shutil
import sys

# -- Path setup --------------------------------------------------------------

Expand Down Expand Up @@ -52,7 +52,7 @@

apidoc.main(args)
except Exception as e:
print("Running `sphinx-apidoc` failed!\n{}".format(e))
print(f"Running `sphinx-apidoc` failed!\n{e}")

# -- General configuration ---------------------------------------------------

Expand Down Expand Up @@ -114,7 +114,7 @@
#
# version: The short X.Y version.
# release: The full version, including alpha/beta/rc tags.
# If you dont need the separation provided between version and release,
# If you don`t need the separation provided between version and release,
# just set them both to the same value.
try:
from pyEQL import __version__ as version
Expand Down Expand Up @@ -301,4 +301,4 @@
"pyscaffold": ("https://pyscaffold.org/en/stable", None),
}

print(f"loading configurations for {project} {version} ...", file=sys.stderr)
print(f"loading configurations for {project} {version} ...", file=sys.stderr)
2 changes: 1 addition & 1 deletion docs/database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ following parameters for some common electrolytes:
Basics
======

The Paramsdb class creates a container for parameters. Each paramter
The Paramsdb class creates a container for parameters. Each parameter
is an object which contains not only the value, but also information about
the units, the reference, and the conditions of measurement. paramsdb() also
defines several methods that are helpful for retrieving parameters.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Add a short description here!

> This is the main page of your project's [Sphinx] documentation. It is
> formatted in [Markdown]. Add additional pages by creating md-files in
> `docs` or rst-files (formated in [reStructuredText]) and adding links to
> `docs` or rst-files (formatted in [reStructuredText]) and adding links to
> them in the `Contents` section below.
>
> Please check [Sphinx], [recommonmark] and [autostructify] for more information
Expand Down
Loading

0 comments on commit 781ad4a

Please sign in to comment.