-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
11,406 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,19 @@ | ||
import importlib | ||
import os | ||
from typing import TYPE_CHECKING # noqa F401 | ||
|
||
# The below lazy import logic is coming from openff-toolkit: | ||
# https://github.com/openforcefield/openff-toolkit/blob/b52879569a0344878c40248ceb3bd0f90348076a/openff/toolkit/__init__.py#L44 | ||
|
||
# Dictionary of objects to lazily import; maps the object's name to its module path | ||
|
||
_lazy_imports_obj = { | ||
"BaseInteractionDataset": "openqdc.datasets.interaction.base", | ||
"DES370K": "openqdc.datasets.interaction.des370k", | ||
"DES5M": "openqdc.datasets.interaction.des5m", | ||
"Metcalf": "openqdc.datasets.interaction.metcalf", | ||
"DESS66": "openqdc.datasets.interaction.dess66", | ||
"DESS66x8": "openqdc.datasets.interaction.dess66x8", | ||
"L7": "openqdc.datasets.interaction.L7", | ||
"X40": "openqdc.datasets.interaction.X40", | ||
"Splinter": "openqdc.datasets.interaction.splinter", | ||
from .des5m import DES5M | ||
from .des370k import DES370K | ||
from .dess66 import DESS66 | ||
from .dess66x8 import DESS66x8 | ||
from .L7 import L7 | ||
from .metcalf import Metcalf | ||
from .splinter import Splinter | ||
from .X40 import X40 | ||
|
||
AVAILABLE_INTERACTION_DATASETS = { | ||
"des370k": DES370K, | ||
"des5m": DES5M, | ||
"dess66": DESS66, | ||
"dess66x8": DESS66x8, | ||
"L7": L7, | ||
"metcalf": Metcalf, | ||
"splinter": Splinter, | ||
"X40": X40, | ||
} | ||
|
||
_lazy_imports_mod = {} | ||
|
||
|
||
def __getattr__(name): | ||
"""Lazily import objects from _lazy_imports_obj or _lazy_imports_mod | ||
Note that this method is only called by Python if the name cannot be found | ||
in the current module.""" | ||
obj_mod = _lazy_imports_obj.get(name) | ||
if obj_mod is not None: | ||
mod = importlib.import_module(obj_mod) | ||
return mod.__dict__[name] | ||
|
||
lazy_mod = _lazy_imports_mod.get(name) | ||
if lazy_mod is not None: | ||
return importlib.import_module(lazy_mod) | ||
|
||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") | ||
|
||
|
||
def __dir__(): | ||
"""Add _lazy_imports_obj and _lazy_imports_mod to dir(<module>)""" | ||
keys = (*globals().keys(), *_lazy_imports_obj.keys(), *_lazy_imports_mod.keys()) | ||
return sorted(keys) | ||
|
||
|
||
if TYPE_CHECKING or os.environ.get("OPENQDC_DISABLE_LAZY_LOADING", "0") == "1": | ||
from .base import BaseInteractionDataset | ||
from .des5m import DES5M | ||
from .des370k import DES370K | ||
from .dess66 import DESS66 | ||
from .dess66x8 import DESS66x8 | ||
from .L7 import L7 | ||
from .metcalf import Metcalf | ||
from .splinter import Splinter | ||
from .X40 import X40 | ||
|
||
__all__ = [ | ||
"BaseInteractionDataset", | ||
"DES370K", | ||
"DES5M", | ||
"Metcalf", | ||
"DESS66", | ||
"DESS66x8", | ||
"L7", | ||
"X40", | ||
"Splinter", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.