Skip to content

Commit

Permalink
refactor annottions class in constants
Browse files Browse the repository at this point in the history
  • Loading branch information
rnetser committed Jan 20, 2025
1 parent 87b1daf commit f7f6cf6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
16 changes: 8 additions & 8 deletions tests/model_registry/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from tests.model_registry.utils import get_endpoint_from_mr_service, get_mr_service_by_label
from utilities.infra import create_ns
from utilities.constants import Protocols, KubernetesAnnotations
from utilities.constants import Annotations, Protocols


LOGGER = get_logger(name=__name__)
Expand All @@ -22,9 +22,9 @@
MR_OPERATOR_NAME: str = "model-registry-operator"
MR_NAMESPACE: str = "rhoai-model-registries"
DEFAULT_LABEL_DICT_DB: dict[str, str] = {
KubernetesAnnotations.NAME: DB_RESOURCES_NAME,
KubernetesAnnotations.INSTANCE: DB_RESOURCES_NAME,
KubernetesAnnotations.PART_OF: DB_RESOURCES_NAME,
Annotations.KubernetesIo.NAME: DB_RESOURCES_NAME,
Annotations.KubernetesIo.INSTANCE: DB_RESOURCES_NAME,
Annotations.KubernetesIo.PART_OF: DB_RESOURCES_NAME,
}


Expand Down Expand Up @@ -251,10 +251,10 @@ def model_registry_instance(
name=MR_INSTANCE_NAME,
namespace=model_registry_namespace.name,
label={
KubernetesAnnotations.NAME: MR_INSTANCE_NAME,
KubernetesAnnotations.INSTANCE: MR_INSTANCE_NAME,
KubernetesAnnotations.PART_OF: MR_OPERATOR_NAME,
KubernetesAnnotations.CREATED_BY: MR_OPERATOR_NAME,
Annotations.KubernetesIo.NAME: MR_INSTANCE_NAME,
Annotations.KubernetesIo.INSTANCE: MR_INSTANCE_NAME,
Annotations.KubernetesIo.PART_OF: MR_OPERATOR_NAME,
Annotations.KubernetesIo.CREATED_BY: MR_OPERATOR_NAME,
},
grpc={},
rest={},
Expand Down
4 changes: 2 additions & 2 deletions tests/model_serving/model_server/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from simple_logger.logger import get_logger
from timeout_sampler import TimeoutSampler

from utilities.constants import KServeDeploymentType, KubernetesAnnotations
from utilities.constants import Annotations, KServeDeploymentType
from utilities.exceptions import FailedPodsError, InferenceResponseError, InvalidStorageArgumentError
from utilities.inference_utils import UserInference
from utilities.infra import (
Expand Down Expand Up @@ -110,7 +110,7 @@ def create_isvc(
if volumes:
predictor_dict["volumes"] = volumes

annotations = {KubernetesAnnotations.DEPLOYMENT_MODE: deployment_mode}
annotations = {Annotations.KserveIo.DEPLOYMENT_MODE: deployment_mode}

if deployment_mode == KServeDeploymentType.SERVERLESS:
annotations.update({
Expand Down
15 changes: 9 additions & 6 deletions utilities/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,15 @@ class AcceleratorType:
SUPPORTED_LISTS: list[str] = [NVIDIA, AMD, GAUDI]


class KubernetesAnnotations:
NAME: str = f"{Resource.ApiGroup.APP_KUBERNETES_IO}/name"
INSTANCE: str = f"{Resource.ApiGroup.APP_KUBERNETES_IO}/instance"
PART_OF: str = f"{Resource.ApiGroup.APP_KUBERNETES_IO}/part-of"
CREATED_BY: str = f"{Resource.ApiGroup.APP_KUBERNETES_IO}/created-by"
DEPLOYMENT_MODE: str = "serving.kserve.io/deploymentMode"
class Annotations:
class KubernetesIo:
NAME: str = f"{Resource.ApiGroup.APP_KUBERNETES_IO}/name"
INSTANCE: str = f"{Resource.ApiGroup.APP_KUBERNETES_IO}/instance"
PART_OF: str = f"{Resource.ApiGroup.APP_KUBERNETES_IO}/part-of"
CREATED_BY: str = f"{Resource.ApiGroup.APP_KUBERNETES_IO}/created-by"

class KserveIo:
DEPLOYMENT_MODE: str = "serving.kserve.io/deploymentMode"


class StorageClassName:
Expand Down
4 changes: 2 additions & 2 deletions utilities/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from simple_logger.logger import get_logger

import utilities.infra
from utilities.constants import KServeDeploymentType, KubernetesAnnotations, MODELMESH_SERVING
from utilities.constants import Annotations, KServeDeploymentType, MODELMESH_SERVING

LOGGER = get_logger(name=__name__)

Expand Down Expand Up @@ -111,7 +111,7 @@ def download_model_data(


def create_isvc_label_selector_str(isvc: InferenceService) -> str:
if isvc.instance.metadata.annotations.get(KubernetesAnnotations.DEPLOYMENT_MODE) in (
if isvc.instance.metadata.annotations.get(Annotations.KserveIo.DEPLOYMENT_MODE) in (
KServeDeploymentType.SERVERLESS,
KServeDeploymentType.RAW_DEPLOYMENT,
):
Expand Down

0 comments on commit f7f6cf6

Please sign in to comment.