def _ingest_test_getfeaturetable_mocked_resp(file_url: str, date_partition_col: str = None): return GetFeatureTableResponse(table=FeatureTableProto( spec=FeatureTableSpecProto( name="ingest_featuretable", max_age=Duration(seconds=3600), features=[ FeatureSpecProto( name="dev_feature_float", value_type=ValueProto.ValueType.FLOAT, ), FeatureSpecProto( name="dev_feature_string", value_type=ValueProto.ValueType.STRING, ), ], entities=["dev_entity"], batch_source=DataSourceProto( file_options=DataSourceProto.FileOptions( file_format=ParquetFormat().to_proto(), file_url=file_url), event_timestamp_column="datetime", created_timestamp_column="timestamp", date_partition_column=date_partition_col if date_partition_col is not None else None, ), ), meta=FeatureTableMetaProto(), ))
def to_proto(self) -> FeatureTableProto: """ Converts an feature table object to its protobuf representation Returns: FeatureTableProto protobuf """ meta = FeatureTableMetaProto( created_timestamp=self.created_timestamp, last_updated_timestamp=self.last_updated_timestamp, ) spec = FeatureTableSpecProto( name=self.name, entities=self.entities, features=[ feature.to_proto() if type(feature) == Feature else feature for feature in self.features ], labels=self.labels, max_age=self.max_age, batch_source=(self.batch_source.to_proto() if issubclass( type(self.batch_source), DataSource) else self.batch_source), stream_source=(self.stream_source.to_proto() if issubclass( type(self.stream_source), DataSource) else self.stream_source), ) return FeatureTableProto(spec=spec, meta=meta)
def to_proto(self) -> FeatureTableProto: """ Converts an feature table object to its protobuf representation Returns: FeatureTableProto protobuf """ meta = FeatureTableMetaProto( created_timestamp=self.created_timestamp, last_updated_timestamp=self.last_updated_timestamp, ) return FeatureTableProto(spec=self.to_spec_proto(), meta=meta)
def ApplyFeatureTable(self, request: ApplyFeatureTableRequest, context): feature_table_spec = request.table_spec feature_table_meta = FeatureTableMeta( created_timestamp=Timestamp(seconds=10), ) applied_feature_table = FeatureTableProto(spec=feature_table_spec, meta=feature_table_meta) self._feature_tables[feature_table_spec.name] = applied_feature_table _logger.info("registered feature table " + feature_table_spec.name + " with " + str(len(feature_table_spec.entities)) + " entities and " + str(len(feature_table_spec.features)) + " features") return ApplyFeatureTableResponse(table=applied_feature_table, )
def from_dict(cls, ft_dict): """ Creates a feature table from a dict Args: ft_dict: A dict representation of a feature table Returns: Returns a FeatureTable object based on the feature table dict """ feature_table_proto = json_format.ParseDict( ft_dict, FeatureTableProto(), ignore_unknown_fields=True ) return cls.from_proto(feature_table_proto)
def to_proto(self) -> FeatureTableProto: """ Converts an feature table object to its protobuf representation Returns: FeatureTableProto protobuf """ meta = FeatureTableMetaProto( created_timestamp=self.created_timestamp, last_updated_timestamp=self.last_updated_timestamp, ) spec = FeatureTableSpecProto( name=self.name, entities=self.entities, features=self.features, labels=self.labels, max_age=self.max_age, batch_source=self.batch_source, stream_source=self.stream_source, ) return FeatureTableProto(spec=spec, meta=meta)