From 385329533117f3db75a3525d6b2402d24361c29e Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Fri, 15 Mar 2024 11:57:12 -0400 Subject: [PATCH 01/16] Black linting --- tests/e2e/test_async_client.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/e2e/test_async_client.py b/tests/e2e/test_async_client.py index 20ac35a..1d9b97f 100644 --- a/tests/e2e/test_async_client.py +++ b/tests/e2e/test_async_client.py @@ -41,7 +41,6 @@ async def test_refresh_context_manager(self): async def test_refresh_with_pagination(self): # Arrange async with AsyncDuneClient(self.valid_api_key) as cl: - # Act results = (await cl.refresh(self.multi_rows_query, batch_size=1)).get_rows() @@ -60,7 +59,6 @@ async def test_refresh_with_pagination(self): async def test_refresh_with_filters(self): # Arrange async with AsyncDuneClient(self.valid_api_key) as cl: - # Act results = ( await cl.refresh(self.multi_rows_query, filters="number < 3") @@ -78,7 +76,6 @@ async def test_refresh_with_filters(self): async def test_refresh_csv_with_pagination(self): # Arrange async with AsyncDuneClient(self.valid_api_key) as cl: - # Act result_csv = await cl.refresh_csv(self.multi_rows_query, batch_size=1) @@ -97,7 +94,6 @@ async def test_refresh_csv_with_pagination(self): async def test_refresh_csv_with_filters(self): # Arrange async with AsyncDuneClient(self.valid_api_key) as cl: - # Act result_csv = await cl.refresh_csv( self.multi_rows_query, filters="number < 3" From f97dc83af732bf77ce98a38c36754958b40f0ac5 Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Fri, 15 Mar 2024 11:57:56 -0400 Subject: [PATCH 02/16] Seperate table endpoints into TableAPI class and support for /table/create/ endpoint --- dune_client/api/extensions.py | 37 +---------------- dune_client/api/table.py | 77 +++++++++++++++++++++++++++++++++++ tests/e2e/test_client.py | 18 ++++++++ 3 files changed, 97 insertions(+), 35 deletions(-) create mode 100644 dune_client/api/table.py diff --git a/dune_client/api/extensions.py b/dune_client/api/extensions.py index c5f3047..e4c074c 100644 --- a/dune_client/api/extensions.py +++ b/dune_client/api/extensions.py @@ -19,6 +19,7 @@ ) from dune_client.api.execution import ExecutionAPI from dune_client.api.query import QueryAPI +from dune_client.api.table import TableAPI from dune_client.models import ( ResultsResponse, DuneError, @@ -36,7 +37,7 @@ POLL_FREQUENCY_SECONDS = 1 -class ExtendedAPI(ExecutionAPI, QueryAPI): +class ExtendedAPI(ExecutionAPI, QueryAPI, TableAPI): """ Provides higher level helper methods for faster and easier development on top of the base ExecutionAPI. @@ -316,40 +317,6 @@ def download_csv( ), ) - ############################ - # Plus Subscription Features - ############################ - def upload_csv( - self, - table_name: str, - data: str, - description: str = "", - is_private: bool = False, - ) -> bool: - """ - https://docs.dune.com/api-reference/tables/endpoint/upload - The write API allows you to upload any .csv file into Dune. The only limitations are: - - - File has to be < 200 MB - - Column names in the table can't start with a special character or digits. - - Private uploads require a Plus subscription. - - Below are the specifics of how to work with the API. - """ - response_json = self._post( - route="/table/upload/csv", - params={ - "table_name": table_name, - "description": description, - "data": data, - "is_private": is_private, - }, - ) - try: - return bool(response_json["success"]) - except KeyError as err: - raise DuneError(response_json, "UploadCsvResponse", err) from err - ############################################################################################## # Plus Features: these features use APIs that are only available on paid subscription plans ############################################################################################## diff --git a/dune_client/api/table.py b/dune_client/api/table.py new file mode 100644 index 0000000..9834e7b --- /dev/null +++ b/dune_client/api/table.py @@ -0,0 +1,77 @@ +""" +Table API endpoints enables users to +create and insert data into Dune. +""" + +from __future__ import annotations +from typing import List, Dict, Any + +from dune_client.api.base import BaseRouter +from dune_client.models import DuneError + + +class TableAPI(BaseRouter): + """ + Implementation of Table endpoints - Plus subscription only + https://docs.dune.com/api-reference/tables/ + """ + + def upload_csv( + self, + table_name: str, + data: str, + description: str = "", + is_private: bool = False, + ) -> bool: + """ + https://docs.dune.com/api-reference/tables/endpoint/upload + The write API allows you to upload any .csv file into Dune. The only limitations are: + + - File has to be < 200 MB + - Column names in the table can't start with a special character or digits. + - Private uploads require a Plus subscription. + + Below are the specifics of how to work with the API. + """ + response_json = self._post( + route="/table/upload/csv", + params={ + "table_name": table_name, + "description": description, + "data": data, + "is_private": is_private, + }, + ) + try: + return bool(response_json["success"]) + except KeyError as err: + raise DuneError(response_json, "UploadCsvResponse", err) from err + + def create_table( + self, + namespace: str, + table_name: str, + schema: List[Dict[str, str]], + description: str = "", + ) -> Any: + """ + https://docs.dune.com/api-reference/tables/endpoint/create + The create table endpoint allows you to create an empty table with a specifc schema in Dune. + + The only limitations are: + - A table must currently be created as public. + - If the request tries to create a private table, it will fail. + - If a table already exists with the same name, the request will fail. + - Column names in the table can’t start with a special character or a digit. + """ + payload = { + "schema": schema, + "description": description, + } + response_json = self._post( + route=f"/table/{namespace}/{table_name}/create", params=payload + ) + try: + return response_json + except KeyError as err: + raise DuneError(response_json, "CreateTableResponse", err) from err diff --git a/tests/e2e/test_client.py b/tests/e2e/test_client.py index 07882ac..fa63f3a 100644 --- a/tests/e2e/test_client.py +++ b/tests/e2e/test_client.py @@ -236,6 +236,24 @@ def test_upload_csv_success(self): True, ) + @unittest.skip("This is a plus subscription endpoint.") + def test_create_table_success(self): + # Make sure the table doesn't already exist. + client = DuneClient(self.valid_api_key) + print(dir(DuneClient)) + self.assertEqual( + client.create_table( + namespace="test", + table_name="dataset_e2e_test", + description="e2e test table", + schema=[ + {"name": "date", "type": "timestamp"}, + {"name": "dgs10", "type": "double"}, + ], + ), + {}, + ) + def test_download_csv_with_pagination(self): # Arrange client = DuneClient(self.valid_api_key) From fd95ef834ef3a2d3510ec9a5f18545d205a775e0 Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Mon, 18 Mar 2024 07:39:54 -0400 Subject: [PATCH 03/16] Added support for table/insert endpoint --- dune_client/api/base.py | 13 +++++++-- dune_client/api/table.py | 38 +++++++++++++++++++++++++ tests/e2e/test_client.py | 30 +++++++++++++++++++ tests/fixtures/sample_table_insert.csv | 2 ++ tests/fixtures/sample_table_insert.json | 1 + 5 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 tests/fixtures/sample_table_insert.csv create mode 100644 tests/fixtures/sample_table_insert.json diff --git a/dune_client/api/base.py b/dune_client/api/base.py index ddb3ed4..ebae77b 100644 --- a/dune_client/api/base.py +++ b/dune_client/api/base.py @@ -9,7 +9,7 @@ import logging.config import os from json import JSONDecodeError -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union, IO from requests import Response, Session from requests.adapters import HTTPAdapter, Retry @@ -179,15 +179,22 @@ def _get( return response return self._handle_response(response) - def _post(self, route: str, params: Optional[Any] = None) -> Any: + def _post( + self, + route: str, + params: Optional[Any] = None, + data: Optional[IO[bytes]] = None, + headers: Optional[Dict[str, Optional[str]]] = None, + ) -> Any: """Generic interface for the POST method of a Dune API request""" url = self._route_url(route) self.logger.debug(f"POST received input url={url}, params={params}") response = self.http.post( url=url, json=params, - headers=self.default_headers(), + headers=dict(self.default_headers(), **(headers or {})), timeout=self.request_timeout, + data=data, ) return self._handle_response(response) diff --git a/dune_client/api/table.py b/dune_client/api/table.py index 9834e7b..7de424f 100644 --- a/dune_client/api/table.py +++ b/dune_client/api/table.py @@ -75,3 +75,41 @@ def create_table( return response_json except KeyError as err: raise DuneError(response_json, "CreateTableResponse", err) from err + + def insert_table( + self, + namespace: str, + table_name: str, + path: str, + ) -> Any: + """ + https://docs.dune.com/api-reference/tables/endpoint/insert + The insert table endpoint allows you to insert data into an existing table in Dune. + + The only limitations are: + - The file has to be in json or csv format + - The file has to have the same schema as the table + """ + + file_extension = path.split(".")[-1] + + with open(path, "rb") as data: + response_json = self._post( + route=f"/table/{namespace}/{table_name}/insert", + headers={ + "Content-Type": ( + "text/csv" + if file_extension == "csv" + else ( + "application/x-ndjson" + if file_extension in ["json", "jsonl"] + else None + ) + ) + }, + data=data, + ) + try: + return response_json + except KeyError as err: + raise DuneError(response_json, "InsertTableResponse", err) from err diff --git a/tests/e2e/test_client.py b/tests/e2e/test_client.py index fa63f3a..1d4e162 100644 --- a/tests/e2e/test_client.py +++ b/tests/e2e/test_client.py @@ -254,6 +254,36 @@ def test_create_table_success(self): {}, ) + @unittest.skip("This is a plus subscription endpoint.") + def test_insert_table_csv_success(self): + # Make sure the table already exists and csv matches table schema. + # You will need to change the namespace to your own. + client = DuneClient(self.valid_api_key) + + self.assertEqual( + client.insert_table( + namespace="test", + table_name="dataset_e2e_test", + path="./tests/fixtures/sample_table_insert.csv", + ), + None, + ) + + @unittest.skip("This is a plus subscription endpoint.") + def test_insert_table_json_success(self): + # Make sure the table already exists and json matches table schema. + # You will need to change the namespace to your own. + client = DuneClient(self.valid_api_key) + + self.assertEqual( + client.insert_table( + namespace="test", + table_name="dataset_e2e_test", + path="./tests/fixtures/sample_table_insert.json", + ), + None, + ) + def test_download_csv_with_pagination(self): # Arrange client = DuneClient(self.valid_api_key) diff --git a/tests/fixtures/sample_table_insert.csv b/tests/fixtures/sample_table_insert.csv new file mode 100644 index 0000000..70b2f9e --- /dev/null +++ b/tests/fixtures/sample_table_insert.csv @@ -0,0 +1,2 @@ +date,dgs10 +2020-12-01T23:33:00,10 \ No newline at end of file diff --git a/tests/fixtures/sample_table_insert.json b/tests/fixtures/sample_table_insert.json new file mode 100644 index 0000000..f2b93f0 --- /dev/null +++ b/tests/fixtures/sample_table_insert.json @@ -0,0 +1 @@ +{"date":"2020-12-01T23:33:00","dgs10":10} \ No newline at end of file From dd6d30d78502ea752bd6c04cc1ea7299da2e1347 Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Mon, 18 Mar 2024 07:43:24 -0400 Subject: [PATCH 04/16] Fix test_create_table_success retrun type --- tests/e2e/test_client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/e2e/test_client.py b/tests/e2e/test_client.py index 1d4e162..d119b21 100644 --- a/tests/e2e/test_client.py +++ b/tests/e2e/test_client.py @@ -239,8 +239,9 @@ def test_upload_csv_success(self): @unittest.skip("This is a plus subscription endpoint.") def test_create_table_success(self): # Make sure the table doesn't already exist. + # You will need to change the namespace to your own. client = DuneClient(self.valid_api_key) - print(dir(DuneClient)) + self.assertEqual( client.create_table( namespace="test", @@ -251,7 +252,7 @@ def test_create_table_success(self): {"name": "dgs10", "type": "double"}, ], ), - {}, + None, ) @unittest.skip("This is a plus subscription endpoint.") From 6a3a1c5f2bbe684c02dd1e2abe8a3a8a791539a4 Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Mon, 18 Mar 2024 09:28:21 -0400 Subject: [PATCH 05/16] Refactored insert_table to use data bytes into of path --- dune_client/api/table.py | 39 +++++++++++++-------------------------- tests/e2e/test_client.py | 38 ++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 44 deletions(-) diff --git a/dune_client/api/table.py b/dune_client/api/table.py index 7de424f..4dd4351 100644 --- a/dune_client/api/table.py +++ b/dune_client/api/table.py @@ -4,7 +4,7 @@ """ from __future__ import annotations -from typing import List, Dict, Any +from typing import List, Dict, Any, IO from dune_client.api.base import BaseRouter from dune_client.models import DuneError @@ -25,7 +25,7 @@ def upload_csv( ) -> bool: """ https://docs.dune.com/api-reference/tables/endpoint/upload - The write API allows you to upload any .csv file into Dune. The only limitations are: + This endpoint allows you to upload any .csv file into Dune. The only limitations are: - File has to be < 200 MB - Column names in the table can't start with a special character or digits. @@ -60,7 +60,6 @@ def create_table( The only limitations are: - A table must currently be created as public. - - If the request tries to create a private table, it will fail. - If a table already exists with the same name, the request will fail. - Column names in the table can’t start with a special character or a digit. """ @@ -80,7 +79,8 @@ def insert_table( self, namespace: str, table_name: str, - path: str, + data: IO[bytes], + content_type: str, ) -> Any: """ https://docs.dune.com/api-reference/tables/endpoint/insert @@ -91,25 +91,12 @@ def insert_table( - The file has to have the same schema as the table """ - file_extension = path.split(".")[-1] - - with open(path, "rb") as data: - response_json = self._post( - route=f"/table/{namespace}/{table_name}/insert", - headers={ - "Content-Type": ( - "text/csv" - if file_extension == "csv" - else ( - "application/x-ndjson" - if file_extension in ["json", "jsonl"] - else None - ) - ) - }, - data=data, - ) - try: - return response_json - except KeyError as err: - raise DuneError(response_json, "InsertTableResponse", err) from err + response_json = self._post( + route=f"/table/{namespace}/{table_name}/insert", + headers={"Content-Type": content_type}, + data=data, + ) + try: + return response_json + except KeyError as err: + raise DuneError(response_json, "InsertTableResponse", err) from err diff --git a/tests/e2e/test_client.py b/tests/e2e/test_client.py index d119b21..7990681 100644 --- a/tests/e2e/test_client.py +++ b/tests/e2e/test_client.py @@ -260,30 +260,32 @@ def test_insert_table_csv_success(self): # Make sure the table already exists and csv matches table schema. # You will need to change the namespace to your own. client = DuneClient(self.valid_api_key) - - self.assertEqual( - client.insert_table( - namespace="test", - table_name="dataset_e2e_test", - path="./tests/fixtures/sample_table_insert.csv", - ), - None, - ) + with open("./tests/fixtures/sample_table_insert.csv", "rb") as data: + self.assertEqual( + client.insert_table( + namespace="test", + table_name="dataset_e2e_test", + data=data, + content_type="text/csv", + ), + None, + ) @unittest.skip("This is a plus subscription endpoint.") def test_insert_table_json_success(self): # Make sure the table already exists and json matches table schema. # You will need to change the namespace to your own. client = DuneClient(self.valid_api_key) - - self.assertEqual( - client.insert_table( - namespace="test", - table_name="dataset_e2e_test", - path="./tests/fixtures/sample_table_insert.json", - ), - None, - ) + with open("./tests/fixtures/sample_table_insert.json", "rb") as data: + self.assertEqual( + client.insert_table( + namespace="test", + table_name="dataset_e2e_test", + data=data, + content_type="application/x-ndjson", + ), + None, + ) def test_download_csv_with_pagination(self): # Arrange From 2f14b9a38aabea772b2d7fbdc650798e3be0d6cc Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Mon, 18 Mar 2024 09:31:20 -0400 Subject: [PATCH 06/16] Remove unnecessary try-except --- dune_client/api/table.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/dune_client/api/table.py b/dune_client/api/table.py index 4dd4351..dfb7158 100644 --- a/dune_client/api/table.py +++ b/dune_client/api/table.py @@ -67,13 +67,10 @@ def create_table( "schema": schema, "description": description, } - response_json = self._post( - route=f"/table/{namespace}/{table_name}/create", params=payload + return self._post( + route=f"/table/{namespace}/{table_name}/create", + params=payload, ) - try: - return response_json - except KeyError as err: - raise DuneError(response_json, "CreateTableResponse", err) from err def insert_table( self, @@ -91,12 +88,8 @@ def insert_table( - The file has to have the same schema as the table """ - response_json = self._post( + return self._post( route=f"/table/{namespace}/{table_name}/insert", headers={"Content-Type": content_type}, data=data, ) - try: - return response_json - except KeyError as err: - raise DuneError(response_json, "InsertTableResponse", err) from err From 3338e3687dfc2ff5bc81651556180a03aee1f690 Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Mon, 18 Mar 2024 09:43:11 -0400 Subject: [PATCH 07/16] Default headers to {} --- dune_client/api/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dune_client/api/base.py b/dune_client/api/base.py index ebae77b..99f5c0d 100644 --- a/dune_client/api/base.py +++ b/dune_client/api/base.py @@ -184,15 +184,16 @@ def _post( route: str, params: Optional[Any] = None, data: Optional[IO[bytes]] = None, - headers: Optional[Dict[str, Optional[str]]] = None, + headers: Dict[str, str] = {}, ) -> Any: + # pylint: disable=dangerous-default-value """Generic interface for the POST method of a Dune API request""" url = self._route_url(route) self.logger.debug(f"POST received input url={url}, params={params}") response = self.http.post( url=url, json=params, - headers=dict(self.default_headers(), **(headers or {})), + headers=dict(self.default_headers(), **headers), timeout=self.request_timeout, data=data, ) From eaa0fdb4ac2fe2289279e41900d5c1847edb0f0c Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Mon, 18 Mar 2024 10:57:34 -0400 Subject: [PATCH 08/16] Add support for creating private tables --- dune_client/api/table.py | 12 +++++++----- tests/e2e/test_client.py | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dune_client/api/table.py b/dune_client/api/table.py index dfb7158..21b8a64 100644 --- a/dune_client/api/table.py +++ b/dune_client/api/table.py @@ -53,6 +53,7 @@ def create_table( table_name: str, schema: List[Dict[str, str]], description: str = "", + is_private: bool = False, ) -> Any: """ https://docs.dune.com/api-reference/tables/endpoint/create @@ -63,13 +64,14 @@ def create_table( - If a table already exists with the same name, the request will fail. - Column names in the table can’t start with a special character or a digit. """ - payload = { - "schema": schema, - "description": description, - } + return self._post( route=f"/table/{namespace}/{table_name}/create", - params=payload, + params={ + "schema": schema, + "description": description, + "is_private": is_private, + }, ) def insert_table( diff --git a/tests/e2e/test_client.py b/tests/e2e/test_client.py index 7990681..90be779 100644 --- a/tests/e2e/test_client.py +++ b/tests/e2e/test_client.py @@ -251,6 +251,7 @@ def test_create_table_success(self): {"name": "date", "type": "timestamp"}, {"name": "dgs10", "type": "double"}, ], + is_private=False, ), None, ) From 8c7f8e67333688dd013abf6df580e413e745a076 Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Mon, 18 Mar 2024 10:58:52 -0400 Subject: [PATCH 09/16] Remove must be public comment limitation --- dune_client/api/table.py | 1 - 1 file changed, 1 deletion(-) diff --git a/dune_client/api/table.py b/dune_client/api/table.py index 21b8a64..d5f4f60 100644 --- a/dune_client/api/table.py +++ b/dune_client/api/table.py @@ -60,7 +60,6 @@ def create_table( The create table endpoint allows you to create an empty table with a specifc schema in Dune. The only limitations are: - - A table must currently be created as public. - If a table already exists with the same name, the request will fail. - Column names in the table can’t start with a special character or a digit. """ From 613046597ddfe4d6ff4460b1b4f2cc8dfefac229 Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Tue, 19 Mar 2024 05:29:14 -0400 Subject: [PATCH 10/16] Changing create endpoint to use params for namespace and table_name --- dune_client/api/table.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dune_client/api/table.py b/dune_client/api/table.py index d5f4f60..fc0e1a8 100644 --- a/dune_client/api/table.py +++ b/dune_client/api/table.py @@ -65,8 +65,10 @@ def create_table( """ return self._post( - route=f"/table/{namespace}/{table_name}/create", + route=f"/table/create", params={ + "namespace": namespace, + "table_name": table_name, "schema": schema, "description": description, "is_private": is_private, From d5fe607f5a21972bafeeb215876dcdebe1847a2f Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Tue, 19 Mar 2024 05:32:44 -0400 Subject: [PATCH 11/16] Resolve linting issues --- dune_client/api/table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dune_client/api/table.py b/dune_client/api/table.py index fc0e1a8..3a035fa 100644 --- a/dune_client/api/table.py +++ b/dune_client/api/table.py @@ -65,7 +65,7 @@ def create_table( """ return self._post( - route=f"/table/create", + route="/table/create", params={ "namespace": namespace, "table_name": table_name, From e3f6c98eab115e4f03d256b18fc8709a524c886f Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Tue, 19 Mar 2024 06:50:42 -0400 Subject: [PATCH 12/16] Update create_table rest with latest response --- tests/e2e/test_client.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/e2e/test_client.py b/tests/e2e/test_client.py index 90be779..2bc6b34 100644 --- a/tests/e2e/test_client.py +++ b/tests/e2e/test_client.py @@ -236,16 +236,19 @@ def test_upload_csv_success(self): True, ) - @unittest.skip("This is a plus subscription endpoint.") + # @unittest.skip("This is a plus subscription endpoint.") def test_create_table_success(self): # Make sure the table doesn't already exist. # You will need to change the namespace to your own. client = DuneClient(self.valid_api_key) + namespace = "test" + table_name = "dataset_e2e_test" + self.assertEqual( client.create_table( - namespace="test", - table_name="dataset_e2e_test", + namespace=namespace, + table_name=table_name, description="e2e test table", schema=[ {"name": "date", "type": "timestamp"}, @@ -253,7 +256,12 @@ def test_create_table_success(self): ], is_private=False, ), - None, + { + "namespace": namespace, + "table_name": table_name, + "full_name": f"dune.{namespace}.{table_name}", + "example_query": f"select * from dune.{namespace}.{table_name} limit 10", + }, ) @unittest.skip("This is a plus subscription endpoint.") From 0c1c14d489719e9cdec63970cf05d599b13a2f12 Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Tue, 19 Mar 2024 07:22:20 -0400 Subject: [PATCH 13/16] Fixed a typo --- dune_client/api/table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dune_client/api/table.py b/dune_client/api/table.py index 3a035fa..bcc81a2 100644 --- a/dune_client/api/table.py +++ b/dune_client/api/table.py @@ -57,7 +57,7 @@ def create_table( ) -> Any: """ https://docs.dune.com/api-reference/tables/endpoint/create - The create table endpoint allows you to create an empty table with a specifc schema in Dune. + The create table endpoint allows you to create an empty table with a specific schema in Dune. The only limitations are: - If a table already exists with the same name, the request will fail. From 7fdbfa5feff03ea56369fadf46dd2e975d33770b Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Tue, 19 Mar 2024 07:27:14 -0400 Subject: [PATCH 14/16] Fix linting --- dune_client/api/table.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dune_client/api/table.py b/dune_client/api/table.py index bcc81a2..ed1f9a3 100644 --- a/dune_client/api/table.py +++ b/dune_client/api/table.py @@ -57,7 +57,8 @@ def create_table( ) -> Any: """ https://docs.dune.com/api-reference/tables/endpoint/create - The create table endpoint allows you to create an empty table with a specific schema in Dune. + The create table endpoint allows you to create an empty table + with a specific schema in Dune. The only limitations are: - If a table already exists with the same name, the request will fail. From 4e11311633d0ca6a7fa41b8d98b7507437914e32 Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Tue, 19 Mar 2024 07:30:25 -0400 Subject: [PATCH 15/16] Skip create_table_success unit test --- tests/e2e/test_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/test_client.py b/tests/e2e/test_client.py index 2bc6b34..426c9d4 100644 --- a/tests/e2e/test_client.py +++ b/tests/e2e/test_client.py @@ -236,7 +236,7 @@ def test_upload_csv_success(self): True, ) - # @unittest.skip("This is a plus subscription endpoint.") + @unittest.skip("This is a plus subscription endpoint.") def test_create_table_success(self): # Make sure the table doesn't already exist. # You will need to change the namespace to your own. From 642cc49bf3b979c365c46ecc5cf108405b03efb6 Mon Sep 17 00:00:00 2001 From: waddahAldrobi Date: Tue, 19 Mar 2024 08:06:16 -0400 Subject: [PATCH 16/16] Change headers in post back to default to None --- dune_client/api/base.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dune_client/api/base.py b/dune_client/api/base.py index 99f5c0d..c00b016 100644 --- a/dune_client/api/base.py +++ b/dune_client/api/base.py @@ -184,16 +184,15 @@ def _post( route: str, params: Optional[Any] = None, data: Optional[IO[bytes]] = None, - headers: Dict[str, str] = {}, + headers: Optional[Dict[str, str]] = None, ) -> Any: - # pylint: disable=dangerous-default-value """Generic interface for the POST method of a Dune API request""" url = self._route_url(route) self.logger.debug(f"POST received input url={url}, params={params}") response = self.http.post( url=url, json=params, - headers=dict(self.default_headers(), **headers), + headers=dict(self.default_headers(), **headers if headers else {}), timeout=self.request_timeout, data=data, )