feat: aggregations in structured views #480
GitHub Actions / JUnit Test Report
failed
Jul 18, 2024 in 0s
94 tests run, 92 passed, 0 skipped, 2 failed.
Annotations
Check failure on line 291 in tests/unit/test_collection.py
github-actions / JUnit Test Report
test_collection.test_ask_view_selection_single_view
dbally.iql._exceptions.IQLSyntaxError: Syntax error in: mock response
Raw output
self = <dbally.iql._processor.IQLProcessor object at 0x7f5da0edb940>
async def process(self) -> syntax.Node:
"""
Process IQL string to root IQL.Node.
Returns:
IQL node which is root of the tree representing IQL query.
Raises:
IQLError: If parsing fails.
"""
self.source = self._to_lower_except_in_quotes(self.source, ["AND", "OR", "NOT"])
try:
> ast_tree = ast.parse(self.source)
src/dbally/iql/_processor.py:48:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
source = 'mock response', filename = '<unknown>', mode = 'exec'
def parse(source, filename='<unknown>', mode='exec', *,
type_comments=False, feature_version=None):
"""
Parse the source into an AST node.
Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).
Pass type_comments=True to get back type comments where the syntax allows.
"""
flags = PyCF_ONLY_AST
if type_comments:
flags |= PyCF_TYPE_COMMENTS
if isinstance(feature_version, tuple):
major, minor = feature_version # Should be a 2-tuple.
assert major == 3
feature_version = minor
elif feature_version is None:
feature_version = -1
# Else it should be an int giving the minor version for 3.x.
> return compile(source, filename, mode, flags,
_feature_version=feature_version)
E File "<unknown>", line 1
E mock response
E ^
E SyntaxError: invalid syntax
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/ast.py:47: SyntaxError
The above exception was the direct cause of the following exception:
async def test_ask_view_selection_single_view() -> None:
"""
Tests that the ask method select view correctly when there is only one view
"""
collection = Collection(
"foo",
view_selector=MockViewSelector(""),
llm=MockLLM(),
nl_responder=AsyncMock(),
event_handlers=[],
)
collection.add(MockViewWithResults)
> result = await collection.ask("Mock question")
tests/unit/test_collection.py:291:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/dbally/collection/collection.py:204: in ask
view_result = await view.ask(
src/dbally/views/structured.py:92: in ask
agg_node = await agg_formatter.format_to_query_object(
src/dbally/prompt/aggregation.py:82: in format_to_query_object
return await IQLQuery.parse(
src/dbally/iql/_query.py:46: in parse
root = await IQLProcessor(source, allowed_functions, event_tracker=event_tracker).process()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <dbally.iql._processor.IQLProcessor object at 0x7f5da0edb940>
async def process(self) -> syntax.Node:
"""
Process IQL string to root IQL.Node.
Returns:
IQL node which is root of the tree representing IQL query.
Raises:
IQLError: If parsing fails.
"""
self.source = self._to_lower_except_in_quotes(self.source, ["AND", "OR", "NOT"])
try:
ast_tree = ast.parse(self.source)
except (SyntaxError, ValueError) as exc:
> raise IQLSyntaxError(self.source) from exc
E dbally.iql._exceptions.IQLSyntaxError: Syntax error in: mock response
src/dbally/iql/_processor.py:50: IQLSyntaxError
Check failure on line 312 in tests/unit/test_collection.py
github-actions / JUnit Test Report
test_collection.test_ask_view_selection_multiple_views
dbally.iql._exceptions.IQLSyntaxError: Syntax error in: mock response
Raw output
self = <dbally.iql._processor.IQLProcessor object at 0x7f5da0f258b0>
async def process(self) -> syntax.Node:
"""
Process IQL string to root IQL.Node.
Returns:
IQL node which is root of the tree representing IQL query.
Raises:
IQLError: If parsing fails.
"""
self.source = self._to_lower_except_in_quotes(self.source, ["AND", "OR", "NOT"])
try:
> ast_tree = ast.parse(self.source)
src/dbally/iql/_processor.py:48:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
source = 'mock response', filename = '<unknown>', mode = 'exec'
def parse(source, filename='<unknown>', mode='exec', *,
type_comments=False, feature_version=None):
"""
Parse the source into an AST node.
Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).
Pass type_comments=True to get back type comments where the syntax allows.
"""
flags = PyCF_ONLY_AST
if type_comments:
flags |= PyCF_TYPE_COMMENTS
if isinstance(feature_version, tuple):
major, minor = feature_version # Should be a 2-tuple.
assert major == 3
feature_version = minor
elif feature_version is None:
feature_version = -1
# Else it should be an int giving the minor version for 3.x.
> return compile(source, filename, mode, flags,
_feature_version=feature_version)
E File "<unknown>", line 1
E mock response
E ^
E SyntaxError: invalid syntax
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/ast.py:47: SyntaxError
The above exception was the direct cause of the following exception:
async def test_ask_view_selection_multiple_views() -> None:
"""
Tests that the ask method select view correctly when there are multiple views
"""
collection = Collection(
"foo",
view_selector=MockViewSelector("MockViewWithResults"),
llm=MockLLM(),
nl_responder=AsyncMock(),
event_handlers=[],
)
collection.add(MockView1)
collection.add(MockViewWithResults)
collection.add(MockView2)
> result = await collection.ask("Mock question")
tests/unit/test_collection.py:312:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/dbally/collection/collection.py:204: in ask
view_result = await view.ask(
src/dbally/views/structured.py:92: in ask
agg_node = await agg_formatter.format_to_query_object(
src/dbally/prompt/aggregation.py:82: in format_to_query_object
return await IQLQuery.parse(
src/dbally/iql/_query.py:46: in parse
root = await IQLProcessor(source, allowed_functions, event_tracker=event_tracker).process()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <dbally.iql._processor.IQLProcessor object at 0x7f5da0f258b0>
async def process(self) -> syntax.Node:
"""
Process IQL string to root IQL.Node.
Returns:
IQL node which is root of the tree representing IQL query.
Raises:
IQLError: If parsing fails.
"""
self.source = self._to_lower_except_in_quotes(self.source, ["AND", "OR", "NOT"])
try:
ast_tree = ast.parse(self.source)
except (SyntaxError, ValueError) as exc:
> raise IQLSyntaxError(self.source) from exc
E dbally.iql._exceptions.IQLSyntaxError: Syntax error in: mock response
src/dbally/iql/_processor.py:50: IQLSyntaxError
Loading