From cb6d955fdaf10143ade3ec434f4c044c81278d87 Mon Sep 17 00:00:00 2001 From: tandede <1090179959@qq.com> Date: Fri, 21 Aug 2026 15:16:49 +0800 Subject: [PATCH] fix: Support SQL registry dump Signed-off-by: tandede <1090179959@qq.com> --- sdk/python/feast/repo_operations.py | 12 ++----- .../test_repo_operations_registry_dump.py | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 sdk/python/tests/unit/test_repo_operations_registry_dump.py diff --git a/sdk/python/feast/repo_operations.py b/sdk/python/feast/repo_operations.py index 02747ac4b54..f09fd252354 100644 --- a/sdk/python/feast/repo_operations.py +++ b/sdk/python/feast/repo_operations.py @@ -26,7 +26,7 @@ from feast.feature_view import DUMMY_ENTITY, FeatureView from feast.file_utils import replace_str_in_file from feast.infra.registry.base_registry import BaseRegistry -from feast.infra.registry.registry import FEAST_OBJECT_TYPES, FeastObjectType, Registry +from feast.infra.registry.registry import FEAST_OBJECT_TYPES, FeastObjectType from feast.labeling.label_view import LabelView from feast.names import adjectives, animals from feast.on_demand_feature_view import OnDemandFeatureView @@ -544,15 +544,9 @@ def teardown(repo_config: RepoConfig, repo_path: Optional[str]): def registry_dump(repo_config: RepoConfig, repo_path: Path) -> str: """For debugging only: output contents of the metadata registry""" - registry_config = repo_config.registry project = repo_config.project - registry = Registry( - project, - registry_config=registry_config, - repo_path=repo_path, - auth_config=repo_config.auth_config, - ) - registry_dict = registry.to_dict(project=project) + feature_store = FeatureStore(repo_path=str(repo_path), config=repo_config) + registry_dict = feature_store.registry.to_dict(project=project) return json.dumps(registry_dict, indent=2, sort_keys=True) diff --git a/sdk/python/tests/unit/test_repo_operations_registry_dump.py b/sdk/python/tests/unit/test_repo_operations_registry_dump.py new file mode 100644 index 00000000000..f45995d2158 --- /dev/null +++ b/sdk/python/tests/unit/test_repo_operations_registry_dump.py @@ -0,0 +1,36 @@ +from __future__ import annotations + +import json + +from feast import Entity, FeatureStore +from feast.infra.registry.sql import SqlRegistryConfig +from feast.repo_config import RepoConfig +from feast.repo_operations import registry_dump +from feast.value_type import ValueType + + +def test_registry_dump_uses_configured_sql_registry(tmp_path): + project = "test_project" + config = RepoConfig( + project=project, + registry=SqlRegistryConfig(path=f"sqlite:///{tmp_path / 'registry.db'}"), + provider="local", + online_store={"type": "sqlite", "path": str(tmp_path / "online.db")}, + offline_store={"type": "file"}, + ) + store = FeatureStore(repo_path=tmp_path, config=config) + store.registry.apply_entity( + Entity( + name="driver", + join_keys=["driver_id"], + value_type=ValueType.INT64, + ), + project, + ) + + dumped_registry = json.loads(registry_dump(config, tmp_path)) + + assert dumped_registry["project"] == project + assert [entity["spec"]["name"] for entity in dumped_registry["entities"]] == [ + "driver" + ]