def test_feature_table_import_export_yaml(self): batch_source = DataSource( type=SourceType(1).name, field_mapping={ "ride_distance": "ride_distance", "ride_duration": "ride_duration", }, options=FileOptions(file_format="avro", file_url="data/test.avro"), timestamp_column="ts_col", date_partition_column="date_partition_col", ) stream_source = DataSource( type=SourceType(3).name, field_mapping={ "ride_distance": "ride_distance", "ride_duration": "ride_duration", }, options=KafkaOptions( bootstrap_servers="localhost:9094", class_path="random/path/to/class", topic="test_topic", ), timestamp_column="ts_col", ) test_feature_table = FeatureTable( name="car_driver", features=[ FeatureV2(name="ride_distance", dtype=ValueType.FLOAT).to_proto(), FeatureV2(name="ride_duration", dtype=ValueType.STRING).to_proto(), ], entities=["car_driver_entity"], labels={"team": "matchmaking"}, batch_source=batch_source.to_proto(), stream_source=stream_source.to_proto(), ) # Create a string YAML representation of the feature table string_yaml = test_feature_table.to_yaml() # Create a new feature table object from the YAML string actual_feature_table_from_string = FeatureTable.from_yaml(string_yaml) # Ensure equality is upheld to original feature table assert test_feature_table == actual_feature_table_from_string
def apply_data_source(self, data_source: DataSource, project: str, commit: bool = True): """ Registers a single data source with Feast Args: data_source: A data source that will be registered project: Feast project that this data source belongs to commit: Whether to immediately commit to the registry """ registry = self._prepare_registry_for_changes() for idx, existing_data_source_proto in enumerate( registry.data_sources): if existing_data_source_proto.name == data_source.name: del registry.data_sources[idx] data_source_proto = data_source.to_proto() data_source_proto.data_source_class_type = ( f"{data_source.__class__.__module__}.{data_source.__class__.__name__}" ) data_source_proto.project = project data_source_proto.data_source_class_type = ( f"{data_source.__class__.__module__}.{data_source.__class__.__name__}" ) registry.data_sources.append(data_source_proto) if commit: self.commit()