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

Add column_types to ResultMetadata and Fix broken async client #136

Merged
merged 2 commits into from
Oct 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
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[MASTER]
disable=fixme,logging-fstring-interpolation
disable=fixme,logging-fstring-interpolation,too-many-positional-arguments
[DESIGN]
max-args=10
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VENV = venv
VENV = .venv
PYTHON = $(VENV)/bin/python3
PIP = $(VENV)/bin/pip

Expand Down
7 changes: 6 additions & 1 deletion dune_client/client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
from __future__ import annotations

import asyncio
import ssl
from io import BytesIO
from typing import Any, Callable, Dict, List, Optional, Union

import certifi
from aiohttp import (
ClientResponseError,
ClientSession,
Expand Down Expand Up @@ -83,7 +85,10 @@ def __init__(
self._session: Optional[ClientSession] = None

async def _create_session(self) -> ClientSession:
conn = TCPConnector(limit=self._connection_limit)
# Create an SSL context using the certifi certificate store
ssl_context = ssl.create_default_context(cafile=certifi.where())

conn = TCPConnector(limit=self._connection_limit, ssl=ssl_context)
return ClientSession(
connector=conn,
base_url=self.base_url,
Expand Down
2 changes: 2 additions & 0 deletions dune_client/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class ResultMetadata:
# pylint: disable=too-many-instance-attributes

column_names: list[str]
column_types: list[str]
row_count: int
result_set_bytes: int
total_row_count: int
Expand All @@ -203,6 +204,7 @@ def from_dict(cls, data: dict[str, Any]) -> ResultMetadata:
pending_time = data.get("pending_time_millis", None)
return cls(
column_names=data["column_names"],
column_types=data["column_types"],
row_count=int(data["total_row_count"]),
result_set_bytes=int(data["result_set_bytes"]),
total_row_count=int(data["total_row_count"]),
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/test_custom_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
dotenv.load_dotenv()


@unittest.skip("endpoint no longer exists - {'error': 'Custom endpoint not found'}")
class TestCustomEndpoints(unittest.TestCase):
def setUp(self) -> None:
self.valid_api_key = os.environ["DUNE_API_KEY"]

def test_gettin_custom_endpoint_results(self):
def test_getting_custom_endpoint_results(self):
dune = DuneClient(self.valid_api_key)
results = dune.get_custom_endpoint_result("dune", "new-test")
self.assertEqual(len(results.get_rows()), 10)
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def setUp(self) -> None:
}
self.result_metadata_data = {
"column_names": ["ct", "TableName"],
"column_types": ["x", "y"],
"row_count": 8,
"result_set_bytes": 194,
"total_result_set_bytes": 194,
Expand Down Expand Up @@ -143,6 +144,7 @@ def test_parse_known_status_response(self):
"execution_ended_at": "2022-10-07T10:53:20.729372559Z",
"result_metadata": {
"column_names": ["token"],
"column_types": ["varchar"],
"result_set_bytes": 815,
"total_row_count": 18,
"datapoint_count": 18,
Expand Down Expand Up @@ -171,6 +173,7 @@ def test_parse_status_response_completed(self):
def test_parse_result_metadata(self):
expected = ResultMetadata(
column_names=["ct", "TableName"],
column_types=["x", "y"],
row_count=8,
result_set_bytes=194,
total_row_count=8,
Expand Down
Loading