Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linting #723

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ We are happy to get you started in using our software.
## Issues

If you think you have encountered a software issue, please raise this on the "Issues" tab in Github.
In general the more details you can provide the better,
In general the more details you can provide the better,
we recommend reading section 3.3 of [this article](https://livecomsjournal.org/index.php/livecoms/article/view/v3i1e1473)
to understand the problem solving process.

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ jobs:
# we only want to upload a slow report if
# 1) it isn't a schedule run
# 2) it wasn't from a PR (we don't run slow tests on PRs)
if: ${{ github.repository == 'OpenFreeEnergy/openfe'
&& github.event_name != 'schedule'
&& github.event_name != 'pull_request' }}
if: ${{ github.repository == 'OpenFreeEnergy/openfe'
&& github.event_name != 'schedule'
&& github.event_name != 'pull_request' }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/clean_cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
micromamba list
- name: "Lint with mypy"
run: mypy
run: mypy
46 changes: 46 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
ci:
autoupdate_schedule: "quarterly"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-symlinks
- id: check-toml
- id: check-yaml
exclude: 'devtools/installer/construct\.yaml'
- id: debug-statements
- id: destroyed-symlinks
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: '\.(pdb|gro|top|sdf)$'
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/econchick/interrogate
rev: 1.5.0
hooks:
- id: interrogate
pass_filenames: false
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
- id: add-trailing-comma
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--py39-plus"]
exclude: '(openmm_utils/omm_settings\.py|openmm_afe/equil_afe_settings\.py|openmm_rfe/equil_rfe_settings\.py|openmm_afe/base\.py|openmm_afe/equil_solvation_afe_method\.py|openmm_md/plain_md_methods\.py|openmm_rfe/equil_rfe_methods\.py)'
2 changes: 1 addition & 1 deletion Code_of_Conduct.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Code of Conduct ##

This project is dedicated to providing a welcoming and supportive environment for all people, regardless of background or identity. Members do not tolerate harassment for any reason, but especially harassment based on gender, sexual orientation, disability, physical appearance, body size, race, nationality, sex, color, ethnic or social origin, pregnancy, citizenship, familial status, veteran status, genetic information, religion or belief, political or any other opinion, membership of a national minority, property, age, or preference of text editor.
This project is dedicated to providing a welcoming and supportive environment for all people, regardless of background or identity. Members do not tolerate harassment for any reason, but especially harassment based on gender, sexual orientation, disability, physical appearance, body size, race, nationality, sex, color, ethnic or social origin, pregnancy, citizenship, familial status, veteran status, genetic information, religion or belief, political or any other opinion, membership of a national minority, property, age, or preference of text editor.


### Expected Behavior ###
Expand Down
63 changes: 23 additions & 40 deletions devtools/data/gen-serialized-results.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,32 @@
- MDProtocol_json_results.gz
- used in md_json fixture
"""

import gzip
import json
import logging
import pathlib
import tempfile
from openff.toolkit import (
Molecule, RDKitToolkitWrapper, AmberToolsToolkitWrapper
)
from openff.toolkit.utils.toolkit_registry import (
toolkit_registry_manager, ToolkitRegistry
)
from openff.units import unit
from kartograf.atom_aligner import align_mol_shape
from kartograf import KartografAtomMapper

import gufe
from gufe.tokenization import JSON_HANDLER
from kartograf import KartografAtomMapper
from kartograf.atom_aligner import align_mol_shape
from openff.toolkit import AmberToolsToolkitWrapper, Molecule, RDKitToolkitWrapper
from openff.toolkit.utils.toolkit_registry import ToolkitRegistry, toolkit_registry_manager
from openff.units import unit

import openfe
from openfe.protocols.openmm_md.plain_md_methods import PlainMDProtocol
from openfe.protocols.openmm_afe import AbsoluteSolvationProtocol
from openfe.protocols.openmm_md.plain_md_methods import PlainMDProtocol
from openfe.protocols.openmm_rfe import RelativeHybridTopologyProtocol


logger = logging.getLogger(__name__)

LIGA = "[H]C([H])([H])C([H])([H])C(=O)C([H])([H])C([H])([H])[H]"
LIGB = "[H]C([H])([H])C(=O)C([H])([H])C([H])([H])C([H])([H])[H]"

amber_rdkit = ToolkitRegistry(
[RDKitToolkitWrapper(), AmberToolsToolkitWrapper()]
)
amber_rdkit = ToolkitRegistry([RDKitToolkitWrapper(), AmberToolsToolkitWrapper()])


def get_molecule(smi, name):
Expand All @@ -58,21 +54,18 @@ def execute_and_serialize(dag, protocol, simname):
shared_basedir=workdir,
scratch_basedir=workdir,
keep_shared=False,
n_retries=3
n_retries=3,
)
protres = protocol.gather([dagres])

outdict = {
"estimate": protres.get_estimate(),
"uncertainty": protres.get_uncertainty(),
"protocol_result": protres.to_dict(),
"unit_results": {
unit.key: unit.to_keyed_dict()
for unit in dagres.protocol_unit_results
}
"unit_results": {unit.key: unit.to_keyed_dict() for unit in dagres.protocol_unit_results},
}

with gzip.open(f"{simname}_json_results.gz", 'wt') as zipfile:
with gzip.open(f"{simname}_json_results.gz", "wt") as zipfile:
json.dump(outdict, zipfile, cls=JSON_HANDLER.encoder)


Expand All @@ -95,27 +88,19 @@ def generate_ahfe_json(smc):
settings.solvent_simulation_settings.production_length = 500 * unit.picosecond
settings.vacuum_simulation_settings.equilibration_length = 10 * unit.picosecond
settings.vacuum_simulation_settings.production_length = 1000 * unit.picosecond
settings.lambda_settings.lambda_elec = [0.0, 0.25, 0.5, 0.75, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0]
settings.lambda_settings.lambda_vdw = [0.0, 0.0, 0.0, 0.0, 0.0, 0.12, 0.24,
0.36, 0.48, 0.6, 0.7, 0.77, 0.85,
1.0]
settings.lambda_settings.lambda_elec = [0.0, 0.25, 0.5, 0.75, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
settings.lambda_settings.lambda_vdw = [0.0, 0.0, 0.0, 0.0, 0.0, 0.12, 0.24, 0.36, 0.48, 0.6, 0.7, 0.77, 0.85, 1.0]
settings.protocol_repeats = 3
settings.solvent_simulation_settings.n_replicas = 14
settings.vacuum_simulation_settings.n_replicas = 14
settings.solvent_simulation_settings.early_termination_target_error = 0.12 * unit.kilocalorie_per_mole
settings.vacuum_simulation_settings.early_termination_target_error = 0.12 * unit.kilocalorie_per_mole
settings.vacuum_engine_settings.compute_platform = 'CPU'
settings.solvent_engine_settings.compute_platform = 'CUDA'
settings.vacuum_engine_settings.compute_platform = "CPU"
settings.solvent_engine_settings.compute_platform = "CUDA"

protocol = AbsoluteSolvationProtocol(settings=settings)
sysA = openfe.ChemicalSystem(
{"ligand": smc, "solvent": openfe.SolventComponent()}
)
sysB = openfe.ChemicalSystem(
{"solvent": openfe.SolventComponent()}
)
sysA = openfe.ChemicalSystem({"ligand": smc, "solvent": openfe.SolventComponent()})
sysB = openfe.ChemicalSystem({"solvent": openfe.SolventComponent()})

dag = protocol.create(stateA=sysA, stateB=sysB, mapping=None)

Expand All @@ -133,15 +118,13 @@ def generate_rfe_json(smcA, smcB):
mapper = KartografAtomMapper(atom_map_hydrogens=True)
mapping = next(mapper.suggest_mappings(smcA, a_smcB))

systemA = openfe.ChemicalSystem({'ligand': smcA})
systemB = openfe.ChemicalSystem({'ligand': a_smcB})
systemA = openfe.ChemicalSystem({"ligand": smcA})
systemB = openfe.ChemicalSystem({"ligand": a_smcB})

dag = protocol.create(
stateA=systemA, stateB=systemB, mapping=mapping
)
dag = protocol.create(stateA=systemA, stateB=systemB, mapping=mapping)

execute_and_serialize(dag, protocol, "RHFEProtocol")


if __name__ == "__main__":
molA = get_molecule(LIGA, "ligandA")
Expand Down
7 changes: 1 addition & 6 deletions docs/_ext/sass.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
from pathlib import Path
from typing import Optional, Union


import sass
from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment
from sphinx.util import logging


logger = logging.getLogger(__name__)


Expand All @@ -44,10 +42,7 @@ def get_targets(app: Sphinx) -> dict[Path, Path]:
if isinstance(app.config.sass_targets, dict):
targets = app.config.sass_targets
else:
targets = {
path: path.relative_to(src_dir).with_suffix(".css")
for path in src_dir.glob("**/[!_]*.s[ca]ss")
}
targets = {path: path.relative_to(src_dir).with_suffix(".css") for path in src_dir.glob("**/[!_]*.s[ca]ss")}

return {src_dir / src: dst_dir / dst for src, dst in targets.items()}

Expand Down
4 changes: 2 additions & 2 deletions docs/_sass/deflist-flowchart.scss
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ ul.deflist-flowchart {
margin-left: 0;
}
}

dl {
display: flex;
flex-direction: row-reverse;
Expand Down Expand Up @@ -394,4 +394,4 @@ ul.deflist-flowchart {
}
}
}
}
}
2 changes: 1 addition & 1 deletion docs/_static/API.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_static/CLI.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_static/Cookbook.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading