Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: correct definitions, broken link and grammar, capitalization, punctuation in python client documentation #2940

Merged
merged 16 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"\n",
"### Why there is an extra Python library for StreamPipes?\n",
"[Apache StreamPipes](https://streampipes.apache.org/) aims to enable non-technical users to connect and analyze IoT data streams.\n",
"To this end, it provides an easy-to-use and convenient user interface that allows one to connect to an IoT data source and create some visual\n",
"To achieve this, it provides an easy-to-use and convenient user interface that allows one to connect to an IoT data source and create some visual\n",
"graphs within a few minutes. <br>\n",
"Although this is the main use case of Apache StreamPipes, it can also provide great value for people who are eager to work on data analysis or data science with IoT data, but don't we do get in touch with all the hassle associated with extracting data from devices in a suitable format.\n",
"While this is the primary use case for Apache StreamPipes, it also offers significant value to those interested in data analysis or data science with IoT data, without the need to handle the complexities of extracting data from devices in a suitable format..\n",
"In this scenario, StreamPipes helps you connect to your data source and extract the data for you.\n",
"You then can make the data available outside StreamPipes by writing it into an external source, such as a database, Kafka, etc.\n",
"While this requires another component, you can also extract your data directly from StreamPipes programmatically using the StreamPipes API.\n",
Expand Down Expand Up @@ -87,7 +87,7 @@
"source": [
"### How to configure the Python client\n",
"In order to access the resources available in StreamPipes, one must be able to authenticate against the backend.\n",
"For this purpose, the client sofar only supports the authentication via an API token that can be generated via the StreamPipes UI, as you see below.\n",
"For this purpose, the client so far only supports the authentication via an API token that can be generated via the StreamPipes UI, as you can see below.\n",
"\n",
"![how-to-get-api-key](https://raw.githubusercontent.com/apache/streampipes/dev/streampipes-client-python/docs/img/how-to-get-api-key.gif)\n",
"\n",
Expand Down Expand Up @@ -159,7 +159,7 @@
"cell_type": "markdown",
"source": [
"To ensure that the above code works, you must set the environment variables as expected.\n",
"This can be done like following:"
"This can be done as follows:"
],
"metadata": {
"collapsed": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
{
"cell_type": "markdown",
"source": [
"So let's see how many measures are available"
"So let's see how many measures are available:"
],
"metadata": {
"collapsed": false
Expand Down Expand Up @@ -179,7 +179,7 @@
{
"cell_type": "markdown",
"source": [
"To get a more comprehensive overview, you can take a look at the [`pandas`](https://pandas.pydata.org/) representation"
"To get a more comprehensive overview, you can take a look at the [`pandas`](https://pandas.pydata.org/) representation:"
],
"metadata": {
"collapsed": false
Expand Down Expand Up @@ -318,7 +318,7 @@
{
"cell_type": "markdown",
"source": [
"As a final step, we want to create a plot of both attributes"
"As a final step, we want to create a plot of both attributes."
],
"metadata": {
"collapsed": false
Expand Down Expand Up @@ -469,10 +469,10 @@
{
"cell_type": "markdown",
"source": [
"... from this point on we leave all future processing of the data up to your creativity.\n",
"... from this point on, we leave all future processing of the data up to your creativity.\n",
"Keep in mind: the general syntax used in this tutorial (`all()`, `to_pandas()`, `get()`) applies to all endpoints and associated resources of the StreamPipes Python client.\n",
"\n",
"If you get further and create exiting stuff with data extracted from StreamPipes please [let us know](https://github.com/apache/streampipes/discussions/categories/show-and-tell).\n",
"If you get further and create exciting stuff with data extracted from StreamPipes please [let us know](https://github.com/apache/streampipes/discussions/categories/show-and-tell).\n",
"We are thrilled to see what you as a community will build with the provided client.\n",
"Furthermore, don't hesitate to discuss [feature requests](https://github.com/apache/streampipes/discussions/812) to extend the current functionality with us."
],
Expand All @@ -483,7 +483,7 @@
{
"cell_type": "markdown",
"source": [
"For now, that's all about the StreamPipes client. Read the next tutorial ([Getting live data from the StreamPipes data stream](../3-getting-live-data-from-the-streampipes-data-stream)) if you are interested in making use of the powerful [StreamPipes functions](https://streampipes.apache.org/docs/docs/extend-sdk-functions.html) to interact with StreamPipes event-based."
"For now, that's all about the StreamPipes client. Read the next tutorial ([Getting live data from the StreamPipes data stream](../3-getting-live-data-from-the-streampipes-data-stream)) if you are interested in making use of the powerful [StreamPipes functions](https://streampipes.apache.org/docs/extend-sdk-functions.html) to interact with StreamPipes in an event-based manner."
],
"metadata": {
"collapsed": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
"source": [
"Let's dive a little deeper into the different parts of the function\n",
"\n",
"- **`__init__`**: First, we need to take care about the data stream that is required to send the predictions from our function to StreamPipes. Thus, we create a dedicated output data stream which we need to provide with the attributes our event will consist of (a timestamp attribute is always added automatically). This output data stream needs to be registered at the function definition which is to be passed to the parent class. Lastly, we need to define some instance variables that are mainly required for the ONNX runtime.\n",
"- **`__init__`**: First, we need to take care of the data stream that is required to send the predictions from our function to StreamPipes. Thus, we create a dedicated output data stream which we need to provide with the attributes our event will consist of (a timestamp attribute is always added automatically). This output data stream needs to be registered at the function definition which is to be passed to the parent class. Lastly, we need to define some instance variables that are mainly required for the ONNX runtime.\n",
"\n",
"- **`onServiceStarted`**: Here we prepare the ONNX runtime session by creating an `InferenceSession` and retrieving the corresponding configuration parameters.\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion streampipes-client-python/streampipes/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def http_headers(self) -> Dict[str, str]:
Returns
-------
http_headers: Dict[str, str]
header information for HTTP requests as string key-value pairs.
Header information for HTTP requests as string key-value pairs.
"""

# create HTTP headers from credential provider and add additional headers needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class StreamPipesApiKeyCredentials(CredentialProvider):
def from_env(cls, username_env: str, api_key_env: str) -> StreamPipesApiKeyCredentials:
"""DEPRECATED - use the class constructor instead

Returns an api key provider parameterized via environment variables.
Returns an API key provider parameterized via environment variables.

Parameters
----------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MeasurementGetQueryConfig(BaseModel):
If provided, the returned data only consists of the given columns.<br>
Please be aware that the column `time` as an index is always included.
end_date: Optional[datetime]
Restricts queried data to be younger than the specified time.
Limits the queried data to only include data that is older than the specified time. In other words, any data that occurred after the end_date will not be included in the query results.
limit: Optional[int]
Amount of records returned at maximum (default: `1000`) <br>
This needs to be at least `1`
Expand All @@ -69,7 +69,7 @@ class MeasurementGetQueryConfig(BaseModel):
Page number used for paging operation <br>
This needs to be at least `1`
start_date: Optional[datetime]
Restricts queried data to be older than the specified time
Limits the queried data to only include data that is newer than the specified time. In other words, any data that occurred before the start_date will not be included in the query results.
"""

_regex_comma_separated_string = r"^[0-9a-zA-Z\_]+(,[0-9a-zA-Z\_]+)*$"
Expand Down Expand Up @@ -344,14 +344,14 @@ def get(self, identifier: str, **kwargs: Optional[Dict[str, Any]]) -> QueryResul
identifier: str
The identifier of the data lake measure to be queried.
**kwargs: Dict[str, Any]
keyword arguments can be used to provide additional query parameters.
Keyword arguments can be used to provide additional query parameters.
The available query parameters are defined by the
[MeasurementGetQueryConfig][streampipes.endpoint.api.data_lake_measure.MeasurementGetQueryConfig].

Returns
-------
measurement: DataLakeMeasures
the specified data lake measure
The specified data lake measure

Examples
--------
Expand Down
4 changes: 2 additions & 2 deletions streampipes-client-python/streampipes/endpoint/api/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def all(self) -> ResourceContainer:
Raises
------
NotImplementedError
this endpoint does not return multiple entries, therefore this method is not available
This endpoint does not return multiple entries, therefore this method is not available.

"""
raise NotImplementedError("The `all()` method is not supported by this endpoint.")
Expand Down Expand Up @@ -147,7 +147,7 @@ def post(self, resource: Resource) -> None:
Raises
------
NotImplementedError
this endpoint does not allow for POST requests, therefore this method is not available
This endpoint does not allow for POST requests, therefore this method is not available.

"""
raise NotImplementedError("The `post()` method is not supported by this endpoint.")
6 changes: 3 additions & 3 deletions streampipes-client-python/streampipes/endpoint/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""
General implementation for an endpoint.
Provided classes and assets are aimed to be used for developing endpoints.
An endpoint provides all options to communicate with ad dedicated part of StreamPipes in a handy way.
An endpoint provides all options to communicate with a dedicated part of StreamPipes in a handy way.
"""

import json
Expand Down Expand Up @@ -184,7 +184,7 @@ def all(self) -> ResourceContainer:
Returns
-------
container: ResourceContainer
container element that bundles the returned resources
Container element that bundles the returned resources
"""

response = self._make_request(
Expand Down Expand Up @@ -284,7 +284,7 @@ def configure(self, broker: Broker) -> None:
"""Configures the message endpoint by setting the broker instance to be used.

This configuration step is required before the endpoint can be actually used.
The based `broker` instance is passed to an internal property
The based `broker` instance is passed to an internal property.

Parameters
----------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

"""
Custom exceptions dedicated for the endpoints module
Custom exceptions dedicated to the endpoints module.
"""

__all__ = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class StreamPipesFunction(ABC):
Parameters
----------
function_definition: FunctionDefinition
the definition of the function that contains metadata about the connected function
The definition of the function that contains metadata about the connected function

Attributes
----------
Expand All @@ -50,7 +50,7 @@ def __init__(self, function_definition: Optional[FunctionDefinition] = None):
}

def add_output(self, stream_id: str, event: Dict[str, Any]):
"""Send an event via an output data stream to StreamPipes
"""Send an event via an output data stream to StreamPipes.

Parameters
----------
Expand Down Expand Up @@ -78,7 +78,7 @@ def getFunctionId(self) -> FunctionId:
return self.function_definition.function_id

def stop(self) -> None:
"""Stops the function and disconnects from the output streams"""
"""Stops the function and disconnects from the output streams."""

for collector in self.output_collectors.values():
collector.disconnect()
Expand All @@ -96,12 +96,12 @@ def requiredStreamIds(self) -> List[str]:

@abstractmethod
def onServiceStarted(self, context: FunctionContext) -> None:
"""Is called when the function gets started.
"""Is called when the function is started.

Parameters
----------
context: FunctionContext
The context in which the function gets started.
The context in which the function is started.

Returns
-------
Expand All @@ -128,7 +128,7 @@ def onEvent(self, event: Dict[str, Any], streamId: str) -> None:

@abstractmethod
def onServiceStopped(self) -> None:
"""Is called when the function gets stopped.
"""Is called when the function is stopped.

Returns
-------
Expand Down
22 changes: 11 additions & 11 deletions streampipes-client-python/streampipes/model/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ class Config:


class BaseElement(BasicModel):
"""Structure of a basic element in the StreamPipes backend"""
"""Structure of a basic element in the StreamPipes Backend."""

element_id: Optional[StrictStr]


class ValueSpecification(BasicModel):
"""
Data model of an `ValueSpecification` in compliance to the StreamPipes Backend.
Data model of an `ValueSpecification` in compliance with the StreamPipes Backend.
"""

class_name: Optional[StrictStr] = Field(alias="@class")
Expand All @@ -101,7 +101,7 @@ class ValueSpecification(BasicModel):

class EventProperty(BasicModel):
"""
Data model of an `EventProperty` in compliance to the StreamPipes Backend.
Data model of an `EventProperty` in compliance with the StreamPipes Backend.
"""

class_name: StrictStr = Field(alias="@class", default="org.apache.streampipes.model.schema.EventPropertyPrimitive")
Expand All @@ -121,15 +121,15 @@ class EventProperty(BasicModel):

class EventSchema(BasicModel):
"""
Data model of an `EventSchema` in compliance to the StreamPipes Backend.
Data model of an `EventSchema` in compliance with the StreamPipes Backend.
"""

event_properties: List[EventProperty]


class ApplicationLink(BasicModel):
"""
Data model of an `ApplicationLink` in compliance to the StreamPipes Backend.
Data model of an `ApplicationLink` in compliance with the StreamPipes Backend.
"""

class_name: Optional[StrictStr] = Field(alias="@class")
Expand All @@ -143,7 +143,7 @@ class ApplicationLink(BasicModel):

class TopicDefinition(BasicModel):
"""
Data model of a `TopicDefinition` in compliance to the StreamPipes Backend.
Data model of a `TopicDefinition` in compliance with the StreamPipes Backend.
"""

class_name: Optional[StrictStr] = Field(
Expand All @@ -154,7 +154,7 @@ class TopicDefinition(BasicModel):

class TransportProtocol(BasicModel):
"""
Data model of a `TransportProtocol` in compliance to the StreamPipes Backend.
Data model of a `TransportProtocol` in compliance with the StreamPipes Backend.
"""

class_name: StrictStr = Field(
Expand All @@ -168,15 +168,15 @@ class TransportProtocol(BasicModel):

class TransportFormat(BasicModel):
"""
Data model of a `TransportFormat` in compliance to the StreamPipes Backend.
Data model of a `TransportFormat` in compliance with the StreamPipes Backend.
"""

rdf_type: List[StrictStr] = Field(default=["http://sepa.event-processing.org/sepa#json"])


class EventGrounding(BasicModel):
"""
Data model of an `EventGrounding` in compliance to the StreamPipes Backend.
Data model of an `EventGrounding` in compliance to with StreamPipes Backend.
"""

transport_protocols: List[TransportProtocol] = Field(default_factory=lambda: [TransportProtocol()])
Expand All @@ -185,7 +185,7 @@ class EventGrounding(BasicModel):

class MeasurementCapability(BasicModel):
"""
Data model of a `MeasurementCapability` in compliance to the StreamPipes Backend.
Data model of a `MeasurementCapability` in compliance with the StreamPipes Backend.
"""

capability: Optional[StrictStr]
Expand All @@ -194,7 +194,7 @@ class MeasurementCapability(BasicModel):

class MeasurementObject(BasicModel):
"""
Data model of a `MeasurementObject` in compliance to the StreamPipes Backend.
Data model of a `MeasurementObject` in compliance with the StreamPipes Backend.
"""

element_id: Optional[StrictStr]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def from_json(cls, json_string: str) -> ResourceContainer:
Returns
-------
container: ResourceContainer
instance of the container derived from the JSON definition
Instance of the container derived from the JSON definition

Raises
------
Expand Down
Loading