Skip to content

Commit 81e8f8f

Browse files
Update documentation (#437)
Co-authored-by: daniil-quix <[email protected]>
1 parent 5a68b3b commit 81e8f8f

File tree

4 files changed

+933
-67
lines changed

4 files changed

+933
-67
lines changed

docs/api-reference/application.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class Application()
1111
```
1212

13-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L56)
13+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L57)
1414

1515
The main Application class.
1616

@@ -84,7 +84,7 @@ def __init__(broker_address: Optional[Union[str, ConnectionConfig]] = None,
8484
processing_guarantee: ProcessingGuarantee = "at-least-once")
8585
```
8686

87-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L94)
87+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L95)
8888

8989

9090
<br>
@@ -196,7 +196,7 @@ def Quix(
196196
) -> Self
197197
```
198198

199-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L342)
199+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L347)
200200

201201
>***NOTE:*** DEPRECATED: use Application with `quix_sdk_token` argument instead.
202202

@@ -307,7 +307,7 @@ def topic(name: str,
307307
timestamp_extractor: Optional[TimestampExtractor] = None) -> Topic
308308
```
309309

310-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L483)
310+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L488)
311311

312312
Create a topic definition.
313313

@@ -388,7 +388,7 @@ topic = app.topic("input-topic", timestamp_extractor=custom_ts_extractor)
388388
def dataframe(topic: Topic) -> StreamingDataFrame
389389
```
390390

391-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L563)
391+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L568)
392392

393393
A simple helper method that generates a `StreamingDataFrame`, which is used
394394

@@ -438,7 +438,7 @@ to be used as an input topic.
438438
def stop(fail: bool = False)
439439
```
440440

441-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L602)
441+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L607)
442442

443443
Stop the internal poll loop and the message processing.
444444

@@ -465,7 +465,7 @@ to unhandled exception, and it shouldn't commit the current checkpoint.
465465
def get_producer() -> Producer
466466
```
467467

468-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L625)
468+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L630)
469469

470470
Create and return a pre-configured Producer instance.
471471
The Producer is initialized with params passed to Application.
@@ -500,7 +500,7 @@ with app.get_producer() as producer:
500500
def get_consumer(auto_commit_enable: bool = True) -> Consumer
501501
```
502502

503-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L655)
503+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L660)
504504

505505
Create and return a pre-configured Consumer instance.
506506
The Consumer is initialized with params passed to Application.
@@ -549,7 +549,7 @@ with app.get_consumer() as consumer:
549549
def clear_state()
550550
```
551551

552-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L702)
552+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L707)
553553

554554
Clear the state of the application.
555555

@@ -563,7 +563,7 @@ Clear the state of the application.
563563
def run(dataframe: StreamingDataFrame)
564564
```
565565

566-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L708)
566+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L713)
567567

568568
Start processing data from Kafka using provided `StreamingDataFrame`
569569

docs/api-reference/dataframe.md

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class StreamingDataFrame(BaseStreaming)
1111
```
1212

13-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L63)
13+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L86)
1414

1515
`StreamingDataFrame` is the main object you will use for ETL work.
1616

@@ -69,6 +69,7 @@ sdf = sdf.to_topic(topic_obj)
6969
#### StreamingDataFrame.apply
7070

7171
```python
72+
@_ensure_unlocked
7273
def apply(func: Union[
7374
ApplyCallback,
7475
ApplyCallbackStateful,
@@ -81,7 +82,7 @@ def apply(func: Union[
8182
metadata: bool = False) -> Self
8283
```
8384

84-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L178)
85+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L203)
8586

8687
Apply a function to transform the value and return a new value.
8788

@@ -128,6 +129,7 @@ Default - `False`.
128129
#### StreamingDataFrame.update
129130

130131
```python
132+
@_ensure_unlocked
131133
def update(func: Union[
132134
UpdateCallback,
133135
UpdateCallbackStateful,
@@ -139,7 +141,7 @@ def update(func: Union[
139141
metadata: bool = False) -> Self
140142
```
141143

142-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L267)
144+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L293)
143145

144146
Apply a function to mutate value in-place or to perform a side effect
145147

@@ -196,6 +198,7 @@ the updated StreamingDataFrame instance (reassignment NOT required).
196198
#### StreamingDataFrame.filter
197199

198200
```python
201+
@_ensure_unlocked
199202
def filter(func: Union[
200203
FilterCallback,
201204
FilterCallbackStateful,
@@ -207,7 +210,7 @@ def filter(func: Union[
207210
metadata: bool = False) -> Self
208211
```
209212

210-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L359)
213+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L386)
211214

212215
Filter value using provided function.
213216

@@ -251,6 +254,7 @@ Default - `False`.
251254
#### StreamingDataFrame.group\_by
252255

253256
```python
257+
@_ensure_unlocked
254258
def group_by(key: Union[str, Callable[[Any], Any]],
255259
name: Optional[str] = None,
256260
value_deserializer: Optional[DeserializerType] = "json",
@@ -259,7 +263,7 @@ def group_by(key: Union[str, Callable[[Any], Any]],
259263
key_serializer: Optional[SerializerType] = "json") -> Self
260264
```
261265

262-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L445)
266+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L473)
263267

264268
"Groups" messages by re-keying them via the provided group_by operation
265269

@@ -324,7 +328,7 @@ a clone with this operation added (assign to keep its effect).
324328
def contains(key: str) -> StreamingSeries
325329
```
326330

327-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L523)
331+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L551)
328332

329333
Check if the key is present in the Row value.
330334

@@ -360,10 +364,11 @@ or False otherwise.
360364
#### StreamingDataFrame.to\_topic
361365

362366
```python
367+
@_ensure_unlocked
363368
def to_topic(topic: Topic, key: Optional[Callable[[Any], Any]] = None) -> Self
364369
```
365370

366-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L548)
371+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L577)
367372

368373
Produce current value to a topic. You can optionally specify a new key.
369374

@@ -413,10 +418,11 @@ the updated StreamingDataFrame instance (reassignment NOT required).
413418
#### StreamingDataFrame.set\_timestamp
414419

415420
```python
421+
@_ensure_unlocked
416422
def set_timestamp(func: Callable[[Any, Any, int, Any], int]) -> Self
417423
```
418424

419-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L593)
425+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L623)
420426

421427
Set a new timestamp based on the current message value and its metadata.
422428

@@ -461,6 +467,7 @@ a new StreamingDataFrame instance
461467
#### StreamingDataFrame.set\_headers
462468

463469
```python
470+
@_ensure_unlocked
464471
def set_headers(
465472
func: Callable[
466473
[Any, Any, int, List[Tuple[str, HeaderValue]]],
@@ -469,7 +476,7 @@ def set_headers(
469476
) -> Self
470477
```
471478

472-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L634)
479+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L665)
473480

474481
Set new message headers based on the current message value and metadata.
475482

@@ -515,10 +522,11 @@ a new StreamingDataFrame instance
515522
#### StreamingDataFrame.print
516523

517524
```python
525+
@_ensure_unlocked
518526
def print(pretty: bool = True, metadata: bool = False) -> Self
519527
```
520528

521-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L685)
529+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L717)
522530

523531
Print out the current message value (and optionally, the message metadata) to
524532

@@ -574,7 +582,7 @@ def compose(
574582
) -> Dict[str, VoidExecutor]
575583
```
576584

577-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L727)
585+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L759)
578586

579587
Compose all functions of this StreamingDataFrame into one big closure.
580588

@@ -628,7 +636,7 @@ def test(value: Any,
628636
topic: Optional[Topic] = None) -> List[Any]
629637
```
630638

631-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L764)
639+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L796)
632640

633641
A shorthand to test `StreamingDataFrame` with provided value
634642

@@ -660,12 +668,13 @@ result of `StreamingDataFrame`
660668
#### StreamingDataFrame.tumbling\_window
661669

662670
```python
671+
@_ensure_unlocked
663672
def tumbling_window(duration_ms: Union[int, timedelta],
664673
grace_ms: Union[int, timedelta] = 0,
665674
name: Optional[str] = None) -> TumblingWindowDefinition
666675
```
667676

668-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L801)
677+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L834)
669678

670679
Create a tumbling window transformation on this StreamingDataFrame.
671680

@@ -745,13 +754,14 @@ sdf = (
745754
#### StreamingDataFrame.hopping\_window
746755

747756
```python
757+
@_ensure_unlocked
748758
def hopping_window(duration_ms: Union[int, timedelta],
749759
step_ms: Union[int, timedelta],
750760
grace_ms: Union[int, timedelta] = 0,
751761
name: Optional[str] = None) -> HoppingWindowDefinition
752762
```
753763

754-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L877)
764+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L911)
755765

756766
Create a hopping window transformation on this StreamingDataFrame.
757767

@@ -840,11 +850,12 @@ sdf = (
840850
#### StreamingDataFrame.drop
841851

842852
```python
853+
@_ensure_unlocked
843854
def drop(columns: Union[str, List[str]],
844855
errors: Literal["ignore", "raise"] = "raise") -> Self
845856
```
846857

847-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L969)
858+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L1004)
848859

849860
Drop column(s) from the message value (value must support `del`, like a dict).
850861

@@ -878,6 +889,35 @@ Default - `"raise"`.
878889

879890
a new StreamingDataFrame instance
880891

892+
<a id="quixstreams.dataframe.dataframe.StreamingDataFrame.sink"></a>
893+
894+
<br><br>
895+
896+
#### StreamingDataFrame.sink
897+
898+
```python
899+
@_ensure_unlocked
900+
def sink(sink: BaseSink)
901+
```
902+
903+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/dataframe/dataframe.py#L1049)
904+
905+
Sink the processed data to the specified destination.
906+
907+
Internally, each processed record is added to a sink, and the sinks are
908+
flushed on each checkpoint.
909+
The offset will be committed only if all the sinks for all topic partitions
910+
are flushed successfully.
911+
912+
Additionally, Sinks may signal the backpressure to the application
913+
(e.g., when the destination is rate-limited).
914+
When this happens, the application will pause the corresponding topic partition
915+
and resume again after the timeout.
916+
The backpressure handling and timeouts are defined by the specific sinks.
917+
918+
Note: `sink()` is a terminal operation, and you cannot add new operations
919+
to the same StreamingDataFrame after it's called.
920+
881921
<a id="quixstreams.dataframe.series"></a>
882922

883923
## quixstreams.dataframe.series

0 commit comments

Comments
 (0)