mirror of
https://github.com/clearml/clearml-serving
synced 2025-03-13 07:18:47 +00:00
Add Preprocess.model_endpoint
This commit is contained in:
parent
49e5acba53
commit
409fc156fd
@ -12,7 +12,8 @@ class Preprocess(object):
|
||||
|
||||
def __init__(self):
|
||||
# set internal state, this will be called only once. (i.e. not per request)
|
||||
pass
|
||||
# it will also set the internal model_endpoint to reference the specific model endpoint object being served
|
||||
self.model_endpoint = None # type: clearml_serving.serving.endpoints.ModelEndpoint
|
||||
|
||||
def load(self, local_file_name: str) -> Optional[Any]: # noqa
|
||||
"""
|
||||
|
@ -228,7 +228,8 @@ class ModelRequestProcessor(object):
|
||||
if len(models) > 1:
|
||||
print("Warning: Found multiple Models for \'{}\', selecting id={}".format(model_query, models[0].id))
|
||||
endpoint.model_id = models[0].id
|
||||
elif not endpoint.model_id:
|
||||
elif not endpoint.model_id and endpoint.engine_type != "custom":
|
||||
# if the "engine_type" is "custom" it might be there is no model_id attached
|
||||
print("Warning: No Model provided for \'{}\'".format(url))
|
||||
|
||||
# upload as new artifact
|
||||
|
@ -71,6 +71,8 @@ class BasePreprocessRequest(object):
|
||||
Preprocess.send_request = BasePreprocessRequest._preprocess_send_request
|
||||
# create preprocess class
|
||||
self._preprocess = Preprocess()
|
||||
# update the model endpoint on the instance we created
|
||||
self._preprocess.model_endpoint = self.model_endpoint
|
||||
# custom model load callback function
|
||||
if callable(getattr(self._preprocess, 'load', None)):
|
||||
self._model = self._preprocess.load(self._get_local_model_file())
|
||||
@ -129,6 +131,8 @@ class BasePreprocessRequest(object):
|
||||
pass
|
||||
|
||||
def _get_local_model_file(self):
|
||||
if not self.model_endpoint.model_id:
|
||||
return None
|
||||
model_repo_object = Model(model_id=self.model_endpoint.model_id)
|
||||
return model_repo_object.get_local_copy()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user