Skip to content

Commit 626648a

Browse files
authored
Put import of ModifierFactory to a try block (#24)
Users who install with the train extra (which excludes llmcompressor) will hit an ImportError. This change wraps the llmcompressor import in try and logs that skipping FMCHISEL modifier registration is expected when using the train extra. When llmcompressor is available, registration proceeds as before.
1 parent 4f29551 commit 626648a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/fmchisel/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import logging
22

3-
from llmcompressor.modifiers.factory import ModifierFactory
4-
53
logger = logging.getLogger(__name__)
4+
65
try:
6+
from llmcompressor.modifiers.factory import ModifierFactory
7+
8+
except ImportError:
9+
logger.info(
10+
"Optional dependency 'llmcompressor' not found; skipping FMCHISEL modifier "
11+
"registration. If you installed from source with the 'train' extra, this is expected."
12+
)
713

14+
else:
815
ModifierFactory._EXPERIMENTAL_PACKAGE_PATH = "fmchisel"
916
ModifierFactory.refresh()
1017
logger.info("Registered FMCHISEL modifiers successfully.")
11-
12-
except ImportError:
13-
logger.info("llmcompressor not detected. FMCHISEL Modifiers will not be registered.")

0 commit comments

Comments
 (0)