athena-intelligence 0.1.88__py3-none-any.whl → 0.1.90__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 CHANGED
@@ -21,42 +21,103 @@ T = TypeVar("T")
21
21
  U = TypeVar('U')
22
22
 
23
23
 
24
- def _inherit_signature(f: typing.Callable[P, T]) -> typing.Callable[..., typing.Callable[P, U]]:
25
- return lambda x: x
24
+ def _inherit_signature_and_doc(
25
+ f: typing.Callable[P, T],
26
+ replace_in_doc: typing.Dict[str, str]
27
+ ) -> typing.Callable[..., typing.Callable[P, U]]:
28
+ def decorator(decorated):
29
+ for old, new in replace_in_doc.items():
30
+ assert old in f.__doc__
31
+ decorated.__doc__ = f.__doc__.replace(old, new)
32
+ return decorated
33
+ return decorator
26
34
 
27
35
 
28
36
  class WrappedToolsClient(ToolsClient):
29
37
 
30
38
  def get_file(self, document_id: str) -> io.BytesIO:
39
+ """
40
+ Parameters
41
+ ----------
42
+ document_id : str
43
+
44
+ Returns
45
+ -------
46
+ io.BytesIO
47
+
48
+ Examples
49
+ --------
50
+ import polars as pl
51
+ from athena.client import Athena
52
+
53
+ client = Athena(api_key="YOUR_API_KEY")
54
+ file_io = client.tools.get_file(document_id="document_id")
55
+ pl.read_csv(file_io)
56
+ """
31
57
  file_bytes = b''.join(self.raw_data(document_id=document_id))
32
58
  bytes_io = io.BytesIO(file_bytes)
33
59
  return bytes_io
34
60
 
35
- @_inherit_signature(ToolsClient.data_frame)
61
+ @_inherit_signature_and_doc(ToolsClient.data_frame, {'DataFrameRequestOut': 'pd.DataFrame'})
36
62
  def data_frame(self, *, document_id: str, **kwargs) -> 'pd.DataFrame':
37
63
  _check_pandas_installed()
38
64
  model = super().data_frame(document_id=document_id, **kwargs)
39
65
  return _read_json_frame(model)
40
66
 
41
67
  def read_data_frame(self, document_id: str, *args, **kwargs) -> 'pd.DataFrame':
68
+ """
69
+ Parameters
70
+ ----------
71
+ document_id : str
72
+
73
+ **kwargs : dict
74
+ keyword arguments passed to pandas `read_csv` or `read_excel` function,
75
+ depending on the file type of the document identified by `document_id`.
76
+
77
+ Returns
78
+ -------
79
+ pd.DataFrame
80
+
81
+ Examples
82
+ --------
83
+ from athena.client import Athena
84
+
85
+ client = Athena(api_key="YOUR_API_KEY")
86
+ client.tools.read_data_frame(document_id="document_id")
87
+ """
42
88
  _check_pandas_installed()
43
89
  file_bytes = self.get_file(document_id)
44
90
  return _to_pandas_df(file_bytes, *args, **kwargs)
45
91
 
46
92
 
93
+ def _add_docs_for_async_variant(obj):
94
+ def decorator(decorated):
95
+ doc = obj.__doc__
96
+ name = obj.__name__
97
+ decorated.__doc__ = (
98
+ doc
99
+ .replace('client = Athena', 'client = AsyncAthena')
100
+ .replace(f'client.tools.{name}', f'await client.tools.{name}')
101
+ )
102
+ return decorated
103
+ return decorator
104
+
105
+
47
106
  class WrappedAsyncToolsClient(AsyncToolsClient):
48
107
 
108
+ @_add_docs_for_async_variant(WrappedToolsClient.get_file)
49
109
  async def get_file(self, document_id: str) -> io.BytesIO:
50
110
  file_bytes = b''.join([gen async for gen in self.raw_data(document_id=document_id)])
51
111
  bytes_io = io.BytesIO(file_bytes)
52
112
  return bytes_io
53
113
 
54
- @_inherit_signature(ToolsClient.data_frame)
114
+ @_inherit_signature_and_doc(AsyncToolsClient.data_frame, {'DataFrameRequestOut': 'pd.DataFrame'})
55
115
  async def data_frame(self, *, document_id: str, **kwargs) -> 'pd.DataFrame':
56
116
  _check_pandas_installed()
57
117
  model = await super().data_frame(document_id=document_id, **kwargs)
58
118
  return _read_json_frame(model)
59
119
 
120
+ @_add_docs_for_async_variant(WrappedToolsClient.read_data_frame)
60
121
  async def read_data_frame(self, document_id: str, *args, **kwargs) -> 'pd.DataFrame':
61
122
  _check_pandas_installed()
62
123
  file_bytes = await self.get_file(document_id)
@@ -83,7 +144,7 @@ class Athena(BaseAthena):
83
144
 
84
145
  api_key: typing.Optional[str]. The API key. Required when used outside of the athena notebook environment.
85
146
  timeout : typing.Optional[float]
86
- The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set.
147
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
87
148
 
88
149
  httpx_client : typing.Optional[httpx.Client]
89
150
  The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
@@ -97,6 +158,8 @@ class Athena(BaseAthena):
97
158
  )
98
159
  """
99
160
 
161
+ tools: WrappedToolsClient
162
+
100
163
  def __init__(
101
164
  self,
102
165
  *,
@@ -147,7 +210,7 @@ class AsyncAthena(AsyncBaseAthena):
147
210
 
148
211
  api_key: typing.Optional[str]. The API key. Required when used outside of the athena notebook environment.
149
212
  timeout : typing.Optional[float]
150
- The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set.
213
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
151
214
 
152
215
  httpx_client : typing.Optional[httpx.AsyncClient]
153
216
  The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
@@ -161,6 +224,8 @@ class AsyncAthena(AsyncBaseAthena):
161
224
  )
162
225
  """
163
226
 
227
+ tools: WrappedAsyncToolsClient
228
+
164
229
  def __init__(
165
230
  self,
166
231
  *,
@@ -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.88",
20
+ "X-Fern-SDK-Version": "0.1.90",
21
21
  }
22
22
  headers["X-API-KEY"] = self.api_key
23
23
  return headers
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: athena-intelligence
3
- Version: 0.1.88
3
+ Version: 0.1.90
4
4
  Summary: Athena Intelligence Python Library
5
5
  Requires-Python: >=3.8,<4.0
6
6
  Classifier: Intended Audience :: Developers
@@ -2,10 +2,10 @@ athena/__init__.py,sha256=vS1F7G3hdiHGM-q24LBoKf77EHpaDBrb3ZzM_sgXoGY,2801
2
2
  athena/base_client.py,sha256=yP2dIc8ja04pFizBx5xF4qhkeOPJ3V9DMfqYcW5HIGg,7119
3
3
  athena/chain/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
4
4
  athena/chain/client.py,sha256=5YJJsXnXLFbPN1y0Qe__QWoQ2QOMp6zK_is_obk7Gg8,11105
5
- athena/client.py,sha256=evktoequsijpv_bKJP4IPLog2E7VhgDL1AgOgJ2tq_0,7833
5
+ athena/client.py,sha256=piHOo-a8KiuQnBCsJ509zSRahXd6DCaxkzaqqTbNWME,9680
6
6
  athena/core/__init__.py,sha256=UFXpYzcGxWQUucU1TkjOQ9mGWN3A5JohluOIWVYKU4I,973
7
7
  athena/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
8
- athena/core/client_wrapper.py,sha256=8dklUiRaBWUyJzo_CO2DsA6Syg_QwA5TK65GlyOeOTA,1805
8
+ athena/core/client_wrapper.py,sha256=ADV3_Uf4JxBw9Vczm9GQW32We6mpjtI9ahr081hxo6g,1805
9
9
  athena/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
10
10
  athena/core/file.py,sha256=sy1RUGZ3aJYuw998bZytxxo6QdgKmlnlgBaMvwEKCGg,1480
11
11
  athena/core/http_client.py,sha256=Z4NuAsJD-51yqmoME17O5sxwx5orSp1wsnd6bPyKcgA,17768
@@ -87,6 +87,6 @@ athena/upload/client.py,sha256=Z44mBN3Vg_HG4uOqrzBkkNhCGETjsAlbU1RA50KDxkQ,3897
87
87
  athena/version.py,sha256=8aYAOJtVLaJLpRp6mTiEIhnl8gXA7yE0aDtZ-3mKQ4k,87
88
88
  athena/workflow/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
89
89
  athena/workflow/client.py,sha256=1WGH4MCnwae5Wgb7pGfiyZRr--HscVpdHxeouNSyPe0,4023
90
- athena_intelligence-0.1.88.dist-info/METADATA,sha256=6GXX6FETmic5jhaAoWrnqS7zmrLk0LVu9eqL6yR4B_I,5273
91
- athena_intelligence-0.1.88.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
92
- athena_intelligence-0.1.88.dist-info/RECORD,,
90
+ athena_intelligence-0.1.90.dist-info/METADATA,sha256=0GdM4W4QOMBcDGBM97xrlEDacHScr7tDV2WgXEcwVFc,5273
91
+ athena_intelligence-0.1.90.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
92
+ athena_intelligence-0.1.90.dist-info/RECORD,,