Skip to main content

Arrakis Python client library

Project description

arrakis-python

Arrakis Python client library

ci ci documentation pypi version conda version


Resources

Installation

With pip:

pip install arrakis

With conda:

conda install -c conda-forge arrakis-python

Features

  • Query live and historical timeseries data
  • Describe channel metadata
  • Search for channels matching a set of conditions
  • Publish timeseries data

Quickstart

Fetch timeseries

import arrakis

start = 1187000000
end = 1187001000
channels = [
    "H1:CAL-DELTAL_EXTERNAL_DQ",
    "H1:LSC-POP_A_LF_OUT_DQ",
]

block = arrakis.fetch(channels, start, end)
for channel, series in block.items():
    print(channel, series)

where block is a [arrakis.block.SeriesBlock][] and series is a [arrakis.block.Series][].

Stream timeseries

1. Live data
import arrakis

channels = [
    "H1:CAL-DELTAL_EXTERNAL_DQ",
    "H1:LSC-POP_A_LF_OUT_DQ",
]

for block in arrakis.stream(channels):
	print(block)
2. Historical data
import arrakis

start = 1187000000
end = 1187001000
channels = [
    "H1:CAL-DELTAL_EXTERNAL_DQ",
    "H1:LSC-POP_A_LF_OUT_DQ",
]

for block in arrakis.stream(channels, start, end):
    print(block)

Describe metadata

import arrakis

channels = [
    "H1:CAL-DELTAL_EXTERNAL_DQ",
    "H1:LSC-POP_A_LF_OUT_DQ",
]

metadata = arrakis.describe(channels)

where metadata is a dictionary mapping channel names to [arrakis.channel.Channel][].

Find channels

import arrakis

for channel in arrakis.find("H1:LSC-*"):
    print(channel)

where channel is a [arrakis.channel.Channel][].

Count channels

import arrakis

count = arrakis.count("H1:LSC-*")

Publish timeseries

from arrakis import Channel, Publisher, SeriesBlock, Time
import numpy

# admin-assigned ID
publisher_id = "my_producer"

# define channel metadata
metadata = {
    "H1:FKE-TEST_CHANNEL1": Channel(
        "H1:FKE-TEST_CHANNEL1",
        data_type=numpy.float64,
        sample_rate=64,
    ),
    "H1:FKE-TEST_CHANNEL2": Channel(
        "H1:FKE-TEST_CHANNEL2",
        data_type=numpy.int32,
        sample_rate=32,
    ),
}

publisher = Publisher(publisher_id)
publisher.register()

with publisher:
    # create block to publish
    series = {
        "H1:FKE-TEST_CHANNEL1": numpy.array([0.1, 0.2, 0.3, 0.4], dtype=numpy.float64),
        "H1:FKE-TEST_CHANNEL2": numpy.array([1, 2], dtype=numpy.int32),
    }
    block = SeriesBlock(
        1234567890 * Time.SECONDS,  # time in nanoseconds for first sample
        series,                     # the data to publish
        metadata,                   # the channel metadata
    )

    # publish timeseries
    publisher.publish(block)

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

arrakis-0.4.0.tar.gz (114.2 kB view details)

Uploaded Source

Built Distribution

arrakis-0.4.0-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file arrakis-0.4.0.tar.gz.

File metadata

  • Download URL: arrakis-0.4.0.tar.gz
  • Upload date:
  • Size: 114.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.2

File hashes

Hashes for arrakis-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3099e5fd1e6e1c5fae7b05f3cdccfa517f876f98b7e6653315aca1109be87e96
MD5 fd2075be9178180b12112a3fd89ccd28
BLAKE2b-256 f96d7d3703ca4d9387c09830f679f2a2e3e54d1bd3ba6a81e9da8258079e6f50

See more details on using hashes here.

File details

Details for the file arrakis-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: arrakis-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 36.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.2

File hashes

Hashes for arrakis-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df487e28569e036ad6cc833103dd594ac7a03ebdfb8ad0ce82a27946388df790
MD5 daef14c3bfb655f4325a112d9b61dfbc
BLAKE2b-256 101512b9b0969f4f95caf03e2fed61e789d26c5bb6d09ea07e84fdfc9a6b6c9a

See more details on using hashes here.

Supported by

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