Skip to content

Commit

Permalink
Default to postgresql+psycopg and log warning
Browse files Browse the repository at this point in the history
Update warning

Fix

Format warning

Add typehints

Use better variable name

Signed-off-by: Job Almekinders <job.almekinders@teampicnic.com>
  • Loading branch information
job-almekinders committed Jun 25, 2024
1 parent 38a376f commit b94fb44
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sdk/python/feast/repo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
StrictInt,
StrictStr,
ValidationError,
ValidationInfo,
field_validator,
model_validator,
)
Expand Down Expand Up @@ -128,6 +129,21 @@ class RegistryConfig(FeastBaseModel):
sqlalchemy_config_kwargs: Dict[str, Any] = {}
""" Dict[str, Any]: Extra arguments to pass to SQLAlchemy.create_engine. """

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


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

0 comments on commit b94fb44

Please sign in to comment.