Load logged features from an offline store and validate them against provided validation reference. Args: source: Logs source object (currently only feature services are supported) start: lower bound for loading logged features end: upper bound
(
self,
source: FeatureService,
start: datetime,
end: datetime,
reference: ValidationReference,
throw_exception: bool = True,
cache_profile: bool = True,
)
| 4064 | ) |
| 4065 | |
| 4066 | def validate_logged_features( |
| 4067 | self, |
| 4068 | source: FeatureService, |
| 4069 | start: datetime, |
| 4070 | end: datetime, |
| 4071 | reference: ValidationReference, |
| 4072 | throw_exception: bool = True, |
| 4073 | cache_profile: bool = True, |
| 4074 | ) -> Optional[ValidationFailed]: |
| 4075 | """ |
| 4076 | Load logged features from an offline store and validate them against provided validation reference. |
| 4077 | |
| 4078 | Args: |
| 4079 | source: Logs source object (currently only feature services are supported) |
| 4080 | start: lower bound for loading logged features |
| 4081 | end: upper bound for loading logged features |
| 4082 | reference: validation reference |
| 4083 | throw_exception: throw exception or return it as a result |
| 4084 | cache_profile: store cached profile in Feast registry |
| 4085 | |
| 4086 | Returns: |
| 4087 | Throw or return (depends on parameter) ValidationFailed exception if validation was not successful |
| 4088 | or None if successful. |
| 4089 | |
| 4090 | """ |
| 4091 | if not flags_helper.is_test(): |
| 4092 | warnings.warn( |
| 4093 | "Logged features validation is an experimental feature. " |
| 4094 | "This API is unstable and it could and most probably will be changed in the future. " |
| 4095 | "We do not guarantee that future changes will maintain backward compatibility.", |
| 4096 | RuntimeWarning, |
| 4097 | ) |
| 4098 | |
| 4099 | if not isinstance(source, FeatureService): |
| 4100 | raise ValueError("Only feature service is currently supported as a source") |
| 4101 | |
| 4102 | j = self._get_provider().retrieve_feature_service_logs( |
| 4103 | feature_service=source, |
| 4104 | start_date=start, |
| 4105 | end_date=end, |
| 4106 | config=self.config, |
| 4107 | registry=self.registry, |
| 4108 | ) |
| 4109 | |
| 4110 | # read and run validation |
| 4111 | try: |
| 4112 | t = j.to_arrow(validation_reference=reference) |
| 4113 | except ValidationFailed as exc: |
| 4114 | if throw_exception: |
| 4115 | raise |
| 4116 | |
| 4117 | return exc |
| 4118 | else: |
| 4119 | print(f"{t.shape[0]} rows were validated.") |
| 4120 | |
| 4121 | if cache_profile: |
| 4122 | self.apply(reference) |
| 4123 |