Skip to content

Commit 9522660

Browse files
authored
Add explicit app.run() to the docs (#551)
1 parent 808905a commit 9522660

File tree

8 files changed

+56
-37
lines changed

8 files changed

+56
-37
lines changed

docs/connectors/sinks/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ sdf = app.dataframe(topic)
2828
# Do some processing here ...
2929
# Sink data to InfluxDB
3030
sdf.sink(influx_sink)
31+
32+
if __name__ == '__main__':
33+
app.run()
3134
```
3235

3336
## Sinks Are Terminal Operations
@@ -118,4 +121,7 @@ influx_sink = InfluxDB3Sink(
118121

119122
# The sink will write to InfluxDB across all assigned partitions.
120123
sdf.sink(influx_sink)
124+
125+
if __name__ == '__main__':
126+
app.run()
121127
```

docs/connectors/sinks/csv-sink.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ sdf = app.dataframe(topic)
2323
# Do some processing here ...
2424
# Sink data to a CSV file
2525
sdf.sink(csv_sink)
26+
27+
if __name__ == '__main__':
28+
app.run()
2629
```
2730

2831
## How the CSV Sink Works

docs/connectors/sinks/influxdb3-sink.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ sdf = app.dataframe(topic)
3333
# Do some processing here ...
3434
# Sink data to InfluxDB
3535
sdf.sink(influx_sink)
36+
37+
if __name__ == '__main__':
38+
app.run()
3639
```
3740

3841
## How the InfluxDB Sink Works

docs/connectors/sources/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ from quixstreams.sources import CSVSource
5353
from quixstreams.models.topics import TopicConfig
5454

5555
def main():
56-
app = Application()
57-
source = CSVSource(path="input.csv")
58-
topic = app.topic("my_csv_source", config=TopicConfig(num_partitions=4, replication_factor=1))
59-
60-
sdf = app.dataframe(topic=topic, source=source)
61-
sdf.print(metadata=True)
62-
63-
app.run()
56+
app = Application()
57+
source = CSVSource(path="input.csv")
58+
topic = app.topic("my_csv_source", config=TopicConfig(num_partitions=4, replication_factor=1))
59+
60+
sdf = app.dataframe(topic=topic, source=source)
61+
sdf.print(metadata=True)
62+
63+
app.run()
6464

6565
if __name__ == "__main__":
66-
main()
66+
main()
6767
```

docs/connectors/sources/custom-sources.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ class MySource(Source):
7373
time.sleep(1)
7474

7575
def main():
76-
app = Application(broker_address="localhost:19092")
77-
source = MySource(name="mysource")
76+
app = Application(broker_address="localhost:19092")
77+
source = MySource(name="mysource")
7878

79-
sdf = app.dataframe(source=source)
80-
sdf.print(metadata=True)
79+
sdf = app.dataframe(source=source)
80+
sdf.print(metadata=True)
8181

82-
app.run()
82+
app.run()
8383

8484
if __name__ == "__main__":
85-
main()
85+
main()
8686
```
8787

8888
```

docs/connectors/sources/kafka-source.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ from quixstreams import Application
1313
from quixstreams.sources import KafkaReplicatorSource
1414

1515
def main():
16-
app = Application()
17-
source = KafkaReplicatorSource(
16+
app = Application()
17+
source = KafkaReplicatorSource(
1818
name="my-source",
1919
app_config=app.config,
2020
topic="source-topic",
2121
broker_address="source-broker-address"
22-
)
23-
24-
sdf = app.dataframe(source=source)
25-
sdf.print(metadata=True)
26-
27-
app.run()
22+
)
23+
24+
sdf = app.dataframe(source=source)
25+
sdf.print(metadata=True)
26+
27+
app.run()
2828

2929
if __name__ == "__main__":
30-
main()
30+
main()
3131
```
3232

3333
## Topic

docs/connectors/sources/quix-source.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@ from quixstreams import Application
1111
from quixstreams.sources import QuixEnvironmentSource
1212

1313
def main():
14-
app = Application()
15-
source = QuixEnvironmentSource(
14+
app = Application()
15+
source = QuixEnvironmentSource(
1616
name="my-source",
1717
app_config=app.config,
1818
topic="source-topic",
1919
quix_sdk_token="quix-sdk-token",
2020
quix_workspace_id="quix-workspace-id",
21-
)
22-
23-
sdf = app.dataframe(source=source)
24-
sdf.print(metadata=True)
25-
26-
app.run()
21+
)
22+
23+
sdf = app.dataframe(source=source)
24+
sdf.print(metadata=True)
25+
26+
app.run()
2727

2828
if __name__ == "__main__":
29-
main()
29+
main()
3030
```
3131

32-
## Token
32+
## SDK Token
3333

34-
The Quix Environment Source requires the sdk token of the source environment. [Click here](../../../develop/authentication/streaming-token.md) for more information on SDK tokens.
34+
The Quix Environment Source requires the SDK token of the source environment. [Click here](../../../develop/authentication/streaming-token.md) for more information on SDK tokens.

docs/processing.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,23 @@ In general, when operations are added, they should follow a "reassignment" patte
4040
to ensure they are applied correctly. For example:
4141

4242
```python
43-
# NOTE: this is an incomplete stub just to show usage
4443
from quixstreams import Application
4544

46-
sdf = Application().dataframe()
45+
# Initialize the Appication
46+
app = Application(...)
47+
48+
# Create a StreamingDataFrame
49+
sdf = app.dataframe()
4750

4851
# re-assign sdf with an added operation
4952
sdf = sdf.apply(lambda x: x + 1)
5053

5154
# add two more operations at once ("chaining" operations)
5255
sdf = sdf.apply(lambda x: x + 2).apply(lambda x: x + 3)
56+
57+
# Run the application
58+
if __name__ == '__main__':
59+
app.run()
5360
```
5461

5562
This pattern is safe to use for almost every operation with `StreamingDataFrames`; any

0 commit comments

Comments
 (0)