Skip to content

Commit

Permalink
Raise notimplemented for stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
greenape committed Nov 5, 2024
1 parent 7075c4e commit 4287e60
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
10 changes: 6 additions & 4 deletions flowmachine/flowmachine/core/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,12 @@ def write_cache_metadata(
)

if not in_cache:
logger.debug("Writing dependencies",
query_id=query.query_id,
dependencies=query.dependencies,
stored_dependencies=query._get_stored_dependencies(exclude_self=True))
logger.debug(
"Writing dependencies",
query_id=query.query_id,
dependencies=query.dependencies,
stored_dependencies=query._get_stored_dependencies(exclude_self=True),
)
for dep in query._get_stored_dependencies(exclude_self=True):
connection.exec_driver_sql(
"INSERT INTO cache.dependencies values (%(query_id)s, %(dep_id)s) ON CONFLICT DO NOTHING",
Expand Down
29 changes: 23 additions & 6 deletions flowmachine/flowmachine/core/query_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
class QStub(Query):
"""
A stub representation of a Query object used for version-aware caching.
This class serves as a lightweight placeholder for cached queries,
particularly when handling queries from different versions.
"""

def __init__(self, deps: list["Query"], qid: str) -> None:
"""
Parameters
Expand All @@ -25,9 +25,26 @@ def __init__(self, deps: list["Query"], qid: str) -> None:
self.deps = deps
self._md5 = qid
super().__init__()
def _make_query(self):
pass

def _make_query(self) -> str:
"""
Not implemented for stub queries.
Raises
------
NotImplementedError
Always, as stub queries cannot generate SQL.
"""
raise NotImplementedError("Stub queries cannot generate SQL")

Check warning on line 38 in flowmachine/flowmachine/core/query_stub.py

View check run for this annotation

Codecov / codecov/patch

flowmachine/flowmachine/core/query_stub.py#L38

Added line #L38 was not covered by tests

@property
def column_names(self):
pass
def column_names(self) -> list[str]:
"""
Not implemented for stub queries.
Raises
------
NotImplementedError
Always, as stub queries cannot generate SQL.
"""
raise NotImplementedError("Stub queries cannot provide column names.")

Check warning on line 50 in flowmachine/flowmachine/core/query_stub.py

View check run for this annotation

Codecov / codecov/patch

flowmachine/flowmachine/core/query_stub.py#L50

Added line #L50 was not covered by tests

0 comments on commit 4287e60

Please sign in to comment.