Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sdk/python/feast/repo_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@

logger = logging.getLogger(__name__)

_SQLITE_ONLINE_STORE_TEMPLATES = frozenset(
{"athena", "aws", "gcp", "local", "minimal", "pytorch_nlp", "ray", "spark"}
)


def py_path_to_module(path: Path) -> str:
return (
Expand Down Expand Up @@ -580,6 +584,12 @@ def init_repo(repo_name: str, template: str, repo_path: Optional[str] = None):
param_hint="PROJECT_DIRECTORY",
)

if "-" in repo_name and template.lower() in _SQLITE_ONLINE_STORE_TEMPLATES:
raise BadParameter(
message="Project names for SQLite online stores cannot contain hyphens because they are used in table names.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angelo-lacson Thanks for PR, this looks good!

Can you also consider a shared helper with repo_config._validate_project_name so the error message and SQLite rule stay in one place ? Currently there is duplication of error messages between this and #5749

param_hint="PROJECT_DIRECTORY",
)

# Determine where to create the repository
if repo_path:
# User specified a custom path
Expand Down
12 changes: 12 additions & 0 deletions sdk/python/tests/unit/local_feast_tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,15 @@ def test_postgres_template_registry_path_is_parameterized() -> None:
contents = template_fs_yaml.read_text(encoding="utf-8")
expected = "path: postgresql://DB_USERNAME:DB_PASSWORD@DB_HOST:DB_PORT/DB_NAME"
assert expected in contents


def test_repo_init_rejects_hyphenated_sqlite_project_name() -> None:
with tempfile.TemporaryDirectory() as temp_dir:
temp_path = Path(temp_dir)
runner = CliRunner()

result = runner.run(["init", "hyphen-name"], cwd=temp_path)

assert result.returncode != 0
assert "SQLite online stores cannot contain hyphens" in result.stderr.decode()
assert not (temp_path / "hyphen-name").exists()
Loading