Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,17 @@ These scripts compile the C# base library and then use the `InteropGenerator` pr
```

┌───────────────────────────┐
│ Python client library │ /Python/lib/quixstreaming
│ Python client library │ /Python/lib/quixstreams
└─────────────┬─────────────┘
┌─────────────▼─────────────┐
│ Python Interop wrapper │ /Python/lib/quixstreaming/native/Python (auto-generated)
│ Python Interop wrapper │ /Python/lib/quixstreams/native/Python (auto-generated)
└─────────────┬─────────────┘
┌─────────────▼─────────────┐
│ C# AoT compiled library │ /Python/lib/quixstreaming/native/win64 (auto-generated)
│ C# AoT compiled library │ /Python/lib/quixstreams/native/win64 (auto-generated)
└───────────────────────────┘

```
Expand Down
4 changes: 2 additions & 2 deletions docs/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ The following code shows you how to set up the `SecurityOptions` for your connec

``` python
security = SecurityOptions(CERTIFICATES_FOLDER, QUIX_USER, QUIX_PASSWORD)
client = StreamingClient('kafka-k1.quix.ai:9093,kafka-k2.quix.ai:9093,kafka-k3.quix.ai:9093', security)
client = KafkaStreamingClient('kafka-k1.quix.ai:9093,kafka-k2.quix.ai:9093,kafka-k3.quix.ai:9093', security)
```

=== "C\#"

``` cs
var security = new SecurityOptions(CERTIFICATES_FOLDER, QUIX_USER, QUIX_PASSWORD);
var client = new Quix.Sdk.Streaming.StreamingClient("kafka-k1.quix.ai:9093,kafka-k2.quix.ai:9093,kafka-k3.quix.ai:9093", security);
var client = new Quix.Sdk.Streaming.KafkaStreamingClient("kafka-k1.quix.ai:9093,kafka-k2.quix.ai:9093,kafka-k3.quix.ai:9093", security);
```

=== "JavaScript"
Expand Down
39 changes: 20 additions & 19 deletions docs/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,34 @@ Let’s see some examples of how to read and write data in a Data processor usin
``` python
# Callback triggered for each new data frame
def on_parameter_data_handler(data: ParameterData):
with data:

df = data.to_panda_frame() # Input data frame
output_df = pd.DataFrame()
output_df["time"] = df["time"]
output_df["TAG__LapNumber"] = df["TAG__LapNumber"]

# If braking force applied is more than 50%, we mark HardBraking with True
output_df["HardBraking"] = df.apply(lambda row: "True" if row.Brake > 0.5 else "False", axis=1)

stream_output.parameters.write(output_df) # Send data back to the stream
df = data.to_panda_frame() # Input data frame
output_df = pd.DataFrame()
output_df["time"] = df["time"]
output_df["TAG__LapNumber"] = df["TAG__LapNumber"]
# If braking force applied is more than 50%, we mark HardBraking with True
output_df["HardBraking"] = df.apply(lambda row: "True" if row.Brake > 0.5 else "False", axis=1)
stream_output.parameters.write(output_df) # Send data back to the stream
```

=== "Python - Plain"

``` python
# Callback triggered for each new data frame
def on_parameter_data_handler(data: ParameterData):

for row in data.timestamps:
# If braking force applied is more than 50%, we mark HardBraking with True
hard_braking = row.parameters["Brake"].numeric_value > 0.5

stream_output.parameters \
.add_timestamp(row.timestamp) \
.add_tag("LapNumber", row.tags["LapNumber"]) \
.add_value("HardBraking", hard_braking) \
.write()
with data:
for row in data.timestamps:
# If braking force applied is more than 50%, we mark HardBraking with True
hard_braking = row.parameters["Brake"].numeric_value > 0.5
stream_output.parameters \
.add_timestamp(row.timestamp) \
.add_tag("LapNumber", row.tags["LapNumber"]) \
.add_value("HardBraking", hard_braking) \
.write()
```

=== "C\#"
Expand Down
44 changes: 23 additions & 21 deletions docs/read.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ For instance, in the following example we read and print the first timestamp and
def on_stream_received_handler(new_stream: StreamReader):

def on_parameter_data_handler(data: ParameterData):

timestamp = data.timestamps[0].timestamp
num_value = data.timestamps[0].parameters['ParameterA'].numeric_value
print("ParameterA - " + str(timestamp) + ": " + str(num_value))
with data:
timestamp = data.timestamps[0].timestamp
num_value = data.timestamps[0].parameters['ParameterA'].numeric_value
print("ParameterA - " + str(timestamp) + ": " + str(num_value))

new_stream.on_read += on_parameter_data_handler

Expand Down Expand Up @@ -248,9 +248,10 @@ Reading data from that buffer is as simple as using its `OnRead` event. For each

``` python
def on_parameter_data_handler(data: ParameterData):
timestamp = data.timestamps[0].timestamp
num_value = data.timestamps[0].parameters['ParameterA'].numeric_value
print("ParameterA - " + str(timestamp) + ": " + str(num_value))
with data:
timestamp = data.timestamps[0].timestamp
num_value = data.timestamps[0].parameters['ParameterA'].numeric_value
print("ParameterA - " + str(timestamp) + ": " + str(num_value))

buffer.on_read += on_parameter_data_handler
```
Expand Down Expand Up @@ -383,10 +384,10 @@ def read_stream(new_stream: StreamReader):
buffer = new_stream.parameters.create_buffer()

def on_parameter_data_handler(data: ParameterData):

# read from input stream
df = data.to_panda_frame()
print(df.to_string())
with data:
# read from input stream
df = data.to_panda_frame()
print(df.to_string())

buffer.on_read += on_parameter_data_handler

Expand Down Expand Up @@ -421,7 +422,8 @@ Reading events from a stream is as easy as reading parameter data. In this case,

``` python
def on_event_data_handler(data: EventData):
print("Event read for stream. Event Id: " + data.Id)
with data:
print("Event read for stream. Event Id: " + data.Id)

new_stream.events.on_read += on_event_data_handler
```
Expand Down Expand Up @@ -465,7 +467,7 @@ If you wish to use different automatic commit intervals, use the following code:
=== "Python"

``` python
from quixstreaming import CommitOptions
from quixstreams import CommitOptions

commit_settings = CommitOptions()
commit_settings.commit_every = 100 # note, you can set this to none
Expand Down Expand Up @@ -494,7 +496,7 @@ Some use cases need manual committing to mark completion of work, for example wh
=== "Python"

``` python
from quixstreaming import CommitMode
from quixstreams import CommitMode

input_topic = client.open_input_topic('yourtopic', commit_settings=CommitMode.Manual)
```
Expand Down Expand Up @@ -610,7 +612,7 @@ One or more streams are revoked from your client. You can no longer commit to th
=== "Python"

``` python
from quixstreaming import StreamReader
from quixstreams import StreamReader

def on_streams_revoked_handler(readers: [StreamReader]):
for reader in readers:
Expand Down Expand Up @@ -668,9 +670,9 @@ This is a minimal code example you can use to read data from a topic using the Q
=== "Python"

``` python
from quixstreaming import *
from quixstreaming.app import App
from quixstreaming.models.parametersbufferconfiguration import ParametersBufferConfiguration
from quixstreams import *
from quixstreams.app import App
from quixstreams.models.parametersbufferconfiguration import ParametersBufferConfiguration
import sys
import signal
import threading
Expand All @@ -686,9 +688,9 @@ This is a minimal code example you can use to read data from a topic using the Q
buffer = new_stream.parameters.create_buffer()

def on_parameter_data_handler(data: ParameterData):

df = data.to_panda_frame()
print(df.to_string())
with data:
df = data.to_panda_frame()
print(df.to_string())

buffer.on_read += on_parameter_data_handler

Expand Down
6 changes: 3 additions & 3 deletions docs/state-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ The Quix SDK has state management built in to allow values to be used and persis

## Usage

To use the SDK’s state management feature create an instance of *LocalFileStorage*. This is in *quixstreaming.state.localfilestorage*. Then use the set, get, containsKey and clear methods to manipulate the state as needed.
To use the SDK’s state management feature create an instance of *LocalFileStorage*. This is in *quixstreams.state.localfilestorage*. Then use the `set`, `get`, `containsKey` (`contains_key` for Python), and `clear` methods to manipulate the state as needed.

=== "Python"

``` python
from quixstreaming.state.localfilestorage import LocalFileStorage
from quixstreams.state.localfilestorage import LocalFileStorage

storage = LocalFileStorage()

Expand All @@ -30,7 +30,7 @@ To use the SDK’s state management feature create an instance of *LocalFileStor
storage.set("KEY4", False)

#check if the storage contains key
storage.containsKey("KEY1")
storage.contains_key("KEY1")

#get value
value = storage.get("KEY1")
Expand Down
5 changes: 3 additions & 2 deletions docs/write.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,8 @@ Alternatively, you can convert a Pandas Data Frame to a [ParameterData](#paramet

``` python
data = ParameterData.from_panda_frame(df)
stream.parameters.buffer.write(data)
with data:
stream.parameters.buffer.write(data)
```

!!! tip
Expand Down Expand Up @@ -938,7 +939,7 @@ This is a minimal code example you can use to write data to a topic using the Qu
import datetime
import math

from quixstreaming import *
from quixstreams import *

# Quix injects credentials automatically to the client. Alternatively, you can always pass an SDK token manually as an argument.
client = QuixStreamingClient()
Expand Down