Skip to content

Commit

Permalink
using try except -> pkgutil does not work with notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
c-w-feldmann committed Apr 25, 2024
1 parent de13674 commit 11cdd8e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 2 additions & 5 deletions molpipeline/estimators/chemprop/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""Initialize Chemprop module."""

import pkgutil

installed_packages = {pkg.name for pkg in pkgutil.iter_modules()}
if "chemprop" in installed_packages:
try:
from molpipeline.estimators.chemprop.models import ( # noqa: F401
ChempropClassifier,
ChempropModel,
Expand All @@ -17,5 +14,5 @@
"ChempropNeuralFP",
"ChempropRegressor",
]
else:
except ImportError:
__all__ = []
7 changes: 3 additions & 4 deletions molpipeline/mol2any/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Init the module for mol2any pipeline elements."""

import pkgutil

from molpipeline.mol2any.mol2bin import MolToBinary
from molpipeline.mol2any.mol2concatinated_vector import MolToConcatenatedVector
from molpipeline.mol2any.mol2inchi import MolToInchi, MolToInchiKey
Expand All @@ -21,8 +19,9 @@
"MolToRDKitPhysChem",
]

installed_packages = {pkg.name for pkg in pkgutil.iter_modules()}
if "chemprop" in installed_packages:
try:
from molpipeline.mol2any.mol2chemprop import MolToChemprop # noqa

__all__.append("MolToChemprop")
except ImportError:
pass

0 comments on commit 11cdd8e

Please sign in to comment.