Skip to content

Commit

Permalink
[HWORKS-1822] Infer valid serving name based on the model name
Browse files Browse the repository at this point in the history
  • Loading branch information
javierdlrm authored and davitbzh committed Dec 3, 2024
1 parent 9c18299 commit 0e26fa0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion python/hsml/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import json
import logging
import os
import re
import warnings
from typing import Any, Dict, Optional, Union

Expand Down Expand Up @@ -236,7 +237,7 @@ def deploy(
"""

if name is None:
name = self._name
name = self._get_default_serving_name()

predictor = Predictor.for_model(
self,
Expand Down Expand Up @@ -366,6 +367,9 @@ def get_training_dataset_provenance(self):
"""
return self._model_engine.get_training_dataset_provenance(model_instance=self)

def _get_default_serving_name(self):
return re.sub(r"[^a-zA-Z0-9]", "", self._name)

@classmethod
def from_response_json(cls, json_dict):
json_decamelized = humps.decamelize(json_dict)
Expand Down
4 changes: 2 additions & 2 deletions python/hsml/model_serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def get_deployments(self, model: Model = None, status: str = None):
`RestAPIError`: If unable to retrieve deployments from model serving.
"""

model_name = model.name if model is not None else None
model_name = model._get_default_serving_name() if model is not None else None
if status is not None:
self._validate_deployment_status(status)

Expand Down Expand Up @@ -208,7 +208,7 @@ def create_predictor(
"""

if name is None:
name = model.name
name = model._get_default_serving_name()

return Predictor.for_model(
model,
Expand Down

0 comments on commit 0e26fa0

Please sign in to comment.