PyClarify
from pyclarify import Client
data = {
"times": ["2022-10-10T00:00:00"],
"series": {
"temperature": [19],
"pressure": [1025]
}
}
client = Client("credentials.json")
client.insert(data)
PyClarify helps users of Clarify to easily read, write and manipulate data in Clarify.
- Data scientists can easily filter data, convert it to
pandaswith our built in methods, and write results back. - System integrators can set up pipelines for automatic streaming of data, and update labels on the fly.
Useful tutorials and documentation
- PyClarify SDK
- PyClarify documentation
- Clarify Developer documentation
- Basic tutorial on using Python with Clarify
Prerequisites
In order to start using the Python SDK, you need
- To know a bit of Python. For a refresher, see the Official Python tutorial.
- Python 3.10 or newer and pip.
- Credentials from a Clarify integration. See the introduction notebook for a complete introduction.
Where to get it
The source code is currently hosted on GitHub at: https://github.com/clarify/pyclarify
Binary installers for the latest released version are available at the Python Package Index (PyPI).
# PyPI install
pip install pyclarify
# Conda install
conda install pyclarify
Dependencies
- requests - The most used (and trusted) HTTP library.
- Pydantic - Allowing for strict typing and data validation.
- Typing Extensions - Brings new type system features, such as deprecation markers, to older Python versions.
Interact with Clarify
PyClarify provides a fast and easy way to interact with Clarify.
The Client class takes as an argument the path of your credentials in string format, which should always be the first step when starting to interact with PyClarify.
For information about the Clarify Developer documentation click here.
Quickstart
We recommend using Google Colab to quickly learn how to interact with Clarify using Python. We have created an interactive introduction tutorial where you will learn all the basics to get you started.
Access you data with the ClarifyClient
from pyclarify import Client
client = Client("clarify-credentials.json")
Choose the API version
PyClarify uses Clarify API 1.1 unless you choose another version. Features from API 1.2, such as group aggregations in evaluate and connecting signals to items, need a client created for 1.2:
client = Client("clarify-credentials.json", api_version="1.2")
Create new Signals
from pyclarify import Signal
signal = Signal(
name = "Home temperature",
description = "Temperature in the bedroom",
labels = {"data-source": ["Raspberry Pi"], "location": ["Home"]}
)
response = client.save_signals(
input_ids=["INPUT_ID"],
signals=[signal],
create_only=False
)
Populate your signals using DataFrames
from pyclarify import DataFrame
data = DataFrame(
series={"INPUT_ID_1": [1, None], "INPUT_ID_2": [None, 5]},
times = ["2021-11-01T21:50:06Z", "2021-11-02T21:50:06Z"],
)
response = client.insert(data)
Query your stored signals
response = client.select_signals(
skip=10,
limit=50,
sort=["-id"]
)
Publish them as Items
from pyclarify import Item
client = Client("./clarify-credentials.json")
item = Item(
name = "Home temperature",
description = "Temperature in the bedroom",
labels = {"data-source": ["Raspberry Pi"], "location": ["Home"]},
visible=True
)
response = client.publish_signals(
signal_ids=['<SIGNAL_ID>'],
items=[item],
create_only=False
)
Use filters to get a specific selection
from pyclarify.query import Filter, Regex
only_raspberries = Filter(
fields={
"labels.unit-type": Regex(value="Raspberry")
}
)
response = client.select_items(
filter=only_raspberries
)
Get the data and include relationships
response = client.data_frame(
filter=only_raspberries,
include=["item"]
)
Look at our reference!
Changelog
Wondering about upcoming or previous changes to the SDK? Take a look at the CHANGELOG.
Contributing
Want to contribute? Check out CONTRIBUTING.
Metadata
Release files for pyclarify 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyclarify-0.7.0.tar.gz | 49.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyclarify-0.7.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 116.6 kB
Release files / pyclarify-0.7.0.tar.gz
| Download URL | pyclarify-0.7.0.tar.gz |
|---|---|
| Size | 49.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ccc451717c5eafc0e9a2f23c38dbb4a23790db4929a8a4c1430eb5ef0ec5221
|
|
BLAKE2b-256 checksum How to use checksums |
e001d102fe0583d1f89c65ff3709580b7374c29eeb56d0acf9c43d30a5071852
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / pyclarify-0.7.0-py3-none-any.whl
| Download URL | pyclarify-0.7.0-py3-none-any.whl |
|---|---|
| Size | 67.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
534381e251d6b6d3cd49330c024a510d7265d117df9b8c79d237de7a9985a0ac
|
|
BLAKE2b-256 checksum How to use checksums |
1c4c585acf6dd7edc629bcb6662cbc73d91f650d0784d01cef12877c75634ef1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|