Skip to content
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
25 changes: 25 additions & 0 deletions deepmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

if TYPE_CHECKING:
from deepmd.infer import DeepPotential as DeepPotentialType
from deepmd.property import (
PropertyPredictor,
PropertyTrainer,
)

try:
from deepmd._version import version as __version__
Expand Down Expand Up @@ -47,7 +51,28 @@ def DeepPotential(*args: Any, **kwargs: Any) -> "DeepPotentialType":
return DeepPotential(*args, **kwargs)


def __getattr__(name: str) -> Any:
"""Lazily expose optional high-level helpers.

The top-level module should avoid importing third-party-heavy modules at
import time for performance. Keep these exports lazy.
"""
if name in {"PropertyPredictor", "PropertyTrainer"}:
from .property import (
PropertyPredictor,
PropertyTrainer,
)

return {
"PropertyPredictor": PropertyPredictor,
"PropertyTrainer": PropertyTrainer,
}[name]
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


__all__ = [
"DeepPotential",
"PropertyPredictor",
"PropertyTrainer",
"__version__",
]
4 changes: 4 additions & 0 deletions deepmd/infer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
from .deep_pot import (
DeepPot,
)
from .deep_property import (
DeepProperty,
)
from .model_devi import (
calc_model_devi,
)
Expand All @@ -13,6 +16,7 @@
"DeepEval",
"DeepPot",
"DeepPotential",
"DeepProperty",
"calc_model_devi",
]

Expand Down
Loading
Loading