Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#333)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 23.12.1 → 24.3.0](psf/black@23.12.1...24.3.0)
- [github.com/PyCQA/flake8: 6.1.0 → 7.0.0](PyCQA/flake8@6.1.0...7.0.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Apr 3, 2024
1 parent 139a7db commit 8cb29f4
Show file tree
Hide file tree
Showing 21 changed files with 122 additions and 87 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- id: check-yaml
- id: debug-statements
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.3.0
hooks:
- id: black
files: ^openff
Expand All @@ -17,7 +17,7 @@ repos:
- id: isort
files: ^openff
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
files: ^openff
1 change: 1 addition & 0 deletions openff/bespokefit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
BespokeFit: Creating bespoke parameters for individual molecules.
"""

import logging
import sys

Expand Down
1 change: 1 addition & 0 deletions openff/bespokefit/_pydantic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A set of common utilities and types useful for building pydantic models."""

import numpy

try:
Expand Down
16 changes: 9 additions & 7 deletions openff/bespokefit/cli/executor/retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ def retrieve_cli(optimization_id, output_file_path, force_field_path):
if force_field_path is not None:
message = Padding(
(
f"the bespoke fit {'failed' if results.error else 'is still running'} "
f"and so no force field will be saved"
)
if not results.bespoke_force_field
else (
f"the bespoke force field has been saved to "
f"[repr.filename]{force_field_path}[/repr.filename]"
(
f"the bespoke fit {'failed' if results.error else 'is still running'} "
f"and so no force field will be saved"
)
if not results.bespoke_force_field
else (
f"the bespoke force field has been saved to "
f"[repr.filename]{force_field_path}[/repr.filename]"
)
),
(1, 0, 1, 0),
)
Expand Down
12 changes: 6 additions & 6 deletions openff/bespokefit/cli/executor/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ def _run_cli(
with handle_common_errors(console) as error_state:
response_id = _submit(
console=console,
input_file_path=[input_file_path]
if input_file_path is not None
else [],
molecule_smiles=[molecule_smiles]
if molecule_smiles is not None
else [],
input_file_path=(
[input_file_path] if input_file_path is not None else []
),
molecule_smiles=(
[molecule_smiles] if molecule_smiles is not None else []
),
force_field_path=force_field_path,
target_torsion_smirks=target_torsion_smirks,
default_qc_spec=default_qc_spec,
Expand Down
36 changes: 20 additions & 16 deletions openff/bespokefit/executor/services/coordinator/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,27 @@ def get_optimizations(
f"&limit={limit}"
f"{status_url}"
),
prev=None
if prev_index >= skip
else (
f"{__settings.BEFLOW_API_V1_STR}/"
f"{__settings.BEFLOW_COORDINATOR_PREFIX}"
f"?skip={prev_index}"
f"&limit={limit}"
f"{status_url}"
prev=(
None
if prev_index >= skip
else (
f"{__settings.BEFLOW_API_V1_STR}/"
f"{__settings.BEFLOW_COORDINATOR_PREFIX}"
f"?skip={prev_index}"
f"&limit={limit}"
f"{status_url}"
)
),
next=None
if (next_index <= skip or next_index == n_total_tasks)
else (
f"{__settings.BEFLOW_API_V1_STR}/"
f"{__settings.BEFLOW_COORDINATOR_PREFIX}"
f"?skip={next_index}"
f"&limit={limit}"
f"{status_url}"
next=(
None
if (next_index <= skip or next_index == n_total_tasks)
else (
f"{__settings.BEFLOW_API_V1_STR}/"
f"{__settings.BEFLOW_COORDINATOR_PREFIX}"
f"?skip={next_index}"
f"&limit={limit}"
f"{status_url}"
)
),
contents=contents,
)
Expand Down
14 changes: 8 additions & 6 deletions openff/bespokefit/executor/services/coordinator/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ def from_stage(cls, stage: StageType):
type=stage.type,
status=stage.status,
error=stage.error,
results=None
if stage_ids is None
else [
Link(id=stage_id, self=f"{endpoints[stage.type]}{stage_id}")
for stage_id in stage_ids
],
results=(
None
if stage_ids is None
else [
Link(id=stage_id, self=f"{endpoints[stage.type]}{stage_id}")
for stage_id in stage_ids
]
),
)


Expand Down
1 change: 1 addition & 0 deletions openff/bespokefit/fragmentation/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Register new fragmentation methods with bespokefit
"""

from typing import Dict, List, Type, Union

from openff.fragmenter.fragment import Fragmenter, PfizerFragmenter, WBOFragmenter
Expand Down
1 change: 1 addition & 0 deletions openff/bespokefit/optimizers/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Here we register all optimizers with bespokefit.
"""

from typing import Dict, List, Type, Union

from openff.bespokefit.exceptions import OptimizerError
Expand Down
10 changes: 6 additions & 4 deletions openff/bespokefit/optimizers/forcebalance/forcebalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ def _collect_results(cls, root_directory: str) -> OptimizationStageResults:
provenance=cls.provenance(),
status=results_dictionary["status"],
error=results_dictionary["error"],
refit_force_field=None
if results_dictionary["error"] is not None
else force_field_editor.force_field.to_string(
discard_cosmetic_attributes=True
refit_force_field=(
None
if results_dictionary["error"] is not None
else force_field_editor.force_field.to_string(
discard_cosmetic_attributes=True
)
),
)

Expand Down
9 changes: 3 additions & 6 deletions openff/bespokefit/schema/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,19 @@ def _torsion_drive_record_to_torsion_drive_result(
@overload
def from_remote_records(
cls, qc_records: List[Tuple[TorsiondriveRecord, Molecule]]
) -> "LocalQCData[TorsionDriveResult]":
...
) -> "LocalQCData[TorsionDriveResult]": ...

@classmethod
@overload
def from_remote_records(
cls, qc_records: List[Tuple[OptimizationRecord, Molecule]]
) -> "LocalQCData[OptimizationResult]":
...
) -> "LocalQCData[OptimizationResult]": ...

@classmethod
@overload
def from_remote_records(
cls, qc_records: List[Tuple[BaseRecord, Molecule]]
) -> "LocalQCData[AtomicResult]":
...
) -> "LocalQCData[AtomicResult]": ...

@classmethod
def from_remote_records(cls, qc_records):
Expand Down
9 changes: 3 additions & 6 deletions openff/bespokefit/schema/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,15 @@ class Torsion1DTask(Torsion1DTaskSpec):


@overload
def task_from_result(result: AtomicResult) -> HessianTask:
...
def task_from_result(result: AtomicResult) -> HessianTask: ...


@overload
def task_from_result(result: OptimizationResult) -> OptimizationTask:
...
def task_from_result(result: OptimizationResult) -> OptimizationTask: ...


@overload
def task_from_result(result: TorsionDriveResult) -> Torsion1DTask:
...
def task_from_result(result: TorsionDriveResult) -> Torsion1DTask: ...


def task_from_result(result):
Expand Down
1 change: 1 addition & 0 deletions openff/bespokefit/tests/fragmentation/test_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test the fragmentation engine registration system."""

import abc

import pytest
Expand Down
1 change: 1 addition & 0 deletions openff/bespokefit/tests/optimizers/test_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Unit test ability to add and remove new optimizers as well as the various optimizer classes.
"""

import pytest
from openff.toolkit.typing.engines.smirnoff import ForceField

Expand Down
1 change: 1 addition & 0 deletions openff/bespokefit/tests/utilities/test_smirnoff.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test the force field editing tools.
"""

import copy
import os

Expand Down
1 change: 1 addition & 0 deletions openff/bespokefit/tests/workflows/test_bespoke.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test for the bespoke-fit workflow generator.
"""

import os

import pytest
Expand Down
48 changes: 30 additions & 18 deletions openff/bespokefit/utilities/_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,36 +83,48 @@ class Settings(BaseSettings):
def fragmenter_settings(self) -> WorkerSettings:
return WorkerSettings(
import_path=self.BEFLOW_FRAGMENTER_WORKER,
n_cores=None
if self.BEFLOW_FRAGMENTER_WORKER_N_CORES == "auto"
else self.BEFLOW_FRAGMENTER_WORKER_N_CORES,
max_memory=None
if self.BEFLOW_FRAGMENTER_WORKER_MAX_MEM == "auto"
else self.BEFLOW_FRAGMENTER_WORKER_MAX_MEM,
n_cores=(
None
if self.BEFLOW_FRAGMENTER_WORKER_N_CORES == "auto"
else self.BEFLOW_FRAGMENTER_WORKER_N_CORES
),
max_memory=(
None
if self.BEFLOW_FRAGMENTER_WORKER_MAX_MEM == "auto"
else self.BEFLOW_FRAGMENTER_WORKER_MAX_MEM
),
)

@property
def qc_compute_settings(self) -> WorkerSettings:
return WorkerSettings(
import_path=self.BEFLOW_QC_COMPUTE_WORKER,
n_cores=None
if self.BEFLOW_QC_COMPUTE_WORKER_N_CORES == "auto"
else self.BEFLOW_QC_COMPUTE_WORKER_N_CORES,
max_memory=None
if self.BEFLOW_QC_COMPUTE_WORKER_MAX_MEM == "auto"
else self.BEFLOW_QC_COMPUTE_WORKER_MAX_MEM,
n_cores=(
None
if self.BEFLOW_QC_COMPUTE_WORKER_N_CORES == "auto"
else self.BEFLOW_QC_COMPUTE_WORKER_N_CORES
),
max_memory=(
None
if self.BEFLOW_QC_COMPUTE_WORKER_MAX_MEM == "auto"
else self.BEFLOW_QC_COMPUTE_WORKER_MAX_MEM
),
)

@property
def optimizer_settings(self) -> WorkerSettings:
return WorkerSettings(
import_path=self.BEFLOW_OPTIMIZER_WORKER,
n_cores=None
if self.BEFLOW_OPTIMIZER_WORKER_N_CORES == "auto"
else self.BEFLOW_OPTIMIZER_WORKER_N_CORES,
max_memory=None
if self.BEFLOW_OPTIMIZER_WORKER_MAX_MEM == "auto"
else self.BEFLOW_OPTIMIZER_WORKER_MAX_MEM,
n_cores=(
None
if self.BEFLOW_OPTIMIZER_WORKER_N_CORES == "auto"
else self.BEFLOW_OPTIMIZER_WORKER_N_CORES
),
max_memory=(
None
if self.BEFLOW_OPTIMIZER_WORKER_MAX_MEM == "auto"
else self.BEFLOW_OPTIMIZER_WORKER_MAX_MEM
),
)

@contextmanager
Expand Down
32 changes: 19 additions & 13 deletions openff/bespokefit/utilities/smirks.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,11 @@ def generate_smirks_from_molecule(
return self.generate_smirks_from_fragment(
molecule,
molecule,
None
if central_bond is None
else (central_bond[0] + 1, central_bond[1] + 1),
(
None
if central_bond is None
else (central_bond[0] + 1, central_bond[1] + 1)
),
)

def generate_smirks_from_fragment(
Expand Down Expand Up @@ -323,11 +325,13 @@ def _get_existing_parameters(
for valence_term in self._get_valence_terms(
molecule=molecule,
smirks_type=smirks_type,
torsion_bond=None
if molecule_map_indices is None
else (
get_atom_index(molecule, molecule_map_indices[0]),
get_atom_index(molecule, molecule_map_indices[1]),
torsion_bond=(
None
if molecule_map_indices is None
else (
get_atom_index(molecule, molecule_map_indices[0]),
get_atom_index(molecule, molecule_map_indices[1]),
)
),
):
requested_smirks.setdefault(smirks_type, []).append(valence_term)
Expand Down Expand Up @@ -390,11 +394,13 @@ def _get_bespoke_smirks(
valence_terms = self._get_valence_terms(
fragment,
smirks_type,
None
if fragment_map_indices is None
else (
get_atom_index(fragment, fragment_map_indices[0]),
get_atom_index(fragment, fragment_map_indices[1]),
(
None
if fragment_map_indices is None
else (
get_atom_index(fragment, fragment_map_indices[0]),
get_atom_index(fragment, fragment_map_indices[1]),
)
),
)
valence_groups = [*group_valence_by_symmetry(fragment, valence_terms).values()]
Expand Down
1 change: 1 addition & 0 deletions openff/bespokefit/utilities/smirnoff.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tools for dealing with SMIRNOFF force field manipulation.
"""

import copy
from enum import Enum
from typing import TYPE_CHECKING, Dict, List, Tuple, Union
Expand Down
1 change: 1 addition & 0 deletions openff/bespokefit/utilities/tempcd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""""""

import os
import shutil
import tempfile
Expand Down
Loading

0 comments on commit 8cb29f4

Please sign in to comment.