Skip to content

Commit b94fb44

Browse files
Default to postgresql+psycopg and log warning
Update warning Fix Format warning Add typehints Use better variable name Signed-off-by: Job Almekinders <job.almekinders@teampicnic.com>
1 parent 38a376f commit b94fb44

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sdk/python/feast/repo_config.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
StrictInt,
1313
StrictStr,
1414
ValidationError,
15+
ValidationInfo,
1516
field_validator,
1617
model_validator,
1718
)
@@ -128,6 +129,21 @@ class RegistryConfig(FeastBaseModel):
128129
sqlalchemy_config_kwargs: Dict[str, Any] = {}
129130
""" Dict[str, Any]: Extra arguments to pass to SQLAlchemy.create_engine. """
130131

132+
@field_validator("path")
133+
def validate_path(cls, path: str, values: ValidationInfo) -> str:
134+
if values.data.get("registry_type") == "sql":
135+
if path.startswith("postgresql://"):
136+
_logger.warning(
137+
"The `path` of the `RegistryConfig` starts with a plain "
138+
"`postgresql` string. We are updating this to `postgresql+psycopg` "
139+
"to ensure that the `psycopg3` driver is used by `sqlalchemy`. If "
140+
"you want to use `psycopg2` pass `postgresql+psycopg2` explicitely "
141+
"to `path`. To silence this warning, pass `postgresql+psycopg` "
142+
"explicitely to `path`."
143+
)
144+
return path.replace("postgresql://", "postgresql+psycopg://")
145+
return path
146+
131147

132148
class RepoConfig(FeastBaseModel):
133149
"""Repo config. Typically loaded from `feature_store.yaml`"""

0 commit comments

Comments
 (0)