oocana 0.16.5__py3-none-any.whl → 0.16.7__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.
- oocana/context.py +38 -7
- oocana/preview.py +14 -8
- {oocana-0.16.5.dist-info → oocana-0.16.7.dist-info}/METADATA +1 -1
- {oocana-0.16.5.dist-info → oocana-0.16.7.dist-info}/RECORD +6 -6
- {oocana-0.16.5.dist-info → oocana-0.16.7.dist-info}/WHEEL +0 -0
- {oocana-0.16.5.dist-info → oocana-0.16.7.dist-info}/entry_points.txt +0 -0
oocana/context.py
CHANGED
@@ -136,7 +136,7 @@ class Context:
|
|
136
136
|
"api_key": os.getenv("OOMOL_LLM_API_KEY", ""),
|
137
137
|
"models": os.getenv("OOMOL_LLM_MODELS", "").split(","),
|
138
138
|
}
|
139
|
-
|
139
|
+
|
140
140
|
@property
|
141
141
|
def host_info(self) -> HostInfo:
|
142
142
|
"""this is a dict contains the host information
|
@@ -145,7 +145,17 @@ class Context:
|
|
145
145
|
"gpu_vendor": os.getenv("OOMOL_HOST_GPU_VENDOR", "unknown"),
|
146
146
|
"gpu_renderer": os.getenv("OOMOL_HOST_GPU_RENDERER", "unknown"),
|
147
147
|
}
|
148
|
-
|
148
|
+
|
149
|
+
@property
|
150
|
+
def host_endpoint(self) -> str | None:
|
151
|
+
"""A host endpoint that allows containers to access services running on the host system.
|
152
|
+
|
153
|
+
Returns:
|
154
|
+
str: The host endpoint if available.
|
155
|
+
None: If the application is running in a cloud environment where no host endpoint is defined.
|
156
|
+
"""
|
157
|
+
return os.getenv("OO_HOST_ENDPOINT", None)
|
158
|
+
|
149
159
|
@property
|
150
160
|
def is_done(self) -> bool:
|
151
161
|
return self.__is_done
|
@@ -255,6 +265,11 @@ class Context:
|
|
255
265
|
)
|
256
266
|
|
257
267
|
def __dataframe(self, payload: PreviewPayload) -> PreviewPayload:
|
268
|
+
def not_default_index(df: DataFrame) -> bool:
|
269
|
+
index = df.index.tolist()
|
270
|
+
default_index = list(range(len(df)))
|
271
|
+
return index != default_index
|
272
|
+
|
258
273
|
if isinstance(payload, DataFrame):
|
259
274
|
payload = { "type": "table", "data": payload }
|
260
275
|
|
@@ -266,12 +281,28 @@ class Context:
|
|
266
281
|
data = df.to_dict(orient='split')
|
267
282
|
columns = data.get("columns", [])
|
268
283
|
rows = data.get("data", [])
|
284
|
+
if not_default_index(df):
|
285
|
+
index = df.index.tolist()
|
286
|
+
rows = [[index[i], *rows[i]] for i in range(len(rows))]
|
287
|
+
columns = ["", *columns]
|
288
|
+
|
269
289
|
elif isinstance(df, PartialDataFrame):
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
290
|
+
need_add_index = not_default_index(df)
|
291
|
+
head_data = df.head(5).to_dict(orient='split')
|
292
|
+
columns = head_data.get("columns", [])
|
293
|
+
|
294
|
+
rows_head = head_data.get("data", [])
|
295
|
+
if need_add_index:
|
296
|
+
columns = ["", *columns]
|
297
|
+
head_index = head_data.get("index", [])
|
298
|
+
rows_head = [[head_index[i], *rows_head[i]] for i in range(len(rows_head))]
|
299
|
+
|
300
|
+
tail_data = df.tail(5).to_dict(orient='split')
|
301
|
+
rows_tail = tail_data.get("data", [])
|
302
|
+
if need_add_index:
|
303
|
+
tail_index = tail_data.get("index", [])
|
304
|
+
rows_tail = [[tail_index[i], *rows_tail[i]] for i in range(len(rows_tail))]
|
305
|
+
|
275
306
|
rows_dots = [["..."] * len(columns)]
|
276
307
|
rows = rows_head + rows_dots + rows_tail
|
277
308
|
else:
|
oocana/preview.py
CHANGED
@@ -3,20 +3,26 @@ from typing import Any, TypedDict, List, Literal, TypeAlias, Union, Protocol, ru
|
|
3
3
|
|
4
4
|
__all__ = ["PreviewPayload", "TablePreviewPayload", "TextPreviewPayload", "JSONPreviewPayload", "ImagePreviewPayload", "MediaPreviewPayload", "PandasPreviewPayload", "DefaultPreviewPayload"]
|
5
5
|
|
6
|
+
@runtime_checkable
|
7
|
+
class DataFrameIndex(Protocol):
|
8
|
+
def tolist(self) -> Any:
|
9
|
+
...
|
10
|
+
|
6
11
|
# this class is for pandas.DataFrame
|
7
12
|
@runtime_checkable
|
8
13
|
class DataFrame(Protocol):
|
9
14
|
|
10
|
-
def
|
15
|
+
def __len__(self) -> int:
|
11
16
|
...
|
12
17
|
|
13
|
-
def
|
18
|
+
def __dataframe__(self, *args: Any, **kwargs: Any) -> Any:
|
14
19
|
...
|
15
20
|
|
16
|
-
@
|
17
|
-
|
21
|
+
@property
|
22
|
+
def index(self) -> DataFrameIndex:
|
23
|
+
...
|
18
24
|
|
19
|
-
def
|
25
|
+
def to_dict(self, orient: Literal["split"]) -> Any:
|
20
26
|
...
|
21
27
|
|
22
28
|
@runtime_checkable
|
@@ -27,11 +33,11 @@ class ShapeDataFrame(DataFrame, Protocol):
|
|
27
33
|
...
|
28
34
|
|
29
35
|
@runtime_checkable
|
30
|
-
class PartialDataFrame(Protocol):
|
31
|
-
def head(self,
|
36
|
+
class PartialDataFrame(DataFrame, Protocol):
|
37
|
+
def head(self, count: int) -> DataFrame:
|
32
38
|
...
|
33
39
|
|
34
|
-
def tail(self,
|
40
|
+
def tail(self, count: int) -> DataFrame:
|
35
41
|
...
|
36
42
|
|
37
43
|
class TablePreviewData(TypedDict):
|
@@ -1,13 +1,13 @@
|
|
1
|
-
oocana-0.16.
|
2
|
-
oocana-0.16.
|
3
|
-
oocana-0.16.
|
1
|
+
oocana-0.16.7.dist-info/METADATA,sha256=0_TpqDCVlfykzajr-HwTAb9844PjjmtNY9SiL93krig,221
|
2
|
+
oocana-0.16.7.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
|
3
|
+
oocana-0.16.7.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
4
4
|
oocana/__init__.py,sha256=zMrQ1asZoRE91-BShf1v2ibdThaMc07YtZt5iNbbxsg,281
|
5
|
-
oocana/context.py,sha256=
|
5
|
+
oocana/context.py,sha256=LyavX-bgqWGmQkLmE-_QNCd3aHWesShEJJToi4fc32U,14466
|
6
6
|
oocana/data.py,sha256=0KpJyckz_X5JbrncBRFbOaU00CxcDx2UYHk6xuH1Poc,2890
|
7
7
|
oocana/handle_data.py,sha256=p0iEvdsVV3BqcelM8rvq0a_VPI52SeahaGCszfhZ0TI,1927
|
8
8
|
oocana/mainframe.py,sha256=Jixk9PjvJh7PnYwPGqOR5viwcOHWfaPhEiQFNHxHCxw,5219
|
9
|
-
oocana/preview.py,sha256=
|
9
|
+
oocana/preview.py,sha256=xTyVtf5mKMVlXRwz3JSB-n4e_6dlxalkE341nUDwtD4,2027
|
10
10
|
oocana/schema.py,sha256=8LwMaW4eXa3EmKxR4kzyTOpZiClMRMMsMA6f9CXodW4,4332
|
11
11
|
oocana/service.py,sha256=dPCcScQfMBlEjIodFnKU17-HlbBzrQbQK6CNRw7SmOE,2442
|
12
12
|
oocana/throtter.py,sha256=xTldm2OZ5uYPiyC6Aatug4FJAoMylPjtXftxHvSr_50,1104
|
13
|
-
oocana-0.16.
|
13
|
+
oocana-0.16.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|