From a935be7818dd4961f01e29fcdc28cebcd57055a7 Mon Sep 17 00:00:00 2001 From: Hai Nguyen Date: Wed, 11 Oct 2023 14:31:02 +0700 Subject: [PATCH] chore: Minor refactor Signed-off-by: Hai Nguyen --- .../contrib/hbase_online_store/hbase.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sdk/python/feast/infra/online_stores/contrib/hbase_online_store/hbase.py b/sdk/python/feast/infra/online_stores/contrib/hbase_online_store/hbase.py index a900b4dcac3..59f5c58ff79 100644 --- a/sdk/python/feast/infra/online_stores/contrib/hbase_online_store/hbase.py +++ b/sdk/python/feast/infra/online_stores/contrib/hbase_online_store/hbase.py @@ -104,7 +104,7 @@ def online_write_batch( hbase = HbaseUtils(self._get_conn(config)) project = config.project - table_name = _table_id(project, table) + table_name = self._table_id(project, table) b = hbase.batch(table_name) for entity_key, values, timestamp, created_ts in data: @@ -134,6 +134,7 @@ def online_write_batch( b.put(row_key, values_dict) b.send() + progress(len(data)) @log_exceptions_and_usage(online_store="hbase") def online_read( self, @@ -153,7 +154,7 @@ def online_read( """ hbase = HbaseUtils(self._get_conn(config)) project = config.project - table_name = _table_id(project, table) + table_name = self._table_id(project, table) result: List[Tuple[Optional[datetime], Optional[Dict[str, ValueProto]]]] = [] @@ -208,12 +209,12 @@ def update( # We don't create any special state for the entites in this implementation. for table in tables_to_keep: - table_name = _table_id(project, table) + table_name = self._table_id(project, table) if not hbase.check_if_table_exist(table_name): hbase.create_table_with_default_cf(table_name) for table in tables_to_delete: - table_name = _table_id(project, table) + table_name = self._table_id(project, table) hbase.delete_table(table_name) def teardown( @@ -233,7 +234,7 @@ def teardown( project = config.project for table in tables: - table_name = _table_id(project, table) + table_name = self._table_id(project, table) hbase.delete_table(table_name) def _hbase_row_key( @@ -264,13 +265,12 @@ def _hbase_row_key( # colocated. return f"{entity_id}#{feature_view_name}".encode() + def _table_id(self, project: str, table: FeatureView) -> str: + """ + Returns table name given the project_name and the feature_view. -def _table_id(project: str, table: FeatureView) -> str: - """ - Returns table name given the project_name and the feature_view. - - Args: - project: Name of the feast project. - table: Feast FeatureView. - """ - return f"{project}_{table.name}" + Args: + project: Name of the feast project. + table: Feast FeatureView. + """ + return f"{project}_{table.name}"