Skip to content

Commit 30d312c

Browse files
authored
Merge branch 'main' into fix-hash-for-chemprop
2 parents 6045c66 + 1402fe5 commit 30d312c

12 files changed

Lines changed: 65 additions & 66 deletions

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ repos:
2424
stages: [commit-msg]
2525

2626
- repo: https://github.com/astral-sh/ruff-pre-commit
27-
rev: v0.15.7
27+
rev: v0.15.14
2828
hooks:
2929
- id: ruff-format
3030
types_or: [python, pyi, jupyter]

molpipeline/estimators/chemprop/component_wrapper.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,9 @@ def set_params(self, **params: Any) -> Self:
220220

221221

222222
# pylint: disable=too-many-ancestors, too-many-instance-attributes
223-
class PredictorWrapper(_Predictor, BaseEstimator, abc.ABC): # type: ignore
223+
class PredictorWrapper(_Predictor, BaseEstimator, abc.ABC):
224224
"""Abstract wrapper for the Predictor class."""
225225

226-
_T_default_criterion: ChempropMetric
227-
_T_default_metric: ChempropMetric
228-
229226
def __init__( # pylint: disable=too-many-positional-arguments # noqa: PLR0917
230227
self,
231228
n_tasks: int = 1,
@@ -384,45 +381,45 @@ def set_params(self, **params: Any) -> Self:
384381
return self
385382

386383

387-
class RegressionFFN(PredictorWrapper, _RegressionFFN): # type: ignore
384+
class RegressionFFN(PredictorWrapper, _RegressionFFN):
388385
"""A wrapper for the RegressionFFN class."""
389386

390387
n_targets: int = 1
391388
_T_default_criterion = MSE
392389
_T_default_metric = MSE
393390

394391

395-
class MveFFN(PredictorWrapper, _MveFFN): # type: ignore
392+
class MveFFN(PredictorWrapper, _MveFFN):
396393
"""A wrapper for the MveFFN class."""
397394

398395
n_targets: int = 2
399396
_T_default_criterion = MVELoss
400397

401398

402-
class EvidentialFFN(PredictorWrapper, _EvidentialFFN): # type: ignore
399+
class EvidentialFFN(PredictorWrapper, _EvidentialFFN):
403400
"""A wrapper for the EvidentialFFN class."""
404401

405402
n_targets: int = 4
406403
_T_default_criterion = EvidentialLoss
407404

408405

409-
class BinaryClassificationFFN(PredictorWrapper, _BinaryClassificationFFN): # type: ignore
406+
class BinaryClassificationFFN(PredictorWrapper, _BinaryClassificationFFN):
410407
"""A wrapper for the BinaryClassificationFFN class."""
411408

412409
n_targets: int = 1
413410
_T_default_criterion = BCELoss
414411
_T_default_metric = BinaryAUROC
415412

416413

417-
class BinaryDirichletFFN(PredictorWrapper, _BinaryDirichletFFN): # type: ignore
414+
class BinaryDirichletFFN(PredictorWrapper, _BinaryDirichletFFN):
418415
"""A wrapper for the BinaryDirichletFFN class."""
419416

420417
n_targets: int = 2
421418
_T_default_criterion = DirichletLoss
422419
_T_default_metric = BinaryAUROC
423420

424421

425-
class MulticlassClassificationFFN(PredictorWrapper, _MulticlassClassificationFFN): # type: ignore
422+
class MulticlassClassificationFFN(PredictorWrapper, _MulticlassClassificationFFN):
426423
"""A wrapper for the MulticlassClassificationFFN class."""
427424

428425
n_targets: int = 1
@@ -508,15 +505,15 @@ def __setstate__(self, state: dict[str, Any]) -> None:
508505
super().__setstate__(state)
509506

510507

511-
class MulticlassDirichletFFN(PredictorWrapper, _MulticlassDirichletFFN): # type: ignore
508+
class MulticlassDirichletFFN(PredictorWrapper, _MulticlassDirichletFFN):
512509
"""A wrapper for the MulticlassDirichletFFN class."""
513510

514511
n_targets: int = 1
515512
_T_default_criterion = DirichletLoss
516513
_T_default_metric = MulticlassMCCMetric
517514

518515

519-
class SpectralFFN(PredictorWrapper, _SpectralFFN): # type: ignore
516+
class SpectralFFN(PredictorWrapper, _SpectralFFN):
520517
"""A wrapper for the SpectralFFN class."""
521518

522519
n_targets: int = 1

molpipeline/estimators/chemprop/lightning_wrapper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def get_params_trainer(trainer: pl.Trainer) -> dict[str, Any]:
146146
"num_nodes": trainer.num_nodes,
147147
"precision": trainer.precision,
148148
"logger": trainer.logger,
149-
# "callbacks": trainer.callbacks, # type: ignore[attr-defined]
149+
# "callbacks": trainer.callbacks, # type: ignore[attr-defined] # noqa: ERA001
150150
"fast_dev_run": trainer.fast_dev_run, # type: ignore[attr-defined]
151151
"max_epochs": trainer.max_epochs,
152152
"min_epochs": trainer.min_epochs,
@@ -172,11 +172,11 @@ def get_params_trainer(trainer: pl.Trainer) -> dict[str, Any]:
172172
"benchmark": torch.backends.cudnn.benchmark,
173173
"inference_mode": trainer.predict_loop.inference_mode,
174174
"use_distributed_sampler": trainer._accelerator_connector.use_distributed_sampler, # noqa: SLF001,E501
175-
# "profiler": trainer.profiler, # type: ignore[attr-defined]
175+
# "profiler": trainer.profiler, # type: ignore[attr-defined] # noqa: ERA001
176176
"detect_anomaly": trainer._detect_anomaly, # noqa: SLF001
177177
"barebones": trainer.barebones,
178-
# "plugins": trainer.plugins, # can not be exctracted
179-
# "sync_batchnorm": trainer._accelerator_connector.sync_batchnorm, # plugin related # noqa: E501
178+
# "plugins": trainer.plugins, # can not be exctracted # noqa: ERA001
179+
# "sync_batchnorm": trainer._accelerator_connector.sync_batchnorm, # plugin related # noqa: E501, ERA001
180180
"reload_dataloaders_every_n_epochs": trainer.reload_dataloaders_every_n_epochs, # type: ignore[attr-defined]
181181
"default_root_dir": get_trainer_path(trainer),
182182
}

molpipeline/estimators/leader_picker_clustering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def _fit(self, X: list[ExplicitBitVect]) -> Self: # noqa: N803
120120
poolSize=len(X),
121121
threshold=self.distance_threshold,
122122
numThreads=1, # according to rdkit docu this parameter is not used
123-
# seed=self.random_state if self.random_state is not None else -1,
123+
# seed=self.random_state if self.random_state is not None else -1, # noqa: ERA001
124124
)
125125

126126
# Assign points to clusters based on centroid

molpipeline/pipeline/_skl_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ def __sklearn_tags__(self) -> Tags:
10211021
# tuples and `fit` is not called yet to validate the steps.
10221022
pass
10231023

1024-
try:
1024+
try: # noqa: PLW0717
10251025
# Only the _final_estimator is changed from the original implementation is
10261026
# changed in the following 2 lines
10271027
if (

molpipeline/utils/logging.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,16 @@ def print_elapsed_time(
6969
yield
7070
else:
7171
start = timeit.default_timer()
72-
yield
73-
message_to_print = _message_with_time(
74-
source,
75-
message,
76-
timeit.default_timer() - start,
77-
)
78-
79-
if use_logger:
80-
logger.info(message_to_print)
81-
else:
82-
print(message_to_print) # noqa: T201
72+
try:
73+
yield
74+
finally:
75+
message_to_print = _message_with_time(
76+
source,
77+
message,
78+
timeit.default_timer() - start,
79+
)
80+
81+
if use_logger:
82+
logger.info(message_to_print)
83+
else:
84+
print(message_to_print) # noqa: T201

notebooks/advanced_01_hyperopt_on_bbbp.ipynb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,7 @@
391391
"plt.xlabel(\"Cluster rank by size\")\n",
392392
"plt.ylabel(\"Number of molecules in cluster\")\n",
393393
"plt.yscale(\"log\")\n",
394-
"_ = plt.title(\"Sorted distribution of cluster sizes\")\n",
395-
"# plt.savefig(\"cluster_sizes.pdf\", dpi=300)"
394+
"_ = plt.title(\"Sorted distribution of cluster sizes\")"
396395
]
397396
},
398397
{
@@ -1295,8 +1294,7 @@
12951294
"plt.ylabel(\"ROC AUC\", fontsize=13)\n",
12961295
"plt.xlabel(\"Estimators\", fontsize=13)\n",
12971296
"plt.xticks(fontsize=12)\n",
1298-
"plt.tight_layout()\n",
1299-
"# plt.savefig(\"hyperopt_performance.pdf\", dpi=300)"
1297+
"plt.tight_layout()"
13001298
]
13011299
},
13021300
{

notebooks/advanced_03_introduction_to_explainable_ai.ipynb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,8 +1074,6 @@
10741074
"metadata": {},
10751075
"outputs": [],
10761076
"source": [
1077-
"# series_names = [\"b1i5k\", \"b1i2n\", \"b1i5b\"]\n",
1078-
"# series_dict = {k:explanations_dict[k] for k in series_names}\n",
10791077
"series_dict = explanations_dict\n",
10801078
"\n",
10811079
"weight_min = min(exp.atom_weights.min() for exp in series_dict.values())\n",

notebooks/advanced_05_conformal_prediction.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@
716716
" confidence=confidence_level,\n",
717717
")\n",
718718
"\n",
719-
"try:\n",
719+
"try: # noqa: PLW0717\n",
720720
" results_cross_clf = cross_cp_clf.evaluate(\n",
721721
" x_test_clf,\n",
722722
" y_test_clf,\n",
@@ -1199,7 +1199,7 @@
11991199
"intervals_split = split_cp_reg.predict_int(x_test_reg, confidence=confidence_level)\n",
12001200
"\n",
12011201
"# Evaluate using built-in evaluate method and helper functions\n",
1202-
"try:\n",
1202+
"try: # noqa: PLW0717\n",
12031203
" results_built_in = split_cp_reg.evaluate(\n",
12041204
" x_test_reg,\n",
12051205
" y_test_reg,\n",
@@ -1289,7 +1289,7 @@
12891289
"intervals_cross = cross_cp_reg.predict_int(x_test_reg, confidence=confidence_level)\n",
12901290
"\n",
12911291
"# Evaluate using built-in evaluate method\n",
1292-
"try:\n",
1292+
"try: # noqa: PLW0717\n",
12931293
" results_cross_built_in = cross_cp_reg.evaluate(\n",
12941294
" x_test_reg,\n",
12951295
" y_test_reg,\n",

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ ignore = [
9191
"ANN401", # Allow typing.Any
9292
"D203", # incorrect-blank-line-before-class
9393
"D213", # blank-line-before-class-docstring
94-
"ERA001", # Found commented-out code # TO REMOVE
9594
"FURB113", # Use `xxx.extend(...)` instead of repeatedly calling `xxx.append() # TO REMOVE
9695
"N813", # Camelcase `rdFingerprintGenerator` imported as lowercase `rdkit_fp` # TO REMOVE
9796
"PGH003", # Blanket type ignore for types
@@ -143,10 +142,10 @@ reportArgumentType = "warning"
143142
reportCallIssue = "warning"
144143
reportGeneralTypeIssues = "warning"
145144
reportIncompatibleMethodOverride = "warning"
146-
reportIncompatibleVariableOverride = "warning"
145+
reportIncompatibleVariableOverride = "error"
147146
reportInvalidTypeForm = "warning"
148147
reportIndexIssue = "warning"
149-
reportMissingImports = "warning"
148+
reportMissingImports = "error"
150149
reportMissingTypeStubs = "warning"
151150
reportOptionalMemberAccess = "warning"
152151
reportOptionalSubscript = "warning"
@@ -155,7 +154,7 @@ reportPossiblyUnboundVariable = "warning"
155154
reportPrivateImportUsage = "warning"
156155
reportRedeclaration = "warning"
157156
reportReturnType = "warning"
158-
reportUnhashable = "warning"
157+
reportUnhashable = "error"
159158
venvPath = "."
160159
venv = ".venv"
161160
pythonVersion = "3.11"
@@ -174,6 +173,7 @@ exclude = ["tests", "docs"]
174173
dev = [
175174
"bandit>=1.8.3",
176175
"black[jupyter]>=25.1.0",
176+
"chemprop>=2.2.3",
177177
"coverage>=7.8.0",
178178
"docsig>=0.79.0",
179179
"flake8>=7.2.0",

0 commit comments

Comments
 (0)