Skip to content

Defer/fix some minor import issues #4517

Defer/fix some minor import issues

Defer/fix some minor import issues #4517

Workflow file for this run

name: Examples
on:
push:
branches:
- "main"
- "maintenance/.+"
pull_request:
branches:
- "main"
- "maintenance/.+"
schedule:
- cron: "0 0 * * *"
defaults:
run:
shell: bash -l {0}
jobs:
test:
if: (github.event_name == 'schedule' && github.repository == 'openforcefield/openff-toolkit') || (github.event_name != 'schedule')
name: ${{ matrix.os }}, Python ${{ matrix.python-version }}, RDKit=${{ matrix.rdkit }}, OpenEye=${{ matrix.openeye }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-12]
python-version: ["3.10"]
rdkit: [true, false]
openeye: [true, false]
exclude:
- rdkit: false
openeye: false
- rdkit: true
openeye: true
env:
OE_LICENSE: ${{ github.workspace }}/oe_license.txt
PACKAGE: openff
PYTEST_ARGS: -r fE -v -x --tb=short -nauto
NB_ARGS: --nbval-lax --dist loadscope --ignore=examples/deprecated
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set environment variables
run: |
if [[ ${{ matrix.openeye }} == true && ${{ matrix.rdkit }} == false ]]; then
echo "ENVFILE=openeye" >> $GITHUB_ENV
echo "TOOLKIT_CHECKS=OPENEYE" >> $GITHUB_ENV
echo "PACKAGES_TO_REMOVE=ambertools rdkit" >> $GITHUB_ENV
fi
if [[ ${{ matrix.openeye }} == false && ${{ matrix.rdkit }} == true ]]; then
echo "ENVFILE=rdkit" >> $GITHUB_ENV
echo "TOOLKIT_CHECKS=RDKIT" >> $GITHUB_ENV
echo "PACKAGES_TO_REMOVE=openeye-toolkits" >> $GITHUB_ENV
fi
- name: Install conda environment with ${{ env.ENVFILE }}
uses: mamba-org/setup-micromamba@v1
with:
environment-file: devtools/conda-envs/${{env.ENVFILE}}-examples.yaml
create-args: >-
python=${{ matrix.python-version }}
# default - will pull down 2.0 which we don't want!
# micromamba-version: latest
# pin to latest 1.x release
micromamba-version: "1.5.10-0"
- name: Additional info about the build
run: |
uname -a
df -h
ulimit -a
- name: Make oe_license.txt file from GH org secret "OE_LICENSE"
env:
OE_LICENSE_TEXT: ${{ secrets.OE_LICENSE }}
run: |
echo "${OE_LICENSE_TEXT}" > ${OE_LICENSE}
- name: Install package
run: |
# Maybe remove the packaged openff-toolkit, installed as a dependency of openmmforcefields
# and/or Interchange
micromamba remove --force openff-toolkit-base
python -m pip install .
- name: Remove undesired toolkits
run: |
# If openmmforcefields is included in either environment file,
# remove RDKit and AmberTools brought in by it. Currently it's not included,
# so don't remove it.
if [ ! -z "${{ env.PACKAGES_TO_REMOVE }}" ]; then
for cpkg in ${{ env.PACKAGES_TO_REMOVE }}; do
if [[ $(conda list | grep $cpkg) ]]; then micromamba remove --force $cpkg --yes ; fi
done
fi
- name: Reinstall ParmEd
if: ${{ matrix.rdkit == false }}
run: |
micromamba remove --force parmed --yes
# See #1531, #1532, eventually this should work with 4 or 3 and 4
micromamba install "parmed =3" -c conda-forge -yq
# Needed for other examples to run, but were removed incidentally alongside AmberTools
micromamba install h5py -c conda-forge -yq
- name: Check installed toolkits
run: |
for tk in ${{ env.TOOLKIT_CHECKS }}; do
python -c "from openff.toolkit.utils.toolkits import ${tk}_AVAILABLE; assert ${tk}_AVAILABLE, '${tk} unavailable'"
done
- name: Check uninstalled toolkits
run: |
if [ ! -z "${{ env.PACKAGES_TO_REMOVE }}" ]; then
for tk in ${{ env.PACKAGES_TO_REMOVE }}; do
TK=$(echo ${tk%-*} | tr 'a-z' 'A-Z')
python -c "from openff.toolkit.utils.toolkits import ${TK}_AVAILABLE; assert not ${TK}_AVAILABLE, '${TK} available'"
done
fi
- name: Environment Information
run: |
conda info
conda list
- name: Run example scripts
run: |
if [[ ${{ matrix.rdkit }} == false ]]; then
PYTEST_ARGS+=" --ignore=examples/check_dataset_parameter_coverage"
PYTEST_ARGS+=" --ignore=examples/QCArchive_interface"
fi
pytest $PYTEST_ARGS openff/toolkit/_tests/test_examples.py
- name: Run example notebooks
run: |
if [[ ${{ matrix.rdkit }} == false ]]; then
NB_ARGS+=" --ignore=examples/QCArchive_interface"
NB_ARGS+=" --ignore=examples/visualization"
NB_ARGS+=" --ignore=examples/check_dataset_parameter_coverage"
NB_ARGS+=" --ignore=examples/conformer_energies"
NB_ARGS+=" --ignore=examples/using_smirnoff_in_amber_or_gromacs"
NB_ARGS+=" --ignore=examples/using_smirnoff_with_amber_protein_forcefield"
NB_ARGS+=" --ignore=examples/SMIRNOFF_simulation"
NB_ARGS+=" --ignore=examples/toolkit_showcase"
fi
# GROMACS builds are not stable on macOS + GHA
if [[ ${{ matrix.os }} == macos-latest ]]; then
NB_ARGS+=" --ignore=examples/using_smirnoff_in_amber_or_gromacs/"
fi
python -m pytest $PYTEST_ARGS $NB_ARGS examples