Skip to content

Commit

Permalink
Make CLI apply in local mode idempotent (#1401)
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Avdeev <oleg.v.avdeev@gmail.com>
  • Loading branch information
oavdeev authored Mar 21, 2021
1 parent beb30b7 commit 3ae52ff
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sdk/python/feast/infra/local_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def update_infra(
f"CREATE TABLE IF NOT EXISTS {_table_id(project, table)} (entity_key BLOB, feature_name TEXT, value BLOB, event_ts timestamp, created_ts timestamp, PRIMARY KEY(entity_key, feature_name))"
)
conn.execute(
f"CREATE INDEX {_table_id(project, table)}_ek ON {_table_id(project, table)} (entity_key);"
f"CREATE INDEX IF NOT EXISTS {_table_id(project, table)}_ek ON {_table_id(project, table)} (entity_key);"
)

for table in tables_to_delete:
Expand Down
4 changes: 4 additions & 0 deletions sdk/python/tests/cli/test_cli_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def test_basic(self) -> None:
result = runner.run(["apply", str(repo_path)], cwd=repo_path)
assert result.returncode == 0

# Doing another apply should be a no op, and should not cause errors
result = runner.run(["apply", str(repo_path)], cwd=repo_path)
assert result.returncode == 0

basic_rw_test(repo_path, "foo")

result = runner.run(["teardown", str(repo_path)], cwd=repo_path)
Expand Down
4 changes: 4 additions & 0 deletions sdk/python/tests/cli/test_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def test_basic(self) -> None:
result = runner.run(["apply", str(repo_path)], cwd=repo_path)
assert result.returncode == 0

# Doing another apply should be a no op, and should not cause errors
result = runner.run(["apply", str(repo_path)], cwd=repo_path)
assert result.returncode == 0

basic_rw_test(repo_path, project_name=self._project_id)

result = runner.run(["teardown", str(repo_path)], cwd=repo_path)
Expand Down

0 comments on commit 3ae52ff

Please sign in to comment.