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

DO NOT MERGE PoC(tableau): codegen PoC #12491

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion metadata-ingestion/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@
"slack": slack,
"superset": superset_common,
"preset": superset_common,
"tableau": {"tableauserverclient>=0.24.0"} | sqlglot_lib,
"tableau": {"tableauserverclient>=0.24.0"} | sqlglot_lib | {"sgqlc"},
"teradata": sql_common
| usage_common
| sqlglot_lib
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,372 @@
# Generated by ariadne-codegen

import enum
import json
from typing import IO, Any, AsyncIterator, Dict, List, Optional, Tuple, TypeVar, cast
from uuid import uuid4

Check warning on line 6 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L3-L6

Added lines #L3 - L6 were not covered by tests

import httpx
from pydantic import BaseModel
from pydantic_core import to_jsonable_python

Check warning on line 10 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L8-L10

Added lines #L8 - L10 were not covered by tests

from datahub.ingestion.source.tableau.codegen_ariadne.base_model import UNSET, Upload
from datahub.ingestion.source.tableau.codegen_ariadne.exceptions import (

Check warning on line 13 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L12-L13

Added lines #L12 - L13 were not covered by tests
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQLClientInvalidMessageFormat,
GraphQLClientInvalidResponseError,
)

try:
from websockets.client import ( # type: ignore[import-not-found,unused-ignore]

Check warning on line 21 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L20-L21

Added lines #L20 - L21 were not covered by tests
WebSocketClientProtocol,
connect as ws_connect,
)
from websockets.typing import ( # type: ignore[import-not-found,unused-ignore]

Check warning on line 25 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L25

Added line #L25 was not covered by tests
Data,
Origin,
Subprotocol,
)
except ImportError:
from contextlib import asynccontextmanager

Check warning on line 31 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L30-L31

Added lines #L30 - L31 were not covered by tests

@asynccontextmanager # type: ignore
async def ws_connect(*args, **kwargs): # pylint: disable=unused-argument
raise NotImplementedError("Subscriptions require 'websockets' package.")

Check warning on line 35 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L33-L35

Added lines #L33 - L35 were not covered by tests
yield # pylint: disable=unreachable

WebSocketClientProtocol = Any # type: ignore[misc,assignment,unused-ignore]
Data = Any # type: ignore[misc,assignment,unused-ignore]
Origin = Any # type: ignore[misc,assignment,unused-ignore]

Check warning on line 40 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L38-L40

Added lines #L38 - L40 were not covered by tests

def Subprotocol(*args, **kwargs): # type: ignore # pylint: disable=invalid-name
raise NotImplementedError("Subscriptions require 'websockets' package.")

Check warning on line 43 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L42-L43

Added lines #L42 - L43 were not covered by tests


Self = TypeVar("Self", bound="AsyncBaseClient")

Check warning on line 46 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L46

Added line #L46 was not covered by tests

GRAPHQL_TRANSPORT_WS = "graphql-transport-ws"

Check warning on line 48 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L48

Added line #L48 was not covered by tests


class GraphQLTransportWSMessageType(str, enum.Enum):
CONNECTION_INIT = "connection_init"
CONNECTION_ACK = "connection_ack"
PING = "ping"
PONG = "pong"
SUBSCRIBE = "subscribe"
NEXT = "next"
ERROR = "error"
COMPLETE = "complete"

Check warning on line 59 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L51-L59

Added lines #L51 - L59 were not covered by tests


class AsyncBaseClient:
def __init__(

Check warning on line 63 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L62-L63

Added lines #L62 - L63 were not covered by tests
self,
url: str = "",
headers: Optional[Dict[str, str]] = None,
http_client: Optional[httpx.AsyncClient] = None,
ws_url: str = "",
ws_headers: Optional[Dict[str, Any]] = None,
ws_origin: Optional[str] = None,
ws_connection_init_payload: Optional[Dict[str, Any]] = None,
) -> None:
self.url = url
self.headers = headers
self.http_client = (

Check warning on line 75 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L73-L75

Added lines #L73 - L75 were not covered by tests
http_client if http_client else httpx.AsyncClient(headers=headers)
)

self.ws_url = ws_url
self.ws_headers = ws_headers or {}
self.ws_origin = Origin(ws_origin) if ws_origin else None
self.ws_connection_init_payload = ws_connection_init_payload

Check warning on line 82 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L79-L82

Added lines #L79 - L82 were not covered by tests

async def __aenter__(self: Self) -> Self:
return self

Check warning on line 85 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L84-L85

Added lines #L84 - L85 were not covered by tests

async def __aexit__(

Check warning on line 87 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L87

Added line #L87 was not covered by tests
self,
exc_type: object,
exc_val: object,
exc_tb: object,
) -> None:
await self.http_client.aclose()

Check warning on line 93 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L93

Added line #L93 was not covered by tests

async def execute(

Check warning on line 95 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L95

Added line #L95 was not covered by tests
self,
query: str,
operation_name: Optional[str] = None,
variables: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> httpx.Response:
processed_variables, files, files_map = self._process_variables(variables)

Check warning on line 102 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L102

Added line #L102 was not covered by tests

if files and files_map:
return await self._execute_multipart(

Check warning on line 105 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L104-L105

Added lines #L104 - L105 were not covered by tests
query=query,
operation_name=operation_name,
variables=processed_variables,
files=files,
files_map=files_map,
**kwargs,
)

return await self._execute_json(

Check warning on line 114 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L114

Added line #L114 was not covered by tests
query=query,
operation_name=operation_name,
variables=processed_variables,
**kwargs,
)

def get_data(self, response: httpx.Response) -> Dict[str, Any]:
if not response.is_success:
raise GraphQLClientHttpError(

Check warning on line 123 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L121-L123

Added lines #L121 - L123 were not covered by tests
status_code=response.status_code, response=response
)

try:
response_json = response.json()
except ValueError as exc:
raise GraphQLClientInvalidResponseError(response=response) from exc

Check warning on line 130 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L127-L130

Added lines #L127 - L130 were not covered by tests

if (not isinstance(response_json, dict)) or (

Check warning on line 132 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L132

Added line #L132 was not covered by tests
"data" not in response_json and "errors" not in response_json
):
raise GraphQLClientInvalidResponseError(response=response)

Check warning on line 135 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L135

Added line #L135 was not covered by tests

data = response_json.get("data")
errors = response_json.get("errors")

Check warning on line 138 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L137-L138

Added lines #L137 - L138 were not covered by tests

if errors:
raise GraphQLClientGraphQLMultiError.from_errors_dicts(

Check warning on line 141 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L140-L141

Added lines #L140 - L141 were not covered by tests
errors_dicts=errors, data=data
)

return cast(Dict[str, Any], data)

Check warning on line 145 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L145

Added line #L145 was not covered by tests

async def execute_ws(

Check warning on line 147 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L147

Added line #L147 was not covered by tests
self,
query: str,
operation_name: Optional[str] = None,
variables: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> AsyncIterator[Dict[str, Any]]:
headers = self.ws_headers.copy()
headers.update(kwargs.get("extra_headers", {}))

Check warning on line 155 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L154-L155

Added lines #L154 - L155 were not covered by tests

merged_kwargs: Dict[str, Any] = {"origin": self.ws_origin}
merged_kwargs.update(kwargs)
merged_kwargs["extra_headers"] = headers

Check warning on line 159 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L157-L159

Added lines #L157 - L159 were not covered by tests

operation_id = str(uuid4())
async with ws_connect(

Check warning on line 162 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L161-L162

Added lines #L161 - L162 were not covered by tests
self.ws_url,
subprotocols=[Subprotocol(GRAPHQL_TRANSPORT_WS)],
**merged_kwargs,
) as websocket:
await self._send_connection_init(websocket)

Check warning on line 167 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L167

Added line #L167 was not covered by tests
# wait for connection_ack from server
await self._handle_ws_message(

Check warning on line 169 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L169

Added line #L169 was not covered by tests
await websocket.recv(),
websocket,
expected_type=GraphQLTransportWSMessageType.CONNECTION_ACK,
)
await self._send_subscribe(

Check warning on line 174 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L174

Added line #L174 was not covered by tests
websocket,
operation_id=operation_id,
query=query,
operation_name=operation_name,
variables=variables,
)

async for message in websocket:
data = await self._handle_ws_message(message, websocket)
if data:
yield data

Check warning on line 185 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L182-L185

Added lines #L182 - L185 were not covered by tests

def _process_variables(

Check warning on line 187 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L187

Added line #L187 was not covered by tests
self, variables: Optional[Dict[str, Any]]
) -> Tuple[
Dict[str, Any], Dict[str, Tuple[str, IO[bytes], str]], Dict[str, List[str]]
]:
if not variables:
return {}, {}, {}

Check warning on line 193 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L192-L193

Added lines #L192 - L193 were not covered by tests

serializable_variables = self._convert_dict_to_json_serializable(variables)
return self._get_files_from_variables(serializable_variables)

Check warning on line 196 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L195-L196

Added lines #L195 - L196 were not covered by tests

def _convert_dict_to_json_serializable(

Check warning on line 198 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L198

Added line #L198 was not covered by tests
self, dict_: Dict[str, Any]
) -> Dict[str, Any]:
return {

Check warning on line 201 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L201

Added line #L201 was not covered by tests
key: self._convert_value(value)
for key, value in dict_.items()
if value is not UNSET
}

def _convert_value(self, value: Any) -> Any:
if isinstance(value, BaseModel):
return value.model_dump(by_alias=True, exclude_unset=True)
if isinstance(value, list):
return [self._convert_value(item) for item in value]
return value

Check warning on line 212 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L207-L212

Added lines #L207 - L212 were not covered by tests

def _get_files_from_variables(

Check warning on line 214 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L214

Added line #L214 was not covered by tests
self, variables: Dict[str, Any]
) -> Tuple[
Dict[str, Any], Dict[str, Tuple[str, IO[bytes], str]], Dict[str, List[str]]
]:
files_map: Dict[str, List[str]] = {}
files_list: List[Upload] = []

Check warning on line 220 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L219-L220

Added lines #L219 - L220 were not covered by tests

def separate_files(path: str, obj: Any) -> Any:
if isinstance(obj, list):
nulled_list = []
for index, value in enumerate(obj):
value = separate_files(f"{path}.{index}", value)
nulled_list.append(value)
return nulled_list

Check warning on line 228 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L222-L228

Added lines #L222 - L228 were not covered by tests

if isinstance(obj, dict):
nulled_dict = {}
for key, value in obj.items():
value = separate_files(f"{path}.{key}", value)
nulled_dict[key] = value
return nulled_dict

Check warning on line 235 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L230-L235

Added lines #L230 - L235 were not covered by tests

if isinstance(obj, Upload):
if obj in files_list:
file_index = files_list.index(obj)
files_map[str(file_index)].append(path)

Check warning on line 240 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L237-L240

Added lines #L237 - L240 were not covered by tests
else:
file_index = len(files_list)
files_list.append(obj)
files_map[str(file_index)] = [path]
return None

Check warning on line 245 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L242-L245

Added lines #L242 - L245 were not covered by tests

return obj

Check warning on line 247 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L247

Added line #L247 was not covered by tests

nulled_variables = separate_files("variables", variables)
files: Dict[str, Tuple[str, IO[bytes], str]] = {

Check warning on line 250 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L249-L250

Added lines #L249 - L250 were not covered by tests
str(i): (file_.filename, cast(IO[bytes], file_.content), file_.content_type)
for i, file_ in enumerate(files_list)
}
return nulled_variables, files, files_map

Check warning on line 254 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L254

Added line #L254 was not covered by tests

async def _execute_multipart(

Check warning on line 256 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L256

Added line #L256 was not covered by tests
self,
query: str,
operation_name: Optional[str],
variables: Dict[str, Any],
files: Dict[str, Tuple[str, IO[bytes], str]],
files_map: Dict[str, List[str]],
**kwargs: Any,
) -> httpx.Response:
data = {

Check warning on line 265 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L265

Added line #L265 was not covered by tests
"operations": json.dumps(
{
"query": query,
"operationName": operation_name,
"variables": variables,
},
default=to_jsonable_python,
),
"map": json.dumps(files_map, default=to_jsonable_python),
}

return await self.http_client.post(

Check warning on line 277 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L277

Added line #L277 was not covered by tests
url=self.url, data=data, files=files, **kwargs
)

async def _execute_json(

Check warning on line 281 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L281

Added line #L281 was not covered by tests
self,
query: str,
operation_name: Optional[str],
variables: Dict[str, Any],
**kwargs: Any,
) -> httpx.Response:
headers: Dict[str, str] = {"Content-Type": "application/json"}
headers.update(kwargs.get("headers", {}))

Check warning on line 289 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L288-L289

Added lines #L288 - L289 were not covered by tests

merged_kwargs: Dict[str, Any] = kwargs.copy()
merged_kwargs["headers"] = headers

Check warning on line 292 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L291-L292

Added lines #L291 - L292 were not covered by tests

return await self.http_client.post(

Check warning on line 294 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L294

Added line #L294 was not covered by tests
url=self.url,
content=json.dumps(
{
"query": query,
"operationName": operation_name,
"variables": variables,
},
default=to_jsonable_python,
),
**merged_kwargs,
)

async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> None:
payload: Dict[str, Any] = {

Check warning on line 308 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L307-L308

Added lines #L307 - L308 were not covered by tests
"type": GraphQLTransportWSMessageType.CONNECTION_INIT.value
}
if self.ws_connection_init_payload:
payload["payload"] = self.ws_connection_init_payload
await websocket.send(json.dumps(payload))

Check warning on line 313 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L311-L313

Added lines #L311 - L313 were not covered by tests

async def _send_subscribe(

Check warning on line 315 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L315

Added line #L315 was not covered by tests
self,
websocket: WebSocketClientProtocol,
operation_id: str,
query: str,
operation_name: Optional[str] = None,
variables: Optional[Dict[str, Any]] = None,
) -> None:
payload: Dict[str, Any] = {

Check warning on line 323 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L323

Added line #L323 was not covered by tests
"id": operation_id,
"type": GraphQLTransportWSMessageType.SUBSCRIBE.value,
"payload": {"query": query, "operationName": operation_name},
}
if variables:
payload["payload"]["variables"] = self._convert_dict_to_json_serializable(

Check warning on line 329 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L328-L329

Added lines #L328 - L329 were not covered by tests
variables
)
await websocket.send(json.dumps(payload))

Check warning on line 332 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L332

Added line #L332 was not covered by tests

async def _handle_ws_message(

Check warning on line 334 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L334

Added line #L334 was not covered by tests
self,
message: Data,
websocket: WebSocketClientProtocol,
expected_type: Optional[GraphQLTransportWSMessageType] = None,
) -> Optional[Dict[str, Any]]:
try:
message_dict = json.loads(message)
except json.JSONDecodeError as exc:
raise GraphQLClientInvalidMessageFormat(message=message) from exc

Check warning on line 343 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L340-L343

Added lines #L340 - L343 were not covered by tests

type_ = message_dict.get("type")
payload = message_dict.get("payload", {})

Check warning on line 346 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L345-L346

Added lines #L345 - L346 were not covered by tests

if not type_ or type_ not in {t.value for t in GraphQLTransportWSMessageType}:
raise GraphQLClientInvalidMessageFormat(message=message)

Check warning on line 349 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L348-L349

Added lines #L348 - L349 were not covered by tests

if expected_type and expected_type != type_:
raise GraphQLClientInvalidMessageFormat(

Check warning on line 352 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L351-L352

Added lines #L351 - L352 were not covered by tests
f"Invalid message received. Expected: {expected_type.value}"
)

if type_ == GraphQLTransportWSMessageType.NEXT:
if "data" not in payload:
raise GraphQLClientInvalidMessageFormat(message=message)
return cast(Dict[str, Any], payload["data"])

Check warning on line 359 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L356-L359

Added lines #L356 - L359 were not covered by tests

if type_ == GraphQLTransportWSMessageType.COMPLETE:
await websocket.close()
elif type_ == GraphQLTransportWSMessageType.PING:
await websocket.send(

Check warning on line 364 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L361-L364

Added lines #L361 - L364 were not covered by tests
json.dumps({"type": GraphQLTransportWSMessageType.PONG.value})
)
elif type_ == GraphQLTransportWSMessageType.ERROR:
raise GraphQLClientGraphQLMultiError.from_errors_dicts(

Check warning on line 368 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L367-L368

Added lines #L367 - L368 were not covered by tests
errors_dicts=payload, data=message_dict
)

return None

Check warning on line 372 in metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py

View check run for this annotation

Codecov / codecov/patch

metadata-ingestion/src/datahub/ingestion/source/tableau/codegen_ariadne/async_base_client.py#L372

Added line #L372 was not covered by tests
Loading
Loading