diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml index 0351167b..33a3b75c 100644 --- a/.github/workflows/lint_python.yml +++ b/.github/workflows/lint_python.yml @@ -20,6 +20,7 @@ jobs: - 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 diff --git a/.drone.yml b/.woodpecker.yaml similarity index 64% rename from .drone.yml rename to .woodpecker.yaml index 509bc2f0..3aca31ce 100644 --- a/.drone.yml +++ b/.woodpecker.yaml @@ -1,16 +1,18 @@ -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: +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 @@ -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: + - name: test-suite image: bjodah/bjodahimg20dot:21.8.a - group: testing environment: - CC=gcc-11 - CXX=g++-11 @@ -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: + - name: render-notebooks image: bjodah/bjodahimg20dot:21.8.a - group: testing environment: - CHEMPY_DEPRECATION_FILTER=ignore - SUNDBASE=/opt/sundials-5.7.0-release @@ -79,20 +81,11 @@ 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.8.a -# 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: + - name: compile-documentation image: bjodah/bjodahimg20dot:21.8.a environment: - CHEMPY_DEPRECATION_FILTER=ignore @@ -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 + + diff --git a/chempy/chemistry.py b/chempy/chemistry.py index e225dc7f..4b310912 100644 --- a/chempy/chemistry.py +++ b/chempy/chemistry.py @@ -456,9 +456,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 @@ -1456,11 +1455,10 @@ def balance_stoichiometry( 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" + 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) diff --git a/examples/protein_binding_unfolding_4state_model.ipynb b/examples/protein_binding_unfolding_4state_model.ipynb index f462fda6..edf8c003 100644 --- a/examples/protein_binding_unfolding_4state_model.ipynb +++ b/examples/protein_binding_unfolding_4state_model.ipynb @@ -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:" ] }, {