Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pass api_access_token to executor client #1473

Merged
merged 3 commits into from
Jul 8, 2024
Merged
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
6 changes: 5 additions & 1 deletion querybook/server/datasources/query_execution.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime

from flask import abort, Response, redirect
from flask import abort, Response, redirect, request
from flask_login import current_user

from app.flask_app import socketio
Expand Down Expand Up @@ -72,6 +72,10 @@ def create_query_execution(
query=query, engine_id=engine_id, uid=uid, session=session
)

metadata = metadata or {}
used_api_token = request.headers.get("api-access-token") is not None
if used_api_token:
metadata["used_api_token"] = used_api_token
if metadata:
logic.create_query_execution_metadata(
query_execution.id, metadata, session=session
Expand Down
12 changes: 12 additions & 0 deletions querybook/server/lib/query_executor/base_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,18 @@ def __init__(
self._client = None
self._cursor = None

query_execution_metadata = (
qe_logic.get_query_execution_metadata_by_execution_id(
self._query_execution_id
)
)
if query_execution_metadata:
self._used_api_token = query_execution_metadata.execution_metadata.get(
"used_api_token", False
)
else:
self._used_api_token = False

def __del__(self):
del self._logger
del self._cursor
Expand Down
Loading