11import json
22from typing import Any
3+ import time
4+ import yaml
35
46from kubernetes .dynamic import DynamicClient
57from simple_logger .logger import get_logger
68
79import requests
810from timeout_sampler import retry
911
12+ from ocp_resources .config_map import ConfigMap
1013from ocp_resources .pod import Pod
1114from tests .model_registry .model_catalog .constants import (
1215 DEFAULT_CATALOG_NAME ,
@@ -96,18 +99,16 @@ def validate_default_catalog(default_catalog) -> None:
9699
97100def get_catalog_str (ids : list [str ]) -> str :
98101 catalog_str : str = ""
99- for id in ids :
102+ for index , id in enumerate ( ids ) :
100103 catalog_str += f"""
101- - name: Sample Catalog
104+ - name: Sample Catalog { index }
102105 id: { id }
103106 type: yaml
104107 enabled: true
105108 properties:
106109 yamlCatalogPath: { id .replace ("_" , "-" )} .yaml
107110"""
108- return f"""catalogs:
109- { catalog_str }
110- """
111+ return catalog_str
111112
112113
113114def get_sample_yaml_str (models : list [str ]) -> str :
@@ -123,6 +124,7 @@ def get_sample_yaml_str(models: list[str]) -> str:
123124
124125
125126def get_model_str (model : str ) -> str :
127+ current_time = int (time .time () * 1000 )
126128 return f"""
127129- name: { model }
128130 description: test description.
@@ -135,6 +137,8 @@ def get_model_str(model: str) -> str:
135137 libraryName: transformers
136138 artifacts:
137139 - uri: https://huggingface.co/{ model } /resolve/main/consolidated.safetensors
140+ createTimeSinceEpoch: \" { str (current_time - 10000 )} \"
141+ lastUpdateTimeSinceEpoch: \" { str (current_time )} \"
138142"""
139143
140144
@@ -149,3 +153,7 @@ def get_validate_default_model_catalog_source(token: str, model_catalog_url: str
149153 assert result [0 ]["id" ] == DEFAULT_CATALOG_ID
150154 assert result [0 ]["name" ] == DEFAULT_CATALOG_NAME
151155 assert str (result [0 ]["enabled" ]) == "True" , result [0 ]["enabled" ]
156+
157+
158+ def get_default_model_catalog_yaml (config_map : ConfigMap ) -> str :
159+ return yaml .safe_load (config_map .instance .data ["sources.yaml" ])["catalogs" ]
0 commit comments