diff --git a/python/hsml/model.py b/python/hsml/model.py index 838d84f68..2dfa7d7ab 100644 --- a/python/hsml/model.py +++ b/python/hsml/model.py @@ -17,6 +17,7 @@ import json import logging import os +import re import warnings from typing import Any, Dict, Optional, Union @@ -236,7 +237,7 @@ def deploy( """ if name is None: - name = self._name + name = self._get_default_serving_name() predictor = Predictor.for_model( self, @@ -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) diff --git a/python/hsml/model_serving.py b/python/hsml/model_serving.py index d448193aa..9b3c34ba5 100644 --- a/python/hsml/model_serving.py +++ b/python/hsml/model_serving.py @@ -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) @@ -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,