Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions python/hsfs/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#

from dataclasses import dataclass
from hsfs import client
from hsfs.client.exceptions import FeatureStoreException
from typing import Type
import json
Expand Down Expand Up @@ -59,16 +60,27 @@ def from_model(cls, model):
# should get from backend because of authorisation check (unshared project etc)
def get_model(self):
try:
from hsml.core.model_api import ModelApi
from hsml.model import Model
except ModuleNotFoundError:
raise FeatureStoreException(
"Model is attached to embedding feature but hsml library is not installed."
"Install hsml library before getting the feature group."
)

return ModelApi().get(
self.model_name, self.model_version, self.model_registry_id
path_params = [
"project",
client.get_instance()._project_id,
"modelregistries",
self.model_registry_id,
"models",
self.model_name + "_" + str(self.model_version),
]
query_params = {"expand": "trainingdatasets"}

model_json = client.get_instance()._send_request(
"GET", path_params, query_params
)
return Model.from_response_json(model_json)

def json(self):
return json.dumps(self, cls=util.FeatureStoreEncoder)
Expand Down