Skip to main content

Python SDK for reading and writing signals to Clarify.

Project description

Clarify logo

PyClarify

PyPI package Version number Downloads Downloads Actions Status License Code style: black


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 pandas with 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

Prerequisites

In order to start using the Python SDK, you need

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 the typing use of new type system features on older Python versions, allowing us to support python 3.7+.

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.

Open In Colab

Access you data with the ClarifyClient

from pyclarify import Client

client = Client("clarify-credentials.json")

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyclarify-0.6.7.tar.gz (44.0 kB view details)

Uploaded Source

Built Distribution

pyclarify-0.6.7-py3-none-any.whl (61.3 kB view details)

Uploaded Python 3

File details

Details for the file pyclarify-0.6.7.tar.gz.

File metadata

  • Download URL: pyclarify-0.6.7.tar.gz
  • Upload date:
  • Size: 44.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for pyclarify-0.6.7.tar.gz
Algorithm Hash digest
SHA256 765781653a52047f030abf9e32dda4698d03408d04091041cbe2770a64bf17d3
MD5 e5a34d23dcb15d633433b3b77360846e
BLAKE2b-256 1baa19dbff46be16080f6fe9b9637794dd32e5f3eb384904e74d502f5850b6f6

See more details on using hashes here.

File details

Details for the file pyclarify-0.6.7-py3-none-any.whl.

File metadata

  • Download URL: pyclarify-0.6.7-py3-none-any.whl
  • Upload date:
  • Size: 61.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for pyclarify-0.6.7-py3-none-any.whl
Algorithm Hash digest
SHA256 9a89f2af6395f9042bc789a8f9b50f9dd1007de3cd676b0c18777c6a7fd8fda3
MD5 c89fe4aad3fed8bf70d0fb5c7a141427
BLAKE2b-256 7dbc339ee1fbbfbddcfb3e6ee4f3cf45c0771c41a58a74d50ede8654d406324b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page