athena-intelligence 0.1.101__tar.gz → 0.1.103__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/PKG-INFO +1 -1
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/pyproject.toml +1 -1
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/client.py +73 -16
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/client_wrapper.py +1 -1
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/types/sql_unauthorized_error.py +2 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/README.md +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/__init__.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/base_client.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/__init__.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/api_error.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/datetime_utils.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/file.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/http_client.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/jsonable_encoder.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/pydantic_utilities.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/query_encoder.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/remove_none_from_dict.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/request_options.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/environment.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/errors/__init__.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/errors/internal_server_error.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/errors/not_found_error.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/errors/unauthorized_error.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/errors/unprocessable_entity_error.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/errors/unsupported_media_type_error.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/py.typed +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/query/__init__.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/query/client.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/query/types/__init__.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/query/types/query_execute_request_database_asset_ids.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/tools/__init__.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/tools/client.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/tools/types/__init__.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/tools/types/tools_data_frame_request_columns_item.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/types/__init__.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/types/data_frame_request_out.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/types/data_frame_request_out_columns_item.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/types/data_frame_request_out_data_item_item.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/types/data_frame_request_out_index_item.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/types/data_frame_unknown_format_error.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/types/file_fetch_error.py +0 -0
- {athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/version.py +0 -0
@@ -1,14 +1,17 @@
|
|
1
|
+
import enum
|
1
2
|
import io
|
2
3
|
import os
|
3
4
|
import typing
|
4
5
|
import warnings
|
5
6
|
|
6
7
|
import httpx
|
8
|
+
from typing import cast, List, Union
|
7
9
|
from typing_extensions import TypeVar, ParamSpec
|
8
10
|
|
9
11
|
from .base_client import BaseAthena, AsyncBaseAthena
|
10
12
|
from .environment import AthenaEnvironment
|
11
13
|
from .tools.client import AsyncToolsClient, ToolsClient
|
14
|
+
from .query.client import AsyncQueryClient, QueryClient
|
12
15
|
from .types.data_frame_request_out import DataFrameRequestOut
|
13
16
|
|
14
17
|
if typing.TYPE_CHECKING:
|
@@ -32,6 +35,10 @@ def _inherit_signature_and_doc(
|
|
32
35
|
return decorator
|
33
36
|
|
34
37
|
|
38
|
+
class SpecialEnvironments(enum.Enum):
|
39
|
+
AUTODETECT_ENVIRONMENT = 'AUTO'
|
40
|
+
|
41
|
+
|
35
42
|
class WrappedToolsClient(ToolsClient):
|
36
43
|
|
37
44
|
def get_file(self, asset_id: str) -> io.BytesIO:
|
@@ -89,6 +96,25 @@ class WrappedToolsClient(ToolsClient):
|
|
89
96
|
return _to_pandas_df(file_bytes, *args, **kwargs)
|
90
97
|
|
91
98
|
|
99
|
+
class WrappedQueryClient(QueryClient):
|
100
|
+
|
101
|
+
@_inherit_signature_and_doc(QueryClient.execute, {'DataFrameRequestOut': 'pd.DataFrame'})
|
102
|
+
def execute(self, *, sql_command: str, database_asset_ids: Union[str, List[str]], **kwargs) -> 'pd.DataFrame':
|
103
|
+
_check_pandas_installed()
|
104
|
+
model = super().execute(
|
105
|
+
sql_command=sql_command,
|
106
|
+
database_asset_ids=database_asset_ids,
|
107
|
+
**kwargs
|
108
|
+
)
|
109
|
+
return _read_json_frame(model)
|
110
|
+
|
111
|
+
@_inherit_signature_and_doc(QueryClient.execute_snippet, {'DataFrameRequestOut': 'pd.DataFrame'})
|
112
|
+
def execute_snippet(self, *, snippet_asset_id: str, **kwargs) -> 'pd.DataFrame':
|
113
|
+
_check_pandas_installed()
|
114
|
+
model = super().execute_snippet(snippet_asset_id=snippet_asset_id, **kwargs)
|
115
|
+
return _read_json_frame(model)
|
116
|
+
|
117
|
+
|
92
118
|
def _add_docs_for_async_variant(obj):
|
93
119
|
def decorator(decorated):
|
94
120
|
doc = obj.__doc__
|
@@ -123,6 +149,25 @@ class WrappedAsyncToolsClient(AsyncToolsClient):
|
|
123
149
|
return _to_pandas_df(file_bytes, *args, **kwargs)
|
124
150
|
|
125
151
|
|
152
|
+
class WrappedAsyncQueryClient(AsyncQueryClient):
|
153
|
+
|
154
|
+
@_inherit_signature_and_doc(AsyncQueryClient.execute, {'DataFrameRequestOut': 'pd.DataFrame'})
|
155
|
+
async def execute(self, *, sql_command: str, database_asset_ids: Union[str, List[str]], **kwargs) -> 'pd.DataFrame':
|
156
|
+
_check_pandas_installed()
|
157
|
+
model = await super().execute(
|
158
|
+
sql_command=sql_command,
|
159
|
+
database_asset_ids=database_asset_ids,
|
160
|
+
**kwargs
|
161
|
+
)
|
162
|
+
return _read_json_frame(model)
|
163
|
+
|
164
|
+
@_inherit_signature_and_doc(AsyncQueryClient.execute_snippet, {'DataFrameRequestOut': 'pd.DataFrame'})
|
165
|
+
async def execute_snippet(self, *, snippet_asset_id: str, **kwargs) -> 'pd.DataFrame':
|
166
|
+
_check_pandas_installed()
|
167
|
+
model = await super().execute_snippet(snippet_asset_id=snippet_asset_id, **kwargs)
|
168
|
+
return _read_json_frame(model)
|
169
|
+
|
170
|
+
|
126
171
|
class Athena(BaseAthena):
|
127
172
|
"""
|
128
173
|
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions.
|
@@ -133,13 +178,9 @@ class Athena(BaseAthena):
|
|
133
178
|
The base url to use for requests from the client.
|
134
179
|
|
135
180
|
environment : AthenaEnvironment
|
136
|
-
The environment to use for requests from the client.
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
Defaults to AthenaEnvironment.PRODUCTION
|
141
|
-
|
181
|
+
The environment to use for requests from the client.
|
142
182
|
|
183
|
+
Defaults to `AthenaEnvironment.PRODUCTION` when outside of athena notebook environment.
|
143
184
|
|
144
185
|
api_key: typing.Optional[str]. The API key. Required when used outside of the athena notebook environment.
|
145
186
|
timeout : typing.Optional[float]
|
@@ -163,7 +204,7 @@ class Athena(BaseAthena):
|
|
163
204
|
self,
|
164
205
|
*,
|
165
206
|
base_url: typing.Optional[str] = None,
|
166
|
-
environment: AthenaEnvironment =
|
207
|
+
environment: Union[AthenaEnvironment, SpecialEnvironments] = SpecialEnvironments.AUTODETECT_ENVIRONMENT, # type: ignore[arg-type]
|
167
208
|
api_key: typing.Optional[str] = None,
|
168
209
|
timeout: typing.Optional[float] = 60,
|
169
210
|
httpx_client: typing.Optional[httpx.Client] = None
|
@@ -176,14 +217,24 @@ class Athena(BaseAthena):
|
|
176
217
|
"Athena() missing 1 required keyword-only argument: 'api_key'"
|
177
218
|
' (ATHENA_API_KEY environment variable not found)'
|
178
219
|
)
|
220
|
+
if environment == SpecialEnvironments.AUTODETECT_ENVIRONMENT:
|
221
|
+
if 'ATHENA_API_URL' in os.environ:
|
222
|
+
|
223
|
+
class AutodetectedEnvironments(enum.Enum):
|
224
|
+
CURRENT = os.environ['ATHENA_API_URL']
|
225
|
+
|
226
|
+
environment = cast(AthenaEnvironment, AutodetectedEnvironments.CURRENT)
|
227
|
+
else:
|
228
|
+
environment = AthenaEnvironment.PRODUCTION
|
179
229
|
super().__init__(
|
180
230
|
base_url=base_url,
|
181
|
-
environment=environment,
|
231
|
+
environment=environment, # type: ignore[arg-type]
|
182
232
|
api_key=api_key,
|
183
233
|
timeout=timeout,
|
184
234
|
httpx_client=httpx_client,
|
185
235
|
)
|
186
236
|
self.tools = WrappedToolsClient(client_wrapper=self._client_wrapper)
|
237
|
+
self.query = WrappedQueryClient(client_wrapper=self._client_wrapper)
|
187
238
|
|
188
239
|
|
189
240
|
class AsyncAthena(AsyncBaseAthena):
|
@@ -197,13 +248,9 @@ class AsyncAthena(AsyncBaseAthena):
|
|
197
248
|
The base url to use for requests from the client.
|
198
249
|
|
199
250
|
environment : AthenaEnvironment
|
200
|
-
The environment to use for requests from the client.
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
Defaults to AthenaEnvironment.PRODUCTION
|
205
|
-
|
251
|
+
The environment to use for requests from the client.
|
206
252
|
|
253
|
+
Defaults to `AthenaEnvironment.PRODUCTION` when outside of athena notebook environment.
|
207
254
|
|
208
255
|
api_key: typing.Optional[str]. The API key. Required when used outside of the athena notebook environment.
|
209
256
|
timeout : typing.Optional[float]
|
@@ -227,7 +274,7 @@ class AsyncAthena(AsyncBaseAthena):
|
|
227
274
|
self,
|
228
275
|
*,
|
229
276
|
base_url: typing.Optional[str] = None,
|
230
|
-
environment: AthenaEnvironment =
|
277
|
+
environment: Union[AthenaEnvironment, SpecialEnvironments] = SpecialEnvironments.AUTODETECT_ENVIRONMENT, # type: ignore[arg-type]
|
231
278
|
api_key: typing.Optional[str] = None,
|
232
279
|
timeout: typing.Optional[float] = 60,
|
233
280
|
httpx_client: typing.Optional[httpx.AsyncClient] = None
|
@@ -240,14 +287,24 @@ class AsyncAthena(AsyncBaseAthena):
|
|
240
287
|
"AsyncAthena() missing 1 required keyword-only argument: 'api_key'"
|
241
288
|
' (ATHENA_API_KEY environment variable not found)'
|
242
289
|
)
|
290
|
+
if environment == SpecialEnvironments.AUTODETECT_ENVIRONMENT:
|
291
|
+
if 'ATHENA_API_URL' in os.environ:
|
292
|
+
|
293
|
+
class AutodetectedEnvironments(enum.Enum):
|
294
|
+
CURRENT = os.environ['ATHENA_API_URL']
|
295
|
+
|
296
|
+
environment = cast(AthenaEnvironment, AutodetectedEnvironments.CURRENT)
|
297
|
+
else:
|
298
|
+
environment = AthenaEnvironment.PRODUCTION
|
243
299
|
super().__init__(
|
244
300
|
base_url=base_url,
|
245
|
-
environment=environment,
|
301
|
+
environment=environment, # type: ignore[arg-type]
|
246
302
|
api_key=api_key,
|
247
303
|
timeout=timeout,
|
248
304
|
httpx_client=httpx_client,
|
249
305
|
)
|
250
306
|
self.tools = WrappedAsyncToolsClient(client_wrapper=self._client_wrapper)
|
307
|
+
self.query = WrappedAsyncQueryClient(client_wrapper=self._client_wrapper)
|
251
308
|
|
252
309
|
|
253
310
|
def _read_json_frame(model: DataFrameRequestOut) -> 'pd.DataFrame':
|
{athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/client_wrapper.py
RENAMED
@@ -17,7 +17,7 @@ class BaseClientWrapper:
|
|
17
17
|
headers: typing.Dict[str, str] = {
|
18
18
|
"X-Fern-Language": "Python",
|
19
19
|
"X-Fern-SDK-Name": "athena-intelligence",
|
20
|
-
"X-Fern-SDK-Version": "0.1.
|
20
|
+
"X-Fern-SDK-Version": "0.1.103",
|
21
21
|
}
|
22
22
|
headers["X-API-KEY"] = self.api_key
|
23
23
|
return headers
|
@@ -8,6 +8,8 @@ from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
|
8
8
|
|
9
9
|
|
10
10
|
class SqlUnauthorizedError(pydantic_v1.BaseModel):
|
11
|
+
message: str
|
12
|
+
|
11
13
|
def json(self, **kwargs: typing.Any) -> str:
|
12
14
|
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
13
15
|
return super().json(**kwargs_with_defaults)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/datetime_utils.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/jsonable_encoder.py
RENAMED
File without changes
|
{athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/pydantic_utilities.py
RENAMED
File without changes
|
{athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/query_encoder.py
RENAMED
File without changes
|
{athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/remove_none_from_dict.py
RENAMED
File without changes
|
{athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/core/request_options.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/errors/not_found_error.py
RENAMED
File without changes
|
{athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/errors/unauthorized_error.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/query/types/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/tools/types/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{athena_intelligence-0.1.101 → athena_intelligence-0.1.103}/src/athena/types/file_fetch_error.py
RENAMED
File without changes
|
File without changes
|