8
8
9
9
import pandas
10
10
from great_expectations .core import ExpectationSuite
11
+ from oci .feature_store .models import (
12
+ DatasetFeatureGroupCollection ,
13
+ DatasetFeatureGroupSummary ,
14
+ )
15
+
11
16
from ads .common import utils
12
17
from ads .common .oci_mixin import OCIModelMixin
13
18
from ads .feature_store .common .enums import (
26
31
OciExecutionStrategyProvider ,
27
32
)
28
33
from ads .feature_store .feature import DatasetFeature
34
+ from ads .feature_store .feature_group import FeatureGroup
29
35
from ads .feature_store .feature_group_expectation import Expectation
30
36
from ads .feature_store .feature_option_details import FeatureOptionDetails
31
37
from ads .feature_store .service .oci_dataset import OCIDataset
@@ -113,6 +119,7 @@ class Dataset(Builder):
113
119
CONST_ITEMS = "items"
114
120
CONST_LAST_JOB_ID = "jobId"
115
121
CONST_MODEL_DETAILS = "modelDetails"
122
+ CONST_FEATURE_GROUP = "datasetFeatureGroups"
116
123
117
124
attribute_map = {
118
125
CONST_ID : "id" ,
@@ -130,6 +137,7 @@ class Dataset(Builder):
130
137
CONST_LIFECYCLE_STATE : "lifecycle_state" ,
131
138
CONST_MODEL_DETAILS : "model_details" ,
132
139
CONST_PARTITION_KEYS : "partition_keys" ,
140
+ CONST_FEATURE_GROUP : "dataset_feature_groups" ,
133
141
}
134
142
135
143
def __init__ (self , spec : Dict = None , ** kwargs ) -> None :
@@ -503,6 +511,44 @@ def with_model_details(self, model_details: ModelDetails) -> "Dataset":
503
511
504
512
return self .set_spec (self .CONST_MODEL_DETAILS , model_details .to_dict ())
505
513
514
+ @property
515
+ def feature_groups (self ) -> List ["FeatureGroup" ]:
516
+ collection : "DatasetFeatureGroupCollection" = self .get_spec (
517
+ self .CONST_FEATURE_GROUP
518
+ )
519
+ feature_groups : List ["FeatureGroup" ] = []
520
+ if collection :
521
+ for datasetFGSummary in collection .items :
522
+ feature_groups .append (
523
+ FeatureGroup .from_id (datasetFGSummary .feature_group_id )
524
+ )
525
+
526
+ return feature_groups
527
+
528
+ @feature_groups .setter
529
+ def feature_groups (self , feature_groups : List ["FeatureGroup" ]):
530
+ self .with_feature_groups (feature_groups )
531
+
532
+ def with_feature_groups (self , feature_groups : List ["FeatureGroup" ]) -> "Dataset" :
533
+ """Sets the model details for the dataset.
534
+
535
+ Parameters
536
+ ----------
537
+ feature_groups: List of feature groups
538
+ Returns
539
+ -------
540
+ Dataset
541
+ The Dataset instance (self).
542
+
543
+ """
544
+ collection : List ["DatasetFeatureGroupSummary" ] = []
545
+ for group in feature_groups :
546
+ collection .append (DatasetFeatureGroupSummary (feature_group_id = group .id ))
547
+
548
+ return self .set_spec (
549
+ self .CONST_FEATURE_GROUP , DatasetFeatureGroupCollection (items = collection )
550
+ )
551
+
506
552
@property
507
553
def partition_keys (self ) -> List [str ]:
508
554
return self .get_spec (self .CONST_PARTITION_KEYS )
@@ -560,7 +606,9 @@ def add_models(self, model_details: ModelDetails) -> "Dataset":
560
606
f"Dataset update Failed with : { type (ex )} with error message: { ex } "
561
607
)
562
608
if existing_model_details :
563
- self .with_model_details (ModelDetails ().with_items (existing_model_details ["items" ]))
609
+ self .with_model_details (
610
+ ModelDetails ().with_items (existing_model_details ["items" ])
611
+ )
564
612
else :
565
613
self .with_model_details (ModelDetails ().with_items ([]))
566
614
return self
0 commit comments