feldera 0.162.0__py3-none-any.whl → 0.163.0__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.
- feldera/_callback_runner.py +32 -27
- feldera/output_handler.py +13 -1
- feldera/pipeline.py +3 -1
- {feldera-0.162.0.dist-info → feldera-0.163.0.dist-info}/METADATA +1 -1
- {feldera-0.162.0.dist-info → feldera-0.163.0.dist-info}/RECORD +7 -7
- {feldera-0.162.0.dist-info → feldera-0.163.0.dist-info}/WHEEL +0 -0
- {feldera-0.162.0.dist-info → feldera-0.163.0.dist-info}/top_level.txt +0 -0
feldera/_callback_runner.py
CHANGED
|
@@ -14,6 +14,7 @@ class CallbackRunner(Thread):
|
|
|
14
14
|
pipeline_name: str,
|
|
15
15
|
view_name: str,
|
|
16
16
|
callback: Callable[[pd.DataFrame, int], None],
|
|
17
|
+
exception_callback: Callable[[BaseException], None],
|
|
17
18
|
):
|
|
18
19
|
super().__init__()
|
|
19
20
|
self.daemon = True
|
|
@@ -21,6 +22,7 @@ class CallbackRunner(Thread):
|
|
|
21
22
|
self.pipeline_name: str = pipeline_name
|
|
22
23
|
self.view_name: str = view_name
|
|
23
24
|
self.callback: Callable[[pd.DataFrame, int], None] = callback
|
|
25
|
+
self.exception_callback: Callable[[BaseException], None] = exception_callback
|
|
24
26
|
self.schema: Optional[dict] = None
|
|
25
27
|
|
|
26
28
|
def run(self):
|
|
@@ -30,35 +32,38 @@ class CallbackRunner(Thread):
|
|
|
30
32
|
:meta private:
|
|
31
33
|
"""
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
self.
|
|
35
|
-
|
|
35
|
+
try:
|
|
36
|
+
pipeline = self.client.get_pipeline(
|
|
37
|
+
self.pipeline_name, PipelineFieldSelector.ALL
|
|
38
|
+
)
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
schemas = pipeline.tables + pipeline.views
|
|
41
|
+
for schema in schemas:
|
|
42
|
+
if schema.name == self.view_name:
|
|
43
|
+
self.schema = schema
|
|
44
|
+
break
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
if self.schema is None:
|
|
47
|
+
raise ValueError(
|
|
48
|
+
f"Table or View {self.view_name} not found in the pipeline schema."
|
|
49
|
+
)
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
gen_obj = self.client.listen_to_pipeline(
|
|
52
|
+
self.pipeline_name,
|
|
53
|
+
self.view_name,
|
|
54
|
+
format="json",
|
|
55
|
+
case_sensitive=self.schema.case_sensitive,
|
|
56
|
+
)
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
iterator = gen_obj()
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
for chunk in iterator:
|
|
61
|
+
chunk: dict = chunk
|
|
62
|
+
data: Optional[list[dict]] = chunk.get("json_data")
|
|
63
|
+
seq_no: Optional[int] = chunk.get("sequence_number")
|
|
64
|
+
if data is not None and seq_no is not None:
|
|
65
|
+
self.callback(
|
|
66
|
+
dataframe_from_response([data], self.schema.fields), seq_no
|
|
67
|
+
)
|
|
68
|
+
except BaseException as e:
|
|
69
|
+
self.exception_callback(e)
|
feldera/output_handler.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import pandas as pd
|
|
2
2
|
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
3
5
|
from feldera import FelderaClient
|
|
4
6
|
from feldera._callback_runner import CallbackRunner
|
|
5
7
|
|
|
@@ -20,15 +22,23 @@ class OutputHandler:
|
|
|
20
22
|
self.pipeline_name: str = pipeline_name
|
|
21
23
|
self.view_name: str = view_name
|
|
22
24
|
self.buffer: list[pd.DataFrame] = []
|
|
25
|
+
self.exception: Optional[BaseException] = None
|
|
23
26
|
|
|
24
27
|
# the callback that is passed to the `CallbackRunner`
|
|
25
28
|
def callback(df: pd.DataFrame, _: int):
|
|
26
29
|
if not df.empty:
|
|
27
30
|
self.buffer.append(df)
|
|
28
31
|
|
|
32
|
+
def exception_callback(exception: BaseException):
|
|
33
|
+
self.exception = exception
|
|
34
|
+
|
|
29
35
|
# sets up the callback runner
|
|
30
36
|
self.handler = CallbackRunner(
|
|
31
|
-
self.client,
|
|
37
|
+
self.client,
|
|
38
|
+
self.pipeline_name,
|
|
39
|
+
self.view_name,
|
|
40
|
+
callback,
|
|
41
|
+
exception_callback,
|
|
32
42
|
)
|
|
33
43
|
|
|
34
44
|
def start(self):
|
|
@@ -45,6 +55,8 @@ class OutputHandler:
|
|
|
45
55
|
:param clear_buffer: Whether to clear the buffer after getting the output.
|
|
46
56
|
"""
|
|
47
57
|
|
|
58
|
+
if self.exception is not None:
|
|
59
|
+
raise self.exception
|
|
48
60
|
if len(self.buffer) == 0:
|
|
49
61
|
return pd.DataFrame()
|
|
50
62
|
res = pd.concat(self.buffer, ignore_index=True)
|
feldera/pipeline.py
CHANGED
|
@@ -269,7 +269,9 @@ class Pipeline:
|
|
|
269
269
|
if self.status() not in [PipelineStatus.RUNNING, PipelineStatus.PAUSED]:
|
|
270
270
|
raise RuntimeError("Pipeline must be running or paused to listen to output")
|
|
271
271
|
|
|
272
|
-
handler = CallbackRunner(
|
|
272
|
+
handler = CallbackRunner(
|
|
273
|
+
self.client, self.name, view_name, callback, lambda exception: None
|
|
274
|
+
)
|
|
273
275
|
handler.start()
|
|
274
276
|
|
|
275
277
|
def wait_for_completion(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
feldera/__init__.py,sha256=EiY3bTj_mnfNhCGrZo6J__brfovIJ-YYAdy77PyaEoo,378
|
|
2
|
-
feldera/_callback_runner.py,sha256=
|
|
2
|
+
feldera/_callback_runner.py,sha256=aa-CVfIxZMqfFDs1q7MGEL77org2n0BrFgUp_ye_ohY,2333
|
|
3
3
|
feldera/_helpers.py,sha256=TQnDQW19fpljD19ppd5dASy1gUC4y8GNnnJjXxbaUmM,3019
|
|
4
4
|
feldera/enums.py,sha256=doBJtWI3ihMr5oPOe_Xvf3roSYLRDhIOG3MNg6JeGaw,8401
|
|
5
|
-
feldera/output_handler.py,sha256=
|
|
6
|
-
feldera/pipeline.py,sha256=
|
|
5
|
+
feldera/output_handler.py,sha256=J3Z3w3JG_hDGO-42FMHk34HrI20zwBI9upNAN04pi40,2118
|
|
6
|
+
feldera/pipeline.py,sha256=0MnwVcggQ8Fb8lQf4PIZ-Euw7oaJaew_HUK6DuC6mek,47859
|
|
7
7
|
feldera/pipeline_builder.py,sha256=nOKoMyB47YxwrrvByKGn4CagO-dMQNFip3c5PK1DDhQ,4351
|
|
8
8
|
feldera/runtime_config.py,sha256=w6rPkZyijca9jY1G8PKeqP8txXjnn5MPJYmM7B8iE3U,4602
|
|
9
9
|
feldera/stats.py,sha256=YeDQwE_CixTMb2DjBCgt5jTaJAZRsrHtG-3pYuuII-8,5256
|
|
@@ -20,7 +20,7 @@ feldera/rest/pipeline.py,sha256=BvFJnfgZ5b38AtRa9XpZtLQ-rnXlFdLKIgO4DN4wv-E,3625
|
|
|
20
20
|
feldera/rest/sql_table.py,sha256=qrw-YwMzx5T81zDefNO1KOx7EyypFz1vPwGBzSUB7kc,652
|
|
21
21
|
feldera/rest/sql_view.py,sha256=hN12mPM0mvwLCIPYywpb12s9Hd2Ws31IlTMXPriMisw,644
|
|
22
22
|
feldera/tests/test_datafusionize.py,sha256=NGriTaTWf_WnXFud1wmpFwLFa_-XGjfCh6La3dWc3QA,1337
|
|
23
|
-
feldera-0.
|
|
24
|
-
feldera-0.
|
|
25
|
-
feldera-0.
|
|
26
|
-
feldera-0.
|
|
23
|
+
feldera-0.163.0.dist-info/METADATA,sha256=CTSaAplw8eiCV3E624jRZ6X4Q4Egkh_M-CgPCxlYfbs,2306
|
|
24
|
+
feldera-0.163.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
+
feldera-0.163.0.dist-info/top_level.txt,sha256=fB6yTqrQiO6RCbY1xP2T_mpPoTjDFtJvkJJodiee7d0,8
|
|
26
|
+
feldera-0.163.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|