Skip to content

Commit

Permalink
More renames
Browse files Browse the repository at this point in the history
  • Loading branch information
dotsdl committed Apr 8, 2022
1 parent ee76ec3 commit ce56294
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions openff/qcsubmit/results/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import numpy
from cachetools import Cache, LRUCache
from openff.toolkit.topology import Molecule
from qcportal import FractalClient
from qcportal import PortalClient
from qcportal.molecules import Molecule as QCMolecule
from qcportal.records import TorsiondriveRecord
from qcportal.records import OptimizationRecord, RecordBase, ResultRecord
from qcportal.records import OptimizationRecord, BaseRecord, SinglepointRecord

try:
from openmm import unit
Expand All @@ -27,10 +27,10 @@

R = TypeVar("R", bound=_BaseResult)

S = TypeVar("S", bound=RecordBase)
S = TypeVar("S", bound=BaseRecord)
T = TypeVar("T")

RecordAndMolecule = Tuple[RecordBase, Molecule]
RecordAndMolecule = Tuple[BaseRecord, Molecule]

_record_cache = LRUCache(maxsize=20000)

Expand Down Expand Up @@ -63,18 +63,18 @@ def batched_indices(indices: List[T], batch_size: int) -> List[List[T]]:


@lru_cache()
def cached_fractal_client(address: str) -> FractalClient:
def cached_fractal_client(address: str) -> PortalClient:
"""Returns a cached copy of a fractal client."""

try:

return FractalClient(address)
return PortalClient(address)

except ConnectionRefusedError as e:

# Try to handle the case when connecting to a local snowflake.
try:
return FractalClient(address, verify=False)
return PortalClient(address, verify=False)
except ConnectionRefusedError:
raise e

Expand All @@ -86,7 +86,7 @@ def _cached_client_query(
query_cache: Cache,
cache_predicate: Optional[Callable[[Any], bool]] = None,
) -> List[S]:
"""A helper method to cache calls to ``FractalClient.query_XXX`` methods.
"""A helper method to cache calls to ``PortalClient.query_XXX`` methods.
Args:
client_address: The address of the running QCFractal instance to query.
Expand Down Expand Up @@ -145,7 +145,7 @@ def _cached_client_query(


def cached_query_procedures(client_address: str, record_ids: List[str]) -> List[S]:
"""A cached version of ``FractalClient.query_procedures``.
"""A cached version of ``PortalClient.query_procedures``.
Args:
client_address: The address of the running QCFractal instance to query.
Expand All @@ -167,7 +167,7 @@ def cached_query_procedures(client_address: str, record_ids: List[str]) -> List[
def cached_query_molecules(
client_address: str, molecule_ids: List[str]
) -> List[QCMolecule]:
"""A cached version of ``FractalClient.query_molecules``.
"""A cached version of ``PortalClient.query_molecules``.
Args:
client_address: The address of the running QCFractal instance to query.
Expand Down Expand Up @@ -249,7 +249,7 @@ def _cached_query_single_structure_results(

def cached_query_basic_results(
client_address: str, results: List["BasicResult"]
) -> List[Tuple[ResultRecord, Molecule]]:
) -> List[Tuple[SinglepointRecord, Molecule]]:
"""Returns the QC record and corresponding molecule object associated with each
of the specified result entries.
Expand Down Expand Up @@ -288,7 +288,7 @@ def cached_query_optimization_results(


def _cached_torsion_drive_molecule_ids(
client_address: str, qc_records: List[TorsionDriveRecord]
client_address: str, qc_records: List[TorsiondriveRecord]
) -> Dict[Tuple[str, Tuple[int, ...]], str]:

client_address = client_address.rstrip("/")
Expand Down Expand Up @@ -351,7 +351,7 @@ def _cached_torsion_drive_molecule_ids(

def cached_query_torsion_drive_results(
client_address: str, results: List["TorsionDriveResult"]
) -> List[Tuple[TorsionDriveRecord, Molecule]]:
) -> List[Tuple[TorsiondriveRecord, Molecule]]:
"""Returns the QC record and corresponding molecule object associated with each
of the specified result entries.
Expand All @@ -368,7 +368,7 @@ def cached_query_torsion_drive_results(

logger.debug(f"retrieving records from {client_address}")

qc_records: Dict[str, TorsionDriveRecord] = {
qc_records: Dict[str, TorsiondriveRecord] = {
qc_record.id: qc_record
for qc_record in cached_query_procedures(
client_address, [result.record_id for result in results]
Expand Down

0 comments on commit ce56294

Please sign in to comment.