Skip to content

Commit be1f93d

Browse files
authored
Add error handling for RDKit imports
Handle import errors for RDKit library gracefully.
1 parent d55e132 commit be1f93d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • opencompass/datasets/moleculariq/moleculariq_core/rewards

opencompass/datasets/moleculariq/moleculariq_core/rewards/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
from typing import Dict, Any
77

88
from ..properties import canonicalize_property_name
9-
from rdkit import Chem
10-
from rdkit.Chem import SanitizeMol
9+
10+
try:
11+
from rdkit import Chem
12+
from rdkit.Chem import SanitizeMol
13+
except Exception:
14+
Chem, SanitizeMol = None, None
15+
1116
from .._nlp.mappings import parse_natural_language
1217

1318

0 commit comments

Comments
 (0)