Skip to content

Commit 57ce096

Browse files
committed
remove the search model ids
1 parent 44eaf5e commit 57ce096

File tree

2 files changed

+13
-52
lines changed

2 files changed

+13
-52
lines changed

ads/feature_store/common/utils/utility.py

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -402,38 +402,4 @@ def convert_spark_dataframe_with_schema(
402402
def validate_input_feature_details(input_feature_details, data_frame):
403403
if isinstance(data_frame, pd.DataFrame):
404404
return convert_pandas_datatype_with_schema(input_feature_details, data_frame)
405-
return convert_spark_dataframe_with_schema(input_feature_details, data_frame)
406-
407-
408-
def validate_model_ocid_format(model_ocid):
409-
split_words = model_ocid.split('.')
410-
region = split_words[3]
411-
realm = split_words[2]
412-
print(split_words)
413-
# region = auth.get("signer").region will not work for config
414-
# TODO: try to get current region if possible??
415-
if region in oci.regions.REGIONS_SHORT_NAMES:
416-
region = oci.regions.REGIONS_SHORT_NAMES[region]
417-
elif region not in oci.regions.REGIONS:
418-
return False
419-
if realm not in oci.regions.REGION_REALMS[region]:
420-
return False
421-
return True
422-
423-
424-
def search_model_ocids(model_ids: list) -> list:
425-
query = "query datasciencemodel resources where "
426-
items = model_ids
427-
for item in items:
428-
query = query + f"identifier='{item}'||"
429-
list_models = OCIResource.search(
430-
query[:-2]
431-
, type=SEARCH_TYPE.STRUCTURED,
432-
)
433-
list_models_ids = []
434-
for model in list_models:
435-
list_models_ids.append(model.identifier)
436-
for model_id in model_ids:
437-
if model_id not in list_models_ids:
438-
logger.warning(model_id + " doesnt exist")
439-
return list_models_ids
405+
return convert_spark_dataframe_with_schema(input_feature_details, data_frame)

ads/feature_store/dataset.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
from ads.feature_store.common.utils.utility import (
1919
get_metastore_id,
2020
validate_delta_format_parameters,
21-
convert_expectation_suite_to_expectation,
22-
validate_model_ocid_format, search_model_ocids
21+
convert_expectation_suite_to_expectation
2322
)
2423
from ads.feature_store.dataset_job import DatasetJob, IngestionMode
2524
from ads.feature_store.execution_strategy.engine.spark_engine import SparkEngine
@@ -375,7 +374,7 @@ def expectation_details(self) -> "Expectation":
375374
return self.get_spec(self.CONST_EXPECTATION_DETAILS)
376375

377376
def with_expectation_suite(
378-
self, expectation_suite: ExpectationSuite, expectation_type: ExpectationType
377+
self, expectation_suite: ExpectationSuite, expectation_type: ExpectationType
379378
) -> "Dataset":
380379
"""Sets the expectation details for the feature group.
381380
@@ -446,7 +445,7 @@ def statistics_config(self, statistics_config: StatisticsConfig):
446445
self.with_statistics_config(statistics_config)
447446

448447
def with_statistics_config(
449-
self, statistics_config: Union[StatisticsConfig, bool]
448+
self, statistics_config: Union[StatisticsConfig, bool]
450449
) -> "Dataset":
451450
"""Sets the statistics details for the dataset.
452451
@@ -482,7 +481,7 @@ def model_details(self) -> "ModelDetails":
482481
def model_details(self, model_details: ModelDetails):
483482
self.with_model_details(model_details)
484483

485-
def with_model_details(self, model_details: ModelDetails,validate: bool = True) -> "Dataset":
484+
def with_model_details(self, model_details: ModelDetails) -> "Dataset":
486485
"""Sets the model details for the dataset.
487486
488487
Parameters
@@ -500,17 +499,6 @@ def with_model_details(self, model_details: ModelDetails,validate: bool = True)
500499
"The argument `model_details` has to be of type `ModelDetails`"
501500
"but is of type: `{}`".format(type(model_details))
502501
)
503-
#TODO: we could eiher use validate_model_ocid_format if thats enough or search_model_ocids
504-
#search_model_ocids should be used after set_auth without url
505-
# items = model_details["items"]
506-
# for item in items:
507-
# if not validate_model_ocid(item):
508-
# raise ValueError(
509-
# f"the model ocid {item} is not valid"
510-
# )
511-
if validate:
512-
model_ids_list = search_model_ocids(model_details.items)
513-
model_details = ModelDetails(model_ids_list)
514502

515503
return self.set_spec(self.CONST_MODEL_DETAILS, model_details.to_dict())
516504

@@ -532,7 +520,14 @@ def add_models(self, model_details: ModelDetails) -> "Dataset":
532520
for item in items:
533521
model_details.items.append(item)
534522
self.with_model_details(model_details)
535-
return self.update()
523+
self.update()
524+
525+
self._update_from_oci_dataset_model(self.oci_dataset)
526+
updated_model_details = self.model_details
527+
if updated_model_details and updated_model_details.items and model_details:
528+
for model_id in model_details.items:
529+
if model_id not in updated_model_details["items"]:
530+
logger.warning("Model Id" + model_id + " doesnt exist or you do not have the permission")
536531

537532
def remove_models(self, model_details: ModelDetails) -> "Dataset":
538533
"""remove model details from the dataset, remove from the existing dataset model id list

0 commit comments

Comments
 (0)