Skip to content

Commit 63dcd6b

Browse files
authored
update/rebuild docs for 3.0.0 final (#539)
documentation overhaul and rebuild for v3.0.0 release
1 parent 9522660 commit 63dcd6b

14 files changed

+5086
-5292
lines changed

docs/advanced/dataframe-assignments.md

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,67 @@
33
This section aggregates some of the more nuanced rules behind `StreamingDataFrame`
44
operation assignments that are mentioned in various places.
55

6+
7+
## Recommendation: Always Assign Operations!
8+
9+
_**You can safely assign any `StreamingDataFrame` operation to a variable, regardless
10+
of it being [in-place](#valid-in-place-operations) or not.**_
11+
12+
```python
13+
# NOTE: this is an incomplete stub just to show usage
14+
from quixstreams import Application
15+
16+
sdf = Application().dataframe()
17+
sdf = sdf.apply()
18+
sdf = sdf.update() # in-place with assigning!
19+
sdf = sdf.apply().to_topic()
20+
```
21+
22+
So whenever in doubt, simply assign operations to a variable, even if it won't
23+
be referenced afterward.
24+
25+
Once you grow more comfortable with how the various `StreamingDataFrame`operations work,
26+
feel free to skip assignments where applicable.
27+
28+
The only time you should _not_ do assignments is [very special edge cases with
29+
intermediate operation referencing](#avoid-intermediate-operation-referencing).
30+
31+
## Avoid: Intermediate Operation Referencing
32+
33+
Intermediate operation referencing corresponds to a specific set of `StreamingDataFrame`
34+
operations that are assigned as a variable in one assignment step with the intention to
35+
being used in future ones (often more than once), especially with branching.
36+
37+
It will NOT work as expected, so avoid it!
38+
39+
It applies only to a few specific use cases:
40+
41+
1. Using a previous `SDF.apply()` as a filter in a later step:
42+
- **Recommended**:
43+
```python
44+
# `.apply()` in the same assignment step as its filtering use!
45+
sdf = sdf[sdf.apply(f)]
46+
```
47+
- **Avoid**:
48+
```python
49+
my_filter = sdf.apply(f)
50+
sdf = sdf[my_filter]
51+
```
52+
53+
2. Using column-based manipulations later (`SDF["col"]` references):
54+
- **Recommended**:
55+
```python
56+
# column manipulations and assignment on same assignment step!
57+
sdf["z"] = sdf["x"] + sdf["y"]
58+
```
59+
- **Avoid**:
60+
```python
61+
my_sum = sdf["x"] + sdf["y"]
62+
sdf["z"] = my_sum
63+
```
64+
65+
**Intermediate operation references will not raise exceptions**, so be careful!
66+
667
## Assignment vs "in-place" Patterns
768

869
For `StreamingDataFrames`, the general expected pattern is to assign it to a variable
@@ -17,7 +78,7 @@ sdf = sdf.apply() # reassign with new operation
1778
sdf = sdf.apply().apply() # reassign with chaining
1879
```
1980

20-
This is in contrast to an "inplace" (or "discard", "side effect") pattern, where the
81+
This is in contrast to an "in-place" (or "discard", "side effect") pattern, where the
2182
operation is not assigned:
2283

2384
```python
@@ -53,11 +114,11 @@ See [sinks](../connectors/sinks/README.md#sinks-are-terminal-operations) for det
53114

54115
With the introduction of branching, assignment is no longer technically required
55116
for the "assignment" operation to be added: it instead generates a
56-
[terminal branch](branching.md#terminal-branches-no-assignment).
117+
[terminal branch](../branching.md#terminal-branches-no-assignment).
57118

58119
In general, it is still recommended to follow both the
59120
[recommended assignment patterns](#assignment-vs-in-place-patterns) and
60-
[recommended branching patterns](branching.md#branching-fundamentals).
121+
[recommended branching patterns](../branching.md#branching-fundamentals).
61122

62123
## Before Quix Streams v3.0.0 (branching)
63124

docs/api-reference/application.md

Lines changed: 16 additions & 15 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#L63)
13+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L63)
1414

1515
The main Application class.
1616

@@ -59,6 +59,7 @@ app.run()
5959

6060
```python
6161
def __init__(broker_address: Optional[Union[str, ConnectionConfig]] = None,
62+
*,
6263
quix_sdk_token: Optional[str] = None,
6364
consumer_group: Optional[str] = None,
6465
auto_offset_reset: AutoOffsetReset = "latest",
@@ -84,7 +85,7 @@ def __init__(broker_address: Optional[Union[str, ConnectionConfig]] = None,
8485
processing_guarantee: ProcessingGuarantee = "at-least-once")
8586
```
8687

87-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L101)
88+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L101)
8889

8990

9091
<br>
@@ -173,7 +174,7 @@ instead of the default one.
173174
def Quix(cls, *args, **kwargs)
174175
```
175176

176-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L355)
177+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L356)
177178

178179
RAISES EXCEPTION: DEPRECATED.
179180

@@ -196,7 +197,7 @@ def topic(name: str,
196197
timestamp_extractor: Optional[TimestampExtractor] = None) -> Topic
197198
```
198199

199-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L370)
200+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L371)
200201

201202
Create a topic definition.
202203

@@ -278,7 +279,7 @@ def dataframe(topic: Optional[Topic] = None,
278279
source: Optional[BaseSource] = None) -> StreamingDataFrame
279280
```
280281

281-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L450)
282+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L451)
282283

283284
A simple helper method that generates a `StreamingDataFrame`, which is used
284285

@@ -334,7 +335,7 @@ to be used as an input topic.
334335
def stop(fail: bool = False)
335336
```
336337

337-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L505)
338+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L506)
338339

339340
Stop the internal poll loop and the message processing.
340341

@@ -361,7 +362,7 @@ to unhandled exception, and it shouldn't commit the current checkpoint.
361362
def get_producer() -> Producer
362363
```
363364

364-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L550)
365+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L551)
365366

366367
Create and return a pre-configured Producer instance.
367368
The Producer is initialized with params passed to Application.
@@ -396,7 +397,7 @@ with app.get_producer() as producer:
396397
def get_consumer(auto_commit_enable: bool = True) -> Consumer
397398
```
398399

399-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L580)
400+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L581)
400401

401402
Create and return a pre-configured Consumer instance.
402403

@@ -453,7 +454,7 @@ with app.get_consumer() as consumer:
453454
def clear_state()
454455
```
455456

456-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L630)
457+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L631)
457458

458459
Clear the state of the application.
459460

@@ -467,7 +468,7 @@ Clear the state of the application.
467468
def add_source(source: BaseSource, topic: Optional[Topic] = None) -> Topic
468469
```
469470

470-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L636)
471+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L637)
471472

472473
Add a source to the application.
473474

@@ -493,7 +494,7 @@ Default: the source default
493494
def run(dataframe: Optional[StreamingDataFrame] = None)
494495
```
495496

496-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L657)
497+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L658)
497498

498499
Start processing data from Kafka using provided `StreamingDataFrame`
499500

@@ -529,7 +530,7 @@ app.run()
529530
def setup_topics()
530531
```
531532

532-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L779)
533+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L780)
533534

534535
Validate and create the topics
535536

@@ -541,7 +542,7 @@ Validate and create the topics
541542
class ApplicationConfig(BaseSettings)
542543
```
543544

544-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L955)
545+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L956)
545546

546547
Immutable object holding the application configuration
547548

@@ -564,7 +565,7 @@ def settings_customise_sources(
564565
) -> Tuple[PydanticBaseSettingsSource, ...]
565566
```
566567

567-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L990)
568+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L991)
568569

569570
Included to ignore reading/setting values from the environment
570571

@@ -578,7 +579,7 @@ Included to ignore reading/setting values from the environment
578579
def copy(**kwargs) -> Self
579580
```
580581

581-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/app.py#L1003)
582+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/app.py#L1004)
582583

583584
Update the application config and return a copy
584585

docs/api-reference/context.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def set_message_context(context: Optional[MessageContext])
1313
```
1414

15-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/context.py#L20)
15+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/context.py#L20)
1616

1717
Set a MessageContext for the current message in the given `contextvars.Context`
1818

@@ -55,7 +55,7 @@ sdf = sdf.update(lambda value: alter_context(value))
5555
def message_context() -> MessageContext
5656
```
5757

58-
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/main/quixstreams/context.py#L51)
58+
[[VIEW SOURCE]](https://github.com/quixio/quix-streams/blob/3.0.0-docs/quixstreams/context.py#L51)
5959

6060
Get a MessageContext for the current message, which houses most of the message
6161

0 commit comments

Comments
 (0)