Skip to content

Commit

Permalink
Fix circular dependency in hsml (model/util)
Browse files Browse the repository at this point in the history
  • Loading branch information
aversey committed Jul 14, 2024
1 parent b59b0fd commit 3992813
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
25 changes: 15 additions & 10 deletions python/hsml/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@
import pandas as pd
from hsml import client
from hsml.constants import DEFAULT, MODEL, PREDICTOR
from hsml.model import Model as BaseModel
from hsml.predictor import Predictor as BasePredictor
from hsml.python.model import Model as PyModel
from hsml.python.predictor import Predictor as PyPredictor
from hsml.sklearn.model import Model as SkLearnModel
from hsml.sklearn.predictor import Predictor as SkLearnPredictor
from hsml.tensorflow.model import Model as TFModel
from hsml.tensorflow.predictor import Predictor as TFPredictor
from hsml.torch.model import Model as TorchModel
from hsml.torch.predictor import Predictor as TorchPredictor
from six import string_types


Expand Down Expand Up @@ -105,6 +95,11 @@ def default(self, obj): # pylint: disable=E0202


def set_model_class(model):
from hsml.model import Model as BaseModel
from hsml.python.model import Model as PyModel
from hsml.sklearn.model import Model as SkLearnModel
from hsml.tensorflow.model import Model as TFModel
from hsml.torch.model import Model as TorchModel
if "href" in model:
_ = model.pop("href")
if "type" in model: # backwards compatibility
Expand Down Expand Up @@ -236,6 +231,16 @@ def validate_metrics(metrics):


def get_predictor_for_model(model, **kwargs):
from hsml.model import Model as BaseModel
from hsml.python.model import Model as PyModel
from hsml.sklearn.model import Model as SkLearnModel
from hsml.tensorflow.model import Model as TFModel
from hsml.torch.model import Model as TorchModel
from hsml.torch.predictor import Predictor as TorchPredictor
from hsml.predictor import Predictor as BasePredictor
from hsml.tensorflow.predictor import Predictor as TFPredictor
from hsml.sklearn.predictor import Predictor as SkLearnPredictor
from hsml.python.predictor import Predictor as PyPredictor
if not isinstance(model, BaseModel):

Check failure on line 244 in python/hsml/util.py

View workflow job for this annotation

GitHub Actions / Lint and Stylecheck

Ruff (I001)

python/hsml/util.py:234:1: I001 Import block is un-sorted or un-formatted
raise ValueError(
"model is of type {}, but an instance of {} class is expected".format(
Expand Down
11 changes: 1 addition & 10 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,7 @@ build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
exclude = ["tests*"]
include = [
"../README.md",
"../LICENSE",
"hopsworks",
"hopsworks.*",
"hsfs",
"hsfs.*",
"hsml",
"hsml.*",
]
include = ["../README.md", "../LICENSE", "hopsworks*", "hsfs*", "hsml*"]

[tool.setuptools.dynamic]
version = { attr = "hopsworks.version.__version__" }
Expand Down

0 comments on commit 3992813

Please sign in to comment.