Skip to content

Commit

Permalink
Rename .drone.yml to .woodpecker.yaml (#227)
Browse files Browse the repository at this point in the history
* Rename .drone.yml to .woodpecker.yaml

* woodpecker-ci requires 'steps:'

* fix spelling

* try artifacts

* tweak artifacts server

* tweak ftp upload

* re-enable cache

* reorg ci files

* typo

* typo2

* single ci file

* CI_COMMIT_BRANCH

* typo

* fix linting complaints

* Add setuptools to github-actions CI job
  • Loading branch information
bjodah committed Apr 15, 2024
1 parent 1f0460e commit ebbcb8e
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 62 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/lint_python.yml
@@ -0,0 +1,29 @@
name: lint_python
on: [pull_request, push]
jobs:
lint_python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- run: pip install --upgrade pip wheel
- run: pip install bandit "black[jupyter]" codespell flake8 flake8-2020
isort mypy pytest pyupgrade
- run: bandit --recursive --skip B101,B102,B110,B112,B307,B404,B603,B607 .
- run: black --check . || true
- run: codespell --ignore-words-list="ans,claus,fith,nam,nd,ond,serie,te"
- run: flake8 . --count --max-complexity=66 --max-line-length=118
--show-source --statistics
- run: pip install flake8-bugbear flake8-comprehensions flake8-return flake8-simplify
- run: flake8 . --count --exit-zero --max-complexity=66 --max-line-length=118
--show-source --statistics
- run: isort --check-only --profile black . || true
- run: pip install setuptools
- run: pip install --editable . || pip install .
- run: mkdir --parents --verbose .mypy_cache
- run: mypy --ignore-missing-imports --install-types --non-interactive . || true
- run: pytest .
- run: pytest --doctest-modules .
- run: shopt -s globstar && pyupgrade --py37-plus **/*.py || true
115 changes: 58 additions & 57 deletions .drone.yml → .woodpecker.yaml
@@ -1,17 +1,19 @@
pipeline:
restore-cache:
image: drillster/drone-volume-cache
restore: true
mount:
- ./cache-ci/pyusrb
- ./cache-ci/conda_packages
- ./cache-ci/pip_cache
volumes:
- /tmp/cache:/cache
ttl: 90 # liftetime in days
when:
- event: [pull_request, tag, cron, push]

install:
image: bjodah/bjodahimg20dot:21.7.c
steps:

- name: restore-cache
image: bjodah/bjodahimg20dot:21.8.a
commands:
- curl ftp://chempy:$${ARTIFACTS_PASS}@$${FTP_SERVER}/cache/cache-ci.tar | tar x
secrets: [ ARTIFACTS_PASS, FTP_SERVER ]
when:
- event: push
repo: bjodah/chempy

- name: install
image: bjodah/bjodahimg20dot:21.8.a
environment:
- CC=gcc-11
- CXX=g++-11
Expand All @@ -30,12 +32,11 @@ pipeline:
- git fetch -tq
- python3 setup.py sdist # test pip installable sdist (checks MANIFEST.in)
- git archive -o dist/chempy-head.zip HEAD # test pip installable zip (symlinks break)
- mkdir -p deploy/public_html/branches/${DRONE_BRANCH}
- cp dist/chempy-* deploy/public_html/branches/${DRONE_BRANCH}/
- mkdir -p deploy/public_html/branches/${CI_COMMIT_BRANCH}
- cp dist/chempy-* deploy/public_html/branches/${CI_COMMIT_BRANCH}/

test-suite:
image: bjodah/bjodahimg20dot:21.7.c
group: testing
- name: test-suite
image: bjodah/bjodahimg20dot:21.8.a
environment:
- CC=gcc-11
- CXX=g++-11
Expand All @@ -52,19 +53,20 @@ pipeline:
- bash -c '[[ $(python3 setup.py --version) =~ ^[0-9]+.* ]]'
- ./scripts/run_tests.sh --cov chempy --cov-report html
- ./scripts/coverage_badge.py htmlcov/ htmlcov/coverage.svg
- cp -r htmlcov/ deploy/public_html/branches/${DRONE_BRANCH}/
- cp -r htmlcov/ deploy/public_html/branches/${CI_COMMIT_BRANCH}/
- ./.ci/grep-for-merge-blocking-token.sh
- export CHEMPY_DEPRECATION_FILTER=ignore
- python3 -m virtualenv /tmp/test_sdist
- python3 -m virtualenv /tmp/test_git_archive
- cd deploy/public_html/branches/${DRONE_BRANCH}
- cd deploy/public_html/branches/${CI_COMMIT_BRANCH}
- unset CHEMPY_SKIP_NO_TESTS # I can't get pip to install extras when using local file...
- bash -c "source /tmp/test_sdist/bin/activate; pip install --cache-dir $CACHE_ROOT/pip_cache file://$(realpath $(eval ls chempy-*.tar.gz))#chempy[all] pytest; pytest --pyargs chempy"
- bash -c "source /tmp/test_git_archive/bin/activate; pip install --cache-dir $CACHE_ROOT/pip_cache file://$(realpath chempy-head.zip)#chempy[all] pytest; pytest --pyargs chempy"
depends_on:
- install

render-notebooks:
image: bjodah/bjodahimg20dot:21.7.c
group: testing
- name: render-notebooks
image: bjodah/bjodahimg20dot:21.8.a
environment:
- CHEMPY_DEPRECATION_FILTER=ignore
- SUNDBASE=/opt/sundials-5.7.0-release
Expand All @@ -79,21 +81,12 @@ pipeline:
- ./scripts/render_notebooks.sh
- ./.ci/grep-for-binary-data.sh
- mv index.html index.ipynb.html
# - (cd examples/; for f in bokeh_*.py; do python3 -m bokeh html $f; done)
- cp -r index.* examples/ "deploy/public_html/branches/${DRONE_BRANCH}"

# conda-recipe:
# image: bjodah/bjodahimg20dot:21.7.c
# group: testing
# commands:
# - export CONDA_PKGS_DIRS=$(pwd)/cache-ci/conda_packages
# - git fetch -tq
# - PATH=/opt/miniconda3/bin:$PATH conda config --add channels bjodah # sym, pyodesys, pyneqsys
# - PATH=/opt/miniconda3/bin:$PATH conda build --output-folder "deploy/public_html/branches/${DRONE_BRANCH}" conda-recipe
# - (cd $CONDA_PKGS_DIRS; find . -maxdepth 1 -type d -not -path . -not -path .. | xargs rm -r)
- cp -r index.* examples/ "deploy/public_html/branches/${CI_COMMIT_BRANCH}"
depends_on:
- install

compile-documentation:
image: bjodah/bjodahimg20dot:21.7.c
- name: compile-documentation
image: bjodah/bjodahimg20dot:21.8.a
environment:
- CHEMPY_DEPRECATION_FILTER=ignore
- SUNDBASE=/opt/sundials-5.7.0-release
Expand All @@ -104,26 +97,34 @@ pipeline:
- export LD_LIBRARY_PATH=$SUNDBASE/lib
- ./scripts/generate_docs.sh
- cp LICENSE doc/_build/html/
- cp -r doc/_build/html/ deploy/public_html/branches/${DRONE_BRANCH}
- cp -r doc/_build/html/ deploy/public_html/branches/${CI_COMMIT_BRANCH}
depends_on:
- test-suite
- render-notebooks

rebuild-cache:
image: drillster/drone-volume-cache
rebuild: true
mount:
# - ./cache-ci/sund-3.2.1
- ./cache-ci/pyusrb
- ./cache-ci/conda_packages
- ./cache-ci/pip_cache
volumes:
- /tmp/cache:/cache
- name: rebuild-cache
image: bjodah/bjodahimg20dot:21.8.a
commands:
- find ./cache-ci/ -type f -mtime +90 -exec rm {} \;
- tar cf cache-ci.tar ./cache-ci/
- curl -T cache-ci.tar ftp://chempy:$${ARTIFACTS_PASS}@$${FTP_SERVER}/cache/
secrets: [ ARTIFACTS_PASS, FTP_SERVER ]
when:
- event: push
repo: bjodah/chempy
depends_on:
- compile-documentation

deploy:
image: drillster/drone-rsync
- name: deploy-public-html
image: bjodah/bjodahimg20dot:21.8.a
commands:
- tar czf chempy-${CI_COMMIT_BRANCH}.tar.gz ./deploy/public_html
- curl -T chempy-${CI_COMMIT_BRANCH}.tar.gz ftp://chempy:$${ARTIFACTS_PASS}@$${FTP_SERVER}/public_html/
secrets: [ ARTIFACTS_PASS, FTP_SERVER ]
when:
event: [push]
hosts: [ "hera.physchem.kth.se" ]
port: 22
user: chempy
secrets: [ rsync_key ] # secret only set fro event "push" not "pull_request"
source: ./deploy/public_html
target: ~/
- event: push
repo: bjodah/chempy
depends_on:
- compile-documentation


12 changes: 8 additions & 4 deletions chempy/chemistry.py
Expand Up @@ -426,7 +426,8 @@ def _init_stoich(container):
if isinstance(container, set):
container = {k: 1 for k in container}
container = container or {}
if type(container) == dict: # we don't want isinstance here in case of OrderedDict
if type(container) == dict: # noqa
# we don't want isinstance here in case of OrderedDict
container = OrderedDict(sorted(container.items(), key=lambda kv: kv[0]))
return container

Expand Down Expand Up @@ -1275,10 +1276,13 @@ def balance_stoichiometry(reactants, products, substances=None,
if substances is None:
substances = OrderedDict([(k, substance_factory(k)) for k in chain(reactants, products)])
if isinstance(substances, str):
substances = OrderedDict([(k, substance_factory(k)) for k in substances.split()])
if type(reactants) == set: # we don't want isinstance since it might be "OrderedSet"
substances = OrderedDict(
[(k, substance_factory(k)) for k in substances.split()]
)
if type(reactants) == set: # noqa
# we don't want isinstance since it might be "OrderedSet"
reactants = sorted(reactants)
if type(products) == set:
if type(products) == set: # noqa
products = sorted(products)
subst_keys = list(reactants) + list(products)

Expand Down
2 changes: 1 addition & 1 deletion examples/protein_binding_unfolding_4state_model.ipynb
Expand Up @@ -209,7 +209,7 @@
"source": [
"Try hovering over the names to have them highlighted (this is particularly useful when working with large reaction sets).\n",
"\n",
"We ca also generate tables representing the unimolecular reactions involing each substance, or the matrix showing the bimolecular reactions:"
"We ca also generate tables representing the unimolecular reactions involving each substance, or the matrix showing the bimolecular reactions:"
]
},
{
Expand Down

0 comments on commit ebbcb8e

Please sign in to comment.