Skip to content

Commit

Permalink
Re-lint after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwthompson committed Oct 19, 2023
1 parent 3e539fe commit 5dad7ed
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ repos:
rev: v3.1.0
hooks:
- id: add-trailing-comma
args: ["--py36-plus"]
- repo: https://github.com/psf/black
rev: 23.10.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion openff/bespokefit/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import re
import subprocess
import sys
from typing import Any, Callable, Dict, List, Optional, Tuple
from typing import Any, Callable, Optional


def get_keywords() -> dict[str, str]:
Expand Down
10 changes: 6 additions & 4 deletions openff/bespokefit/cli/worker.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Host of `launch-worker` CLI command."""
import importlib

import click
Expand Down Expand Up @@ -25,16 +26,17 @@ def worker_cli(worker_type: str):
Used to connect workers to a remote bespokefit server.
Note:
----
By default bespokefit will automatically use all cores and memory made available to the worker which should
be declared in the job submission script. To change these defaults see the settings `BEFLOW_QC_COMPUTE_WORKER_N_CORES` &
`BEFLOW_QC_COMPUTE_WORKER_MAX_MEM`.
Args:
Parameters
----------
worker_type: str
The alias name of the worker type which should be started.
worker_type: The alias name of the worker type which should be started.
"""

pretty.install()

console = rich.get_console()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Generate QC data using QCEngine."""
from multiprocessing import Pool, current_process, get_context
from multiprocessing import current_process, get_context
from typing import Union

from qcelemental.models import FailedOperation
Expand Down
29 changes: 18 additions & 11 deletions openff/bespokefit/executor/utilities/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

__REDIS_VERSION: int = 1
__CONNECTION_POOL: dict[
tuple[str, int, Optional[int], Optional[str], bool], redis.Redis
tuple[str, int, Optional[int], Optional[str], bool],
redis.Redis,
] = {}


Expand Down Expand Up @@ -51,10 +52,13 @@ def connect_to_default_redis(validate: bool = True) -> redis.Redis:


def connect_to_redis(
host: str, port: int, db: int, validate: bool = True, password: Optional[str] = None
host: str,
port: int,
db: int,
validate: bool = True,
password: Optional[str] = None,
) -> redis.Redis:
"""Connects to a redis server using the specified settings."""

"""Connect to a redis server using the specified settings."""
connection_key = (host, port, db, password, validate)

if connection_key in __CONNECTION_POOL:
Expand Down Expand Up @@ -87,12 +91,11 @@ def connect_to_redis(


def is_redis_available(
host: str, port: int = 6363, password: Optional[str] = None
host: str,
port: int = 6363,
password: Optional[str] = None,
) -> bool:
"""Returns whether a server running on the local host on a particular port is
available.
"""

"""Return whether a server running on the local host on a particular port is available."""
redis_client = redis.Redis(host=host, port=port, password=password)

try:
Expand Down Expand Up @@ -135,7 +138,9 @@ def launch_redis(
)

if is_redis_available(
host="localhost", port=port, password=settings.BEFLOW_REDIS_PASSWORD
host="localhost",
port=port,
password=settings.BEFLOW_REDIS_PASSWORD,
):
raise RuntimeError(f"There is already a server running at localhost:{port}")

Expand Down Expand Up @@ -168,7 +173,9 @@ def launch_redis(

for i in range(0, 60):
if is_redis_available(
host="localhost", port=port, password=settings.BEFLOW_REDIS_PASSWORD
host="localhost",
port=port,
password=settings.BEFLOW_REDIS_PASSWORD,
):
timeout = False
break
Expand Down

0 comments on commit 5dad7ed

Please sign in to comment.