refactor(bbb): tighten is_valid_smiles signature; document RDLogger global effect
Browse files
src/pipelines/bbb_pipeline.py
CHANGED
|
@@ -11,7 +11,6 @@ traceability (row count in / out / dropped), and idempotent output.
|
|
| 11 |
from __future__ import annotations
|
| 12 |
|
| 13 |
import math
|
| 14 |
-
from typing import Any
|
| 15 |
|
| 16 |
from rdkit import Chem, RDLogger
|
| 17 |
|
|
@@ -21,10 +20,16 @@ logger = get_logger(__name__)
|
|
| 21 |
|
| 22 |
# Suppress RDKit's noisy C++-level warning stream; we surface our own
|
| 23 |
# structured warnings via the project logger when a SMILES fails to parse.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
RDLogger.DisableLog("rdApp.*")
|
| 25 |
|
| 26 |
|
| 27 |
-
def is_valid_smiles(smiles:
|
| 28 |
"""Return True iff `smiles` is a non-empty string parseable by RDKit.
|
| 29 |
|
| 30 |
Handles the full set of garbage we expect from real CSVs:
|
|
|
|
| 11 |
from __future__ import annotations
|
| 12 |
|
| 13 |
import math
|
|
|
|
| 14 |
|
| 15 |
from rdkit import Chem, RDLogger
|
| 16 |
|
|
|
|
| 20 |
|
| 21 |
# Suppress RDKit's noisy C++-level warning stream; we surface our own
|
| 22 |
# structured warnings via the project logger when a SMILES fails to parse.
|
| 23 |
+
#
|
| 24 |
+
# IMPORTANT: this call is process-global and irreversible from this module's
|
| 25 |
+
# import. Any other code (other pipelines, the FastAPI surface, tests) that
|
| 26 |
+
# relies on RDKit warnings will be affected. If a future modality needs
|
| 27 |
+
# fine-grained RDKit log control, move this into an explicit
|
| 28 |
+
# `configure_rdkit_logging()` helper invoked from `run_pipeline()` instead.
|
| 29 |
RDLogger.DisableLog("rdApp.*")
|
| 30 |
|
| 31 |
|
| 32 |
+
def is_valid_smiles(smiles: str | float | None) -> bool:
|
| 33 |
"""Return True iff `smiles` is a non-empty string parseable by RDKit.
|
| 34 |
|
| 35 |
Handles the full set of garbage we expect from real CSVs:
|
tests/pipelines/test_bbb_pipeline.py
CHANGED
|
@@ -26,8 +26,8 @@ class TestIsValidSmiles:
|
|
| 26 |
assert is_valid_smiles("") is False
|
| 27 |
|
| 28 |
def test_rejects_none(self) -> None:
|
| 29 |
-
assert is_valid_smiles(None) is False
|
| 30 |
|
| 31 |
def test_rejects_nan(self) -> None:
|
| 32 |
import math
|
| 33 |
-
assert is_valid_smiles(math.nan) is False
|
|
|
|
| 26 |
assert is_valid_smiles("") is False
|
| 27 |
|
| 28 |
def test_rejects_none(self) -> None:
|
| 29 |
+
assert is_valid_smiles(None) is False
|
| 30 |
|
| 31 |
def test_rejects_nan(self) -> None:
|
| 32 |
import math
|
| 33 |
+
assert is_valid_smiles(math.nan) is False
|