From efe0962f5e48749d5dae6b0846046d8820ca1e36 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Sat, 20 Jan 2024 09:11:59 -0500 Subject: [PATCH] move `OutOfMemoryError` from `deepmd` to `deepmd_utils` (#3153) To prevent circular import Signed-off-by: Jinzhe Zeng --- deepmd/utils/errors.py | 12 ++++++++++-- deepmd_utils/utils/batch_size.py | 2 +- deepmd_utils/utils/errors.py | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 deepmd_utils/utils/errors.py diff --git a/deepmd/utils/errors.py b/deepmd/utils/errors.py index 5d96fa0e6a..683131e48a 100644 --- a/deepmd/utils/errors.py +++ b/deepmd/utils/errors.py @@ -1,4 +1,9 @@ # SPDX-License-Identifier: LGPL-3.0-or-later +from deepmd_utils.utils.errors import ( + OutOfMemoryError, +) + + class GraphTooLargeError(Exception): """The graph is too large, exceeding protobuf's hard limit of 2GB.""" @@ -7,5 +12,8 @@ class GraphWithoutTensorError(Exception): pass -class OutOfMemoryError(Exception): - """This error is caused by out-of-memory (OOM).""" +__all__ = [ + "OutOfMemoryError", + "GraphTooLargeError", + "GraphWithoutTensorError", +] diff --git a/deepmd_utils/utils/batch_size.py b/deepmd_utils/utils/batch_size.py index c85806458f..1b93a51242 100644 --- a/deepmd_utils/utils/batch_size.py +++ b/deepmd_utils/utils/batch_size.py @@ -12,7 +12,7 @@ import numpy as np -from deepmd.utils.errors import ( +from deepmd_utils.utils.errors import ( OutOfMemoryError, ) diff --git a/deepmd_utils/utils/errors.py b/deepmd_utils/utils/errors.py new file mode 100644 index 0000000000..11f42ede96 --- /dev/null +++ b/deepmd_utils/utils/errors.py @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +class OutOfMemoryError(Exception): + """This error is caused by out-of-memory (OOM)."""