athena-intelligence 0.1.104__py3-none-any.whl → 0.1.105__py3-none-any.whl
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/client.py +73 -1
- athena/core/client_wrapper.py +1 -1
- athena/tools/client.py +2 -0
- athena/tools/types/tools_data_frame_request_columns_item.py +1 -1
- {athena_intelligence-0.1.104.dist-info → athena_intelligence-0.1.105.dist-info}/METADATA +1 -1
- {athena_intelligence-0.1.104.dist-info → athena_intelligence-0.1.105.dist-info}/RECORD +7 -7
- {athena_intelligence-0.1.104.dist-info → athena_intelligence-0.1.105.dist-info}/WHEEL +0 -0
athena/client.py
CHANGED
@@ -8,11 +8,13 @@ import httpx
|
|
8
8
|
from typing import cast, List, Union
|
9
9
|
from typing_extensions import TypeVar, ParamSpec
|
10
10
|
|
11
|
+
from . import core
|
11
12
|
from .base_client import BaseAthena, AsyncBaseAthena
|
12
13
|
from .environment import AthenaEnvironment
|
13
14
|
from .tools.client import AsyncToolsClient, ToolsClient
|
14
15
|
from .query.client import AsyncQueryClient, QueryClient
|
15
16
|
from .types.data_frame_request_out import DataFrameRequestOut
|
17
|
+
from .types.save_asset_request_out import SaveAssetRequestOut
|
16
18
|
|
17
19
|
if typing.TYPE_CHECKING:
|
18
20
|
import pandas as pd
|
@@ -96,6 +98,43 @@ class WrappedToolsClient(ToolsClient):
|
|
96
98
|
return _to_pandas_df(file_bytes, *args, **kwargs)
|
97
99
|
|
98
100
|
|
101
|
+
def save_asset( # type: ignore[override]
|
102
|
+
self,
|
103
|
+
asset_object: Union["pd.DataFrame", "pd.Series", core.File],
|
104
|
+
*,
|
105
|
+
parent_folder_id: Union[str, None] = None,
|
106
|
+
name: Union[str, None] = None,
|
107
|
+
**kwargs,
|
108
|
+
) -> SaveAssetRequestOut:
|
109
|
+
"""
|
110
|
+
Parameters
|
111
|
+
----------
|
112
|
+
asset_object : pd.DataFrame | pd.Series | core.File
|
113
|
+
A pandas data frame, series, or core.File
|
114
|
+
|
115
|
+
parent_folder_id : typing.Optional[str]
|
116
|
+
|
117
|
+
request_options : typing.Optional[RequestOptions]
|
118
|
+
Request-specific configuration.
|
119
|
+
|
120
|
+
Returns
|
121
|
+
-------
|
122
|
+
SaveAssetRequestOut
|
123
|
+
Successful Response
|
124
|
+
|
125
|
+
Examples
|
126
|
+
--------
|
127
|
+
from athena.client import Athena
|
128
|
+
|
129
|
+
client = Athena(api_key="YOUR_API_KEY")
|
130
|
+
client.tools.save_asset(df)
|
131
|
+
"""
|
132
|
+
asset_object = _convert_asset_object(asset_object=asset_object, name=name)
|
133
|
+
return super().save_asset(
|
134
|
+
file=asset_object, parent_folder_id=parent_folder_id, **kwargs
|
135
|
+
)
|
136
|
+
|
137
|
+
|
99
138
|
class WrappedQueryClient(QueryClient):
|
100
139
|
|
101
140
|
@_inherit_signature_and_doc(QueryClient.execute, {'DataFrameRequestOut': 'pd.DataFrame'})
|
@@ -148,6 +187,20 @@ class WrappedAsyncToolsClient(AsyncToolsClient):
|
|
148
187
|
file_bytes = await self.get_file(asset_id)
|
149
188
|
return _to_pandas_df(file_bytes, *args, **kwargs)
|
150
189
|
|
190
|
+
@_add_docs_for_async_variant(WrappedToolsClient.save_asset)
|
191
|
+
async def save_asset(
|
192
|
+
self,
|
193
|
+
asset_object: Union["pd.DataFrame", "pd.Series", core.File],
|
194
|
+
*,
|
195
|
+
parent_folder_id: Union[str, None] = None,
|
196
|
+
name: Union[str, None] = None,
|
197
|
+
**kwargs,
|
198
|
+
) -> SaveAssetRequestOut:
|
199
|
+
asset_object = _convert_asset_object(asset_object=asset_object, name=name)
|
200
|
+
return await super().save_asset(
|
201
|
+
file=asset_object, parent_folder_id=parent_folder_id, **kwargs
|
202
|
+
)
|
203
|
+
|
151
204
|
|
152
205
|
class WrappedAsyncQueryClient(AsyncQueryClient):
|
153
206
|
|
@@ -333,9 +386,28 @@ def _to_pandas_df(bytes_io: io.BytesIO, *args, **kwargs):
|
|
333
386
|
|
334
387
|
if media_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
|
335
388
|
return pd.read_excel(bytes_io, *args, engine='openpyxl', **kwargs)
|
389
|
+
elif media_type == 'application/vnd.apache.parquet':
|
390
|
+
return pd.read_parquet(bytes_io, *args, **kwargs)
|
336
391
|
elif media_type == 'application/vnd.ms-excel':
|
337
392
|
return pd.read_excel(bytes_io, *args, **kwargs)
|
338
|
-
elif media_type
|
393
|
+
elif media_type in {'text/csv', 'application/csv'}:
|
339
394
|
return pd.read_csv(bytes_io, *args, **kwargs)
|
340
395
|
else:
|
341
396
|
raise Exception("Unknown media type")
|
397
|
+
|
398
|
+
|
399
|
+
def _convert_asset_object(
|
400
|
+
asset_object: Union["pd.DataFrame", "pd.Series", core.File],
|
401
|
+
name: Union[str, None] = None,
|
402
|
+
) -> core.File:
|
403
|
+
import pandas as pd
|
404
|
+
|
405
|
+
if isinstance(asset_object, pd.Series):
|
406
|
+
asset_object = asset_object.to_frame()
|
407
|
+
if isinstance(asset_object, pd.DataFrame):
|
408
|
+
return (
|
409
|
+
name or "Uploaded data frame",
|
410
|
+
asset_object.to_parquet(path=None),
|
411
|
+
"application/vnd.apache.parquet",
|
412
|
+
)
|
413
|
+
return asset_object # type: ignore[return-value]
|
athena/core/client_wrapper.py
CHANGED
@@ -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.105",
|
21
21
|
}
|
22
22
|
headers["X-API-KEY"] = self.api_key
|
23
23
|
return headers
|
athena/tools/client.py
CHANGED
@@ -179,6 +179,7 @@ class ToolsClient:
|
|
179
179
|
See core.File for more documentation
|
180
180
|
|
181
181
|
parent_folder_id : typing.Optional[str]
|
182
|
+
Identifier of the folder into which the asset should be saved
|
182
183
|
|
183
184
|
request_options : typing.Optional[RequestOptions]
|
184
185
|
Request-specific configuration.
|
@@ -373,6 +374,7 @@ class AsyncToolsClient:
|
|
373
374
|
See core.File for more documentation
|
374
375
|
|
375
376
|
parent_folder_id : typing.Optional[str]
|
377
|
+
Identifier of the folder into which the asset should be saved
|
376
378
|
|
377
379
|
request_options : typing.Optional[RequestOptions]
|
378
380
|
Request-specific configuration.
|
@@ -1,9 +1,9 @@
|
|
1
1
|
athena/__init__.py,sha256=EtDa2cZbHfqJnBxCrjErWF1oJWH0cbJbFB7bkxeOFnE,1392
|
2
2
|
athena/base_client.py,sha256=TlP599mOBvj7Tk8IpFe5dgrDM98GJu3lEQh_zwl4vtA,5439
|
3
|
-
athena/client.py,sha256=
|
3
|
+
athena/client.py,sha256=9hj9SzW7OhAIY8yKHA0WObOtx8-1W4aLSHduqkBHJT0,14722
|
4
4
|
athena/core/__init__.py,sha256=UFXpYzcGxWQUucU1TkjOQ9mGWN3A5JohluOIWVYKU4I,973
|
5
5
|
athena/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
|
6
|
-
athena/core/client_wrapper.py,sha256=
|
6
|
+
athena/core/client_wrapper.py,sha256=ijXhms74o95_1sms0mC87d_xv0uBTKXzxH7pmz9YEKE,1806
|
7
7
|
athena/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
|
8
8
|
athena/core/file.py,sha256=sy1RUGZ3aJYuw998bZytxxo6QdgKmlnlgBaMvwEKCGg,1480
|
9
9
|
athena/core/http_client.py,sha256=Z4NuAsJD-51yqmoME17O5sxwx5orSp1wsnd6bPyKcgA,17768
|
@@ -27,9 +27,9 @@ athena/query/client.py,sha256=GYvBV7YFYjL3gyskeF6C8BJZlLvU7R045gJ5kGiYkvg,9043
|
|
27
27
|
athena/query/types/__init__.py,sha256=WX-Or2h5NY2sv93ojrZsHcmiFHGYdqd0yxNo-5iGHR4,206
|
28
28
|
athena/query/types/query_execute_request_database_asset_ids.py,sha256=aoVl5Xb34Q27hYGuVTnByGIxtHkL67wAwzXh7eJctew,154
|
29
29
|
athena/tools/__init__.py,sha256=3n7oOoMebo06MAQqYRE2CX9Q0fTNnKBYE0cTlh1MPkM,165
|
30
|
-
athena/tools/client.py,sha256=
|
30
|
+
athena/tools/client.py,sha256=5oFszmOEfdzZJNV5QHjkdyThhEswWAnWXObmK8halkE,16114
|
31
31
|
athena/tools/types/__init__.py,sha256=cA-ZQm6veQAP3_vKu9KkZpISsQqgTBN_Z--FGY1c2iA,197
|
32
|
-
athena/tools/types/tools_data_frame_request_columns_item.py,sha256=
|
32
|
+
athena/tools/types/tools_data_frame_request_columns_item.py,sha256=GA1FUlTV_CfSc-KToTAwFf4Exl0rr4fsweVZupztjw0,138
|
33
33
|
athena/types/__init__.py,sha256=rN0nC7uMZooYmwp7F7rSIb4tIaH2bIr_yd5P1c7e-XY,939
|
34
34
|
athena/types/asset_not_found_error.py,sha256=ZcgqRuzvO4Z8vVVxwtDB-QtKhpVIVV3hqQuJeUoOoJE,1121
|
35
35
|
athena/types/data_frame_request_out.py,sha256=1CEBe-baDQi0uz_EgMw0TKGYXGj6KV44cL3ViRTZLKM,1669
|
@@ -41,6 +41,6 @@ athena/types/file_too_large_error.py,sha256=AinkrcgR7lcTILAD8RX0x48P3GlSoAh1Oihx
|
|
41
41
|
athena/types/parent_folder_error.py,sha256=ZMF-i3mZY6Mu1n5uQ60Q3mIIfehlWuXtgFUkSYspkx8,1120
|
42
42
|
athena/types/save_asset_request_out.py,sha256=5bpBaUV3oeuL_hz4s07c-6MQHkn4cBsyxgT_SD5oi6I,1193
|
43
43
|
athena/version.py,sha256=8aYAOJtVLaJLpRp6mTiEIhnl8gXA7yE0aDtZ-3mKQ4k,87
|
44
|
-
athena_intelligence-0.1.
|
45
|
-
athena_intelligence-0.1.
|
46
|
-
athena_intelligence-0.1.
|
44
|
+
athena_intelligence-0.1.105.dist-info/METADATA,sha256=0-dSyqtK9SICscX0vlve617c46HjDvYdj6NdWuZcn9k,5274
|
45
|
+
athena_intelligence-0.1.105.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
46
|
+
athena_intelligence-0.1.105.dist-info/RECORD,,
|
File without changes
|