Skip to content

Commit 158fe0c

Browse files
committed
validation output changes
1 parent ca61db6 commit 158fe0c

File tree

5 files changed

+36
-11
lines changed

5 files changed

+36
-11
lines changed

ads/feature_store/dataset.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -887,11 +887,7 @@ def get_validation_output(self, job_id: str = None) -> "ValidationOutput":
887887
validation_output = (
888888
output_details.get("validationOutput") if output_details else None
889889
)
890-
validation_output_json = (
891-
json.loads(validation_output) if validation_output else None
892-
)
893-
894-
return ValidationOutput(validation_output_json)
890+
return ValidationOutput(validation_output)
895891

896892
@classmethod
897893
def list_df(cls, compartment_id: str = None, **kwargs) -> "pandas.DataFrame":

ads/feature_store/feature_group.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,11 +1288,7 @@ def get_validation_output(self, job_id: str = None) -> "ValidationOutput":
12881288
output_details.get("validationOutput") if output_details else None
12891289
)
12901290

1291-
validation_output_json = (
1292-
json.loads(validation_output) if validation_output else None
1293-
)
1294-
1295-
return ValidationOutput(validation_output_json)
1291+
return ValidationOutput(validation_output)
12961292

12971293
def __getattr__(self, name):
12981294
try:

ads/feature_store/validation_output.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import pandas as pd
23
from typing import Dict
34
from copy import deepcopy
@@ -22,9 +23,29 @@ def to_pandas(self) -> pd.DataFrame:
2223
The validation output information as a pandas DataFrame.
2324
"""
2425
if self.content:
25-
profile_result = pd.json_normalize(self.content).transpose()
26+
validation_output_json = (
27+
json.loads(self.content)
28+
)
29+
profile_result = pd.json_normalize(validation_output_json.get("results")).transpose()
2630
return profile_result
2731

32+
def to_summary(self) -> pd.DataFrame:
33+
"""
34+
Converts the validation output summary information to a pandas DataFrame.
35+
36+
Returns
37+
-------
38+
pd.DataFrame
39+
The validation output summary information as a pandas DataFrame.
40+
"""
41+
if self.content:
42+
validation_output_json = (
43+
json.loads(self.content)
44+
)
45+
profile_result = pd.json_normalize(validation_output_json).transpose()
46+
summary_df = profile_result.drop("results")
47+
return summary_df
48+
2849
@property
2950
def kind(self) -> str:
3051
"""

tests/integration/feature_store/test_dataset_validations.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ def test_dataset_validation_operations(self):
6060
assert "success" in df.columns
6161
assert True in df["success"].values
6262

63+
df = dataset.get_validation_output().to_summary().T
64+
assert df is not None
65+
assert "success" in df.columns
66+
assert True in df["success"].values
67+
6368
self.clean_up_dataset(dataset)
6469
self.clean_up_feature_group(fg)
6570
self.clean_up_entity(entity)

tests/integration/feature_store/test_feature_group_validations.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,17 @@ def test_feature_group_validation_operations_single(self):
6868

6969
assert fg.oci_feature_group.id
7070
fg.materialise(self.data)
71+
7172
df = fg.get_validation_output().to_pandas().T
7273
assert df is not None
7374
assert "success" in df.columns
7475
assert True in df["success"].values
76+
77+
df = fg.get_validation_output().to_summary().T
78+
assert df is not None
79+
assert "success" in df.columns
80+
assert True in df["success"].values
81+
7582
self.clean_up_feature_group(fg)
7683
self.clean_up_entity(entity)
7784
self.clean_up_feature_store(fs)

0 commit comments

Comments
 (0)