Skip to content

Commit b60f9c7

Browse files
tandedeshuchu
authored andcommitted
fix: Support SQL registry dump
Signed-off-by: tandede <[email protected]>
1 parent ae6b297 commit b60f9c7

2 files changed

Lines changed: 39 additions & 9 deletions

File tree

‎sdk/python/feast/repo_operations.py‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from feast.feature_view import DUMMY_ENTITY, FeatureView
2727
from feast.file_utils import replace_str_in_file
2828
from feast.infra.registry.base_registry import BaseRegistry
29-
from feast.infra.registry.registry import FEAST_OBJECT_TYPES, FeastObjectType, Registry
29+
from feast.infra.registry.registry import FEAST_OBJECT_TYPES, FeastObjectType
3030
from feast.labeling.label_view import LabelView
3131
from feast.names import adjectives, animals
3232
from feast.on_demand_feature_view import OnDemandFeatureView
@@ -544,15 +544,9 @@ def teardown(repo_config: RepoConfig, repo_path: Optional[str]):
544544

545545
def registry_dump(repo_config: RepoConfig, repo_path: Path) -> str:
546546
"""For debugging only: output contents of the metadata registry"""
547-
registry_config = repo_config.registry
548547
project = repo_config.project
549-
registry = Registry(
550-
project,
551-
registry_config=registry_config,
552-
repo_path=repo_path,
553-
auth_config=repo_config.auth_config,
554-
)
555-
registry_dict = registry.to_dict(project=project)
548+
feature_store = FeatureStore(repo_path=str(repo_path), config=repo_config)
549+
registry_dict = feature_store.registry.to_dict(project=project)
556550
return json.dumps(registry_dict, indent=2, sort_keys=True)
557551

558552

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from __future__ import annotations
2+
3+
import json
4+
5+
from feast import Entity, FeatureStore
6+
from feast.infra.registry.sql import SqlRegistryConfig
7+
from feast.repo_config import RepoConfig
8+
from feast.repo_operations import registry_dump
9+
from feast.value_type import ValueType
10+
11+
12+
def test_registry_dump_uses_configured_sql_registry(tmp_path):
13+
project = "test_project"
14+
config = RepoConfig(
15+
project=project,
16+
registry=SqlRegistryConfig(path=f"sqlite:///{tmp_path / 'registry.db'}"),
17+
provider="local",
18+
online_store={"type": "sqlite", "path": str(tmp_path / "online.db")},
19+
offline_store={"type": "file"},
20+
)
21+
store = FeatureStore(repo_path=tmp_path, config=config)
22+
store.registry.apply_entity(
23+
Entity(
24+
name="driver",
25+
join_keys=["driver_id"],
26+
value_type=ValueType.INT64,
27+
),
28+
project,
29+
)
30+
31+
dumped_registry = json.loads(registry_dump(config, tmp_path))
32+
33+
assert dumped_registry["project"] == project
34+
assert [entity["spec"]["name"] for entity in dumped_registry["entities"]] == [
35+
"driver"
36+
]

0 commit comments

Comments
 (0)