Skip to content

Commit

Permalink
Merge pull request #21 from MolecularAI/misc_fixes
Browse files Browse the repository at this point in the history
Depreciate typing-extensions & inference fixes
  • Loading branch information
lewismervin1 authored Jul 17, 2024
2 parents 1fc1420 + fe06e6f commit 925be89
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 26 deletions.
3 changes: 1 addition & 2 deletions optunaz/config/buildconfig.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import abc
from dataclasses import dataclass, field
from typing import Optional, Union
from typing import Optional, Union, Literal

import sklearn
import sklearn.cross_decomposition
Expand All @@ -11,7 +11,6 @@
import xgboost
from apischema import schema
from sklearn.base import BaseEstimator
from typing_extensions import Literal

import optunaz
from optunaz import algorithms
Expand Down
3 changes: 1 addition & 2 deletions optunaz/config/optconfig.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import logging
from dataclasses import dataclass, field
from enum import Enum
from typing import Union, Optional, List, Iterable, Type, Any
from typing import Union, Optional, List, Iterable, Type, Any, Literal, Annotated

from apischema import schema, type_name, serialize
from apischema.metadata import none_as_undefined, required
from typing_extensions import Literal, Annotated

from optunaz.config import (
ModelMode,
Expand Down
3 changes: 1 addition & 2 deletions optunaz/descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import pathlib
from dataclasses import dataclass, field
from typing import List, Union, Type, Optional, Any, Tuple, Dict
from typing import List, Union, Type, Optional, Any, Tuple, Dict, Literal, Annotated
from functools import partial

import apischema
Expand Down Expand Up @@ -34,7 +34,6 @@
from jazzy.api import molecular_vector_from_smiles
from jazzy.exception import JazzyError
from sklearn import preprocessing
from typing_extensions import Literal, Annotated
from joblib import Parallel, delayed, effective_n_jobs
from optunaz.config import NameParameterDataclass
from optunaz.utils import load_df_from_file
Expand Down
30 changes: 15 additions & 15 deletions optunaz/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ def validate_uncertainty(args, model):
raise UncertaintyError("Uncertainty not availble for this model")


def check_precomp_args(args):
try:
assert (
args.input_precomputed_file is not None
), "Must supply precomputed descriptor parameters"
assert (
args.input_precomputed_input_column
), "Must supply input column for precomputed descriptor"
assert (
args.input_precomputed_response_column
), "Must supply response column for precomputed descriptor"
except AssertionError as e:
raise PrecomputedError(e)


def set_inference_params(args, desc):
if hasattr(desc.parameters, "descriptor") and hasattr(
desc.parameters.descriptor, "inference_parameters"
Expand All @@ -62,21 +77,6 @@ def set_inference_params(args, desc):
return False


def check_precomp_args(args):
try:
assert (
args.input_precomputed_file is not None
), "Must supply precomputed descriptor parameters"
assert (
args.input_precomputed_input_column
), "Must supply input column for precomputed descriptor"
assert (
args.input_precomputed_response_column
), "Must supply response column for precomputed descriptor"
except AssertionError as e:
raise PrecomputedError(e)


def validate_set_precomputed(args, model):
descriptor_str = model.descriptor.name
if set_inference_params(args, model.descriptor):
Expand Down
3 changes: 1 addition & 2 deletions optunaz/utils/preprocessing/deduplicator.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import abc
from dataclasses import dataclass, field
from typing import Optional, Union, Any
from typing import Optional, Union, Any, Literal

import pandas as pd
from apischema import deserializer, serializer, schema, identity
from apischema.conversions import Conversion
from apischema.metadata import none_as_undefined
from typing_extensions import Literal # Python 3.7


class Deduplicator:
Expand Down
3 changes: 1 addition & 2 deletions optunaz/utils/preprocessing/splitter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import abc
from dataclasses import dataclass, field
from typing import Optional, Iterator, Tuple, Union, Dict
from typing import Optional, Iterator, Tuple, Union, Dict, Literal, Annotated

import numpy as np
import sklearn
Expand All @@ -13,7 +13,6 @@
PredefinedSplit,
StratifiedGroupKFold,
)
from typing_extensions import Literal, Annotated # Python 3.7


class SklearnSplitter(abc.ABC):
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jsonpickle = "^2.0"
xgboost = "^1.3"
rdkit = ">=2023.3.1"
scikit-learn = "1.4.0"
typing-extensions = ">=3.10, <5.0"
apischema = "^0.17"
chemprop = "1.6.1"
descriptastorus = "^2.4" # Chemprop dependency, but chemprop does not install it itself.
Expand Down

0 comments on commit 925be89

Please sign in to comment.