Skip to content

Commit

Permalink
chore(python-client): rename python package to streampipes
Browse files Browse the repository at this point in the history
Signed-off-by: bossenti <[email protected]>
  • Loading branch information
bossenti committed Feb 6, 2023
1 parent a73dee9 commit 8a6ef00
Show file tree
Hide file tree
Showing 51 changed files with 248 additions and 193 deletions.
2 changes: 1 addition & 1 deletion streampipes-client-python/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
files: streampipes_client/|tests/
files: streampipes/|tests/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
Expand Down
12 changes: 6 additions & 6 deletions streampipes-client-python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ doc:

.PHONY: lint
lint:
flake8 streampipes_client --max-line-length 120
flake8 streampipes --max-line-length 120

.PHONY: livedoc
livedoc: doc
mkdocs serve --dirtyreload

.PHONY: mypy
mypy:
mypy streampipes_client --warn-unused-ignores --warn-redundant-casts --pretty
mypy streampipes --warn-unused-ignores --warn-redundant-casts --pretty

.PHONY: rebase
rebase:
Expand All @@ -41,14 +41,14 @@ rebase:
.PHONY: reformat-all
reformat-all:
pyupgrade --py38 --keep-runtime-typing
autoflake -r --remove-all-unused-imports --expand-star-imports --in-place streampipes_client tests
isort --profile black streampipes_client tests
black --line-length=120 streampipes_client tests
autoflake -r --remove-all-unused-imports --expand-star-imports --in-place streampipes tests
isort --profile black streampipes tests
black --line-length=120 streampipes tests

.PHONY: pre-commit
pre-commit:
pre-commit run --verbose --all-files

.PHONY: unit-tests
unit-tests:
pytest --cov=streampipes_client tests/ --cov-fail-under=90 --cov-report term-missing --no-cov-on-fail
pytest --cov=streampipes tests/ --cov-fail-under=90 --cov-report term-missing --no-cov-on-fail
62 changes: 44 additions & 18 deletions streampipes-client-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,54 @@ and the amazing universe of data analytics libraries in Python. </p>
As a quick example, we demonstrate how to set up and configure a StreamPipes client.

```python
>>> from streampipes_client.client import StreamPipesClient
>>> from streampipes_client.client.client_config import StreamPipesClientConfig
>>> from streampipes_client.client.credential_provider import StreamPipesApiKeyCredentials
>> > from streampipes.client import StreamPipesClient
>> > from streampipes.client.client_config import StreamPipesClientConfig
>> > from streampipes.client.credential_provider import StreamPipesApiKeyCredentials

>>> config = StreamPipesClientConfig(
... credential_provider=StreamPipesApiKeyCredentials(
... username="[email protected]",
... api_key="DEMO-KEY",
... ),
... host_address="localhost",
... http_disabled=True,
... port=80
>> > config = StreamPipesClientConfig(
...
credential_provider = StreamPipesApiKeyCredentials(
...
username = "[email protected]",
...
api_key = "DEMO-KEY",
... ),
...
host_address = "localhost",
...
http_disabled = True,
...
port = 80
...)

>>> client = StreamPipesClient(client_config=config)
>>> client.describe()
>> > client = StreamPipesClient(client_config=config)
>> > client.describe()

Hi there!
You are connected to a StreamPipes instance running at http://localhost:80.
The following StreamPipes resources are available with this client:
6x DataStreams
1x DataLakeMeasures
Hi
there!
You
are
connected
to
a
StreamPipes
instance
running
at
http: // localhost: 80.
The
following
StreamPipes
resources
are
available
with this client:
6
x
DataStreams
1
x
DataLakeMeasures
```

For more information about how to use the StreamPipes client visit our [introduction example]().
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
"execution_count": 3,
"outputs": [],
"source": [
"from streampipes_client.client import StreamPipesClient\n",
"from streampipes_client.client.client_config import StreamPipesClientConfig\n",
"from streampipes_client.client.credential_provider import StreamPipesApiKeyCredentials"
"from streampipes.client import StreamPipesClient\n",
"from streampipes.client.config import StreamPipesClientConfig\n",
"from streampipes.client.credential_provider import StreamPipesApiKeyCredentials"
],
"metadata": {
"collapsed": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"execution_count": 1,
"outputs": [],
"source": [
"from streampipes_client.client import StreamPipesClient\n",
"from streampipes_client.client.client_config import StreamPipesClientConfig\n",
"from streampipes_client.client.credential_provider import StreamPipesApiKeyCredentials"
"from streampipes.client import StreamPipesClient\n",
"from streampipes.client.config import StreamPipesClientConfig\n",
"from streampipes.client.credential_provider import StreamPipesApiKeyCredentials"
],
"metadata": {
"collapsed": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"metadata": {},
"outputs": [],
"source": [
"from streampipes_client.client import StreamPipesClient\n",
"from streampipes_client.client.client_config import StreamPipesClientConfig\n",
"from streampipes_client.client.credential_provider import StreamPipesApiKeyCredentials"
"from streampipes.client import StreamPipesClient\n",
"from streampipes.client.config import StreamPipesClientConfig\n",
"from streampipes.client.credential_provider import StreamPipesApiKeyCredentials"
]
},
{
Expand Down Expand Up @@ -238,10 +238,10 @@
"import pandas as pd\n",
"from datetime import datetime\n",
"import matplotlib.pyplot as plt\n",
"from streampipes_client.functions.function_handler import FunctionHandler\n",
"from streampipes_client.functions.registration import Registration\n",
"from streampipes_client.functions.streampipes_function import StreamPipesFunction\n",
"from streampipes_client.functions.utils.function_context import FunctionContext\n",
"from streampipes.functions.function_handler import FunctionHandler\n",
"from streampipes.functions.registration import Registration\n",
"from streampipes.functions.streampipes_function import StreamPipesFunction\n",
"from streampipes.functions.utils.function_context import FunctionContext\n",
"\n",
"class ExampleFunction(StreamPipesFunction):\n",
"\n",
Expand Down Expand Up @@ -610,4 +610,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}
66 changes: 46 additions & 20 deletions streampipes-client-python/docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,61 @@
As a quick example, we demonstrate how to set up and configure a StreamPipes client.

```python
>>> from streampipes_client.client import StreamPipesClient
>>> from streampipes_client.client.client_config import StreamPipesClientConfig
>>> from streampipes_client.client.credential_provider import StreamPipesApiKeyCredentials

>>> config = StreamPipesClientConfig(
... credential_provider=StreamPipesApiKeyCredentials(
... username="[email protected]",
... api_key="DEMO-KEY",
... ),
... host_address="localhost",
... http_disabled=True,
... port=80
>> > from streampipes.client import StreamPipesClient
>> > from streampipes.client.client_config import StreamPipesClientConfig
>> > from streampipes.client.credential_provider import StreamPipesApiKeyCredentials

>> > config = StreamPipesClientConfig(
...
credential_provider = StreamPipesApiKeyCredentials(
...
username = "[email protected]",
...
api_key = "DEMO-KEY",
... ),
...
host_address = "localhost",
...
http_disabled = True,
...
port = 80
...)

>>> client = StreamPipesClient(client_config=config)
>>> client.describe()
>> > client = StreamPipesClient(client_config=config)
>> > client.describe()

Hi there!
You are connected to a StreamPipes instance running at http://localhost:80.
The following StreamPipes resources are available with this client:
6x DataStreams
1x DataLakeMeasures
Hi
there!
You
are
connected
to
a
StreamPipes
instance
running
at
http: // localhost: 80.
The
following
StreamPipes
resources
are
available
with this client:
6
x
DataStreams
1
x
DataLakeMeasures
```
<br>
Alternatively, you can provide your credentials via environment variables.
Simply define your credential provider as follows:

```python
>>> from streampipes_client.client.credential_provider import StreamPipesApiKeyCredentials
>> > from streampipes.client.credential_provider import StreamPipesApiKeyCredentials

StreamPipesApiKeyCredentials.from_env(username_env="USER", api_key_env="API-KEY")
```
Expand Down
61 changes: 32 additions & 29 deletions streampipes-client-python/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,9 @@ and the amazing universe of data analytics libraries in Python. </p>

<br>

** ❗❗❗IMPORTANT ❗❗❗**
<br>
<br>
**The current version of this Python client is still in alpha phase at best.**
**💡 The current version of this Python client is still a beta version.**
<br>
**This means that it is still heavily under development, which may result in frequent and extensive API changes, unstable behavior, etc.**
<br>
**Please consider it only as a sneak preview.**
<br>
<br>
**❗❗❗ IMPORTANT ❗❗❗**

<br>

## ⚡️ Quickstart
Expand All @@ -56,41 +47,53 @@ As a quick example, we demonstrate how to set up and configure a StreamPipes cli
In addition, we will get the available data lake measures out of StreamPipes.

```python
>>> from streampipes_client.client import StreamPipesClient
>>> from streampipes_client.client.client_config import StreamPipesClientConfig
>>> from streampipes_client.client.credential_provider import StreamPipesApiKeyCredentials

>>> config = StreamPipesClientConfig(
... credential_provider=StreamPipesApiKeyCredentials(
... username="[email protected]",
... api_key="DEMO-KEY",
... ),
... host_address="localhost",
... http_disabled=True,
... port=80
>> > from streampipes.client import StreamPipesClient
>> > from streampipes.client.client_config import StreamPipesClientConfig
>> > from streampipes.client.credential_provider import StreamPipesApiKeyCredentials

>> > config = StreamPipesClientConfig(
...
credential_provider = StreamPipesApiKeyCredentials(
...
username = "[email protected]",
...
api_key = "DEMO-KEY",
... ),
...
host_address = "localhost",
...
http_disabled = True,
...
port = 80
...)

>>> client = StreamPipesClient(client_config=config)
>> > client = StreamPipesClient(client_config=config)

# get all available datat lake measures
>>> measures = client.dataLakeMeasureApi.all()
>> > measures = client.dataLakeMeasureApi.all()

# get amount of retrieved measures
>>> len(measures)
>> > len(measures)
1

# inspect the data lake measures as pandas dataframe
>>> measures.to_pandas()
measure_name timestamp_field ... pipeline_is_running num_event_properties
0 test s0::timestamp ... False 2
>> > measures.to_pandas()
measure_name
timestamp_field...pipeline_is_running
num_event_properties
0
test
s0::timestamp...
False
2
[1 rows x 6 columns]
```
<br>
Alternatively, you can provide your credentials via environment variables.
Simply define your credential provider as follows:

```python
>>> from streampipes_client.client.credential_provider import StreamPipesApiKeyCredentials
>> > from streampipes.client.credential_provider import StreamPipesApiKeyCredentials

StreamPipesApiKeyCredentials.from_env(username_env="USER", api_key_env="API-KEY")
```
Expand Down
8 changes: 4 additions & 4 deletions streampipes-client-python/docs/scripts/gen_ref_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

nav = mkdocs_gen_files.Nav()

for path in sorted(Path("streampipes_client").rglob("*.py")):
module_path = path.relative_to("streampipes_client").with_suffix("")
doc_path = path.relative_to("streampipes_client").with_suffix(".md")
for path in sorted(Path("streampipes").rglob("*.py")):
module_path = path.relative_to("streampipes").with_suffix("")
doc_path = path.relative_to("streampipes").with_suffix(".md")
full_doc_path = Path("reference", doc_path)

parts = list(module_path.parts)
Expand All @@ -42,7 +42,7 @@

with mkdocs_gen_files.open(full_doc_path, "w+") as fd:
identifier = ".".join(parts)
print(f"::: streampipes_client.{identifier}", file=fd)
print(f"::: streampipes.{identifier}", file=fd)

mkdocs_gen_files.set_edit_path(full_doc_path, path)

Expand Down
4 changes: 2 additions & 2 deletions streampipes-client-python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import setuptools

# Package meta-data.
NAME = "streampipes-client"
NAME = "streampipes"
DESCRIPTION = "Python client for Apache StreamPipes"
LONG_DESCRIPTION_CONTENT_TYPE = "text/markdown"
URL = "https://github.com/apache/streampipes/"
Expand Down Expand Up @@ -74,7 +74,7 @@

# Load the package's __version__.py module as a dictionary.
about = {}
with open(os.path.join(here, "streampipes_client", "__version__.py")) as f:
with open(os.path.join(here, "streampipes", "__version__.py")) as f:
exec(f.read(), about)

# Where the magic happens:
Expand Down
Loading

0 comments on commit 8a6ef00

Please sign in to comment.