Skip to content

Commit 5cf42d6

Browse files
fix(core): propagate title of a query to report fetcher
When query is provide as a text (and not QueryElements object) the information on it's title is lost in executor (despite being provided).
1 parent 8d104db commit 5cf42d6

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

libs/core/garf/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
'ApiReportFetcher',
2727
]
2828

29-
__version__ = '1.0.1'
29+
__version__ = '1.0.2'

libs/core/garf/core/report_fetcher.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ async def afetch(
122122
self,
123123
query_specification: str | query_editor.QuerySpecification,
124124
args: query_editor.GarfQueryParameters | None = None,
125+
title: str | None = None,
125126
**kwargs: str,
126127
) -> report.GarfReport:
127128
"""Asynchronously fetches data from API based on query_specification.
@@ -130,19 +131,21 @@ async def afetch(
130131
query_specification: Query text that will be passed to API
131132
alongside column_names, customizers and virtual columns.
132133
args: Arguments that need to be passed to the query.
134+
title: Optional title of the query.
133135
134136
Returns:
135137
GarfReport with results of query execution.
136138
"""
137139
return await asyncio.to_thread(
138-
self.fetch, query_specification, args, **kwargs
140+
self.fetch, query_specification, args, title, **kwargs
139141
)
140142

141143
@tracer.start_as_current_span('fetch')
142144
def fetch(
143145
self,
144146
query_specification: str | query_editor.QuerySpecification,
145147
args: query_editor.GarfQueryParameters | None = None,
148+
title: str | None = None,
146149
**kwargs: str,
147150
) -> report.GarfReport:
148151
"""Fetches data from API based on query_specification.
@@ -151,6 +154,7 @@ def fetch(
151154
query_specification: Query text that will be passed to API
152155
alongside column_names, customizers and virtual columns.
153156
args: Arguments that need to be passed to the query.
157+
title: Optional title of the query.
154158
155159
Returns:
156160
GarfReport with results of query execution.
@@ -168,6 +172,8 @@ def fetch(
168172
args=args,
169173
)
170174
query = query_specification.generate()
175+
if not query.title:
176+
query.title = title
171177
if query.is_builtin_query:
172178
span.set_attribute('is_builtin_query', True)
173179
if not (builtin_report := self.builtin_queries.get(query.title)):

libs/executors/garf/executors/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ def setup_executor(
5757
'ApiExecutionContext',
5858
]
5959

60-
__version__ = '1.0.3'
60+
__version__ = '1.0.4'

libs/executors/garf/executors/api_executor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from __future__ import annotations
2222

2323
import logging
24+
import pathlib
2425

2526
from garf.core import report_fetcher
2627
from garf.executors import (
@@ -110,9 +111,11 @@ def execute(
110111
span.set_attribute('query.title', title)
111112
span.set_attribute('query.text', query)
112113
logger.debug('starting query %s', query)
114+
title = pathlib.Path(title).name.split('.')[0]
113115
results = self.fetcher.fetch(
114116
query_specification=query,
115117
args=context.query_parameters,
118+
title=title,
116119
**context.fetcher_parameters,
117120
)
118121
writer_clients = context.writer_clients

0 commit comments

Comments
 (0)