Skip to content

Commit

Permalink
feat: real exception handling during module load
Browse files Browse the repository at this point in the history
  • Loading branch information
supersergiy committed May 8, 2024
1 parent c31f977 commit 6fbfeb3
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions zetta_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"""Zetta AI Computational Connectomics Toolkit."""
from . import log, typing, parsing, builder, common, constants
from . import geometry, distributions, layer, ng
from .log import get_logger

logger = get_logger("zetta_utils")

builder.registry.MUTLIPROCESSING_INCOMPATIBLE_CLASSES.add("mazepa")
builder.registry.MUTLIPROCESSING_INCOMPATIBLE_CLASSES.add("lightning")
Expand All @@ -17,25 +20,22 @@ def try_load_train_inference(): # pragma: no cover
try:
load_inference_modules()

except ImportError:
...
except Exception as e: # pylint: disable=broad-exception-caught
logger.exception(e)

try:
load_training_modules()
except ImportError:
...
except Exception as e: # pylint: disable=broad-exception-caught
logger.exception(e)

try:
from . import mazepa_addons
except ImportError:
...
except Exception as e: # pylint: disable=broad-exception-caught
logger.exception(e)


def try_load_submodules(): # pragma: no cover
try:
from . import internal
except ImportError:
...
def load_submodules(): # pragma: no cover
from . import internal


def load_inference_modules():
Expand All @@ -56,7 +56,7 @@ def load_inference_modules():
from . import message_queues
from . import cloud_management

try_load_submodules()
load_submodules()


def load_training_modules():
Expand All @@ -76,7 +76,4 @@ def load_training_modules():
from . import message_queues
from . import cloud_management

try_load_submodules()


try_load_train_inference()
load_submodules()

0 comments on commit 6fbfeb3

Please sign in to comment.