Skip to main content

This is the official Python library for the Myst Platform.

Project description

Myst Python Library

This is the official Python client library for the Myst Platform.

Requirements

  • Python 3.7+

Installation

To install the package from PyPI:

$ pip install --upgrade myst-alpha

Authentication

The Myst API uses JSON Web Tokens (JWTs) to authenticate requests.

The Myst Python library handles the sending of JWTs to the API automatically and currently supports two ways to authenticate to obtain a JWT: through your Google user account or a Myst service account.

Authenticating using your user account

If you don't yet have a Google account, you can create one on the Google Account Signup page.

Once you have access to a Google account, send an email to support@myst.ai with your email so we can authorize you to use the Myst Platform.

Use the following code snippet to authenticate using your user account:

import myst

myst.authenticate()

The first time you run this, you'll be presented with a web browser and asked to authorize the Myst Python library to make requests on behalf of your Google user account.

Authenticating using a service account

You can also authenticate using a Myst service account. To request a service account, email support@myst.ai.

To authenticate using a service account, set the MYST_APPLICATION_CREDENTIALS environment variable to the path to your service account key file:

$ export MYST_APPLICATION_CREDENTIALS=</path/to/key/file.json>

Then, go through the service account authentication flow:

import myst

myst.authenticate_with_service_account()

Alternatively, you can explicitly pass the path to your service account key:

from pathlib import Path

import myst

myst.authenticate_with_service_account(key_file_path=Path("/path/to/key/file.json"))

Working with time series

Time series are at the core of Myst's API. To retrieve a time series by UUID:

import myst

# You'll have to replace this UUID with the UUID of a time series you own.
time_series = myst.TimeSeries.get("ca2a63d1-3515-47b4-afc7-13c6656dd744")

You can insert a TimeArray into the time series:

import myst
import numpy as np

time_array = myst.TimeArray(
    sample_period="PT1H",
    start_time="2021-07-01T00:00:00Z",
    end_time="2021-07-08T00:00:00Z",
    as_of_time="2021-07-01T00:00:00Z",
    values=np.random.randn(168),
)
time_series.insert_time_array(time_array=time_array)

You can also query a time series for a given as of time and natural time range. In this example, the query should return the data we just inserted:

import myst
from myst.testing import assert_time_array_equal

returned_time_array = time_series.query_time_array(
    start_time=myst.Time("2021-07-01T00:00:00Z"),
    end_time=myst.Time("2021-07-08T00:00:00Z"),
    as_of_time=myst.Time("2021-07-01T00:00:00Z"),
)
assert_time_array_equal(returned_time_array, time_array)

Support

For questions or just to say hi, reach out to support@myst.ai.

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

myst-alpha-0.1.0.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

myst_alpha-0.1.0-py3-none-any.whl (39.9 kB view details)

Uploaded Python 3

File details

Details for the file myst-alpha-0.1.0.tar.gz.

File metadata

  • Download URL: myst-alpha-0.1.0.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.7.11 Linux/5.4.92-flatcar

File hashes

Hashes for myst-alpha-0.1.0.tar.gz
Algorithm Hash digest
SHA256 59aef28e266539762c62b86544660fc4b432bb812b44767cdf03b2cef55162ae
MD5 72d4116b41974c9fe679785aa9b6a834
BLAKE2b-256 a10bb72832019a1d813bf120e88ccef09c2c99b1abca6e42f99400f201f63f8b

See more details on using hashes here.

File details

Details for the file myst_alpha-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: myst_alpha-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 39.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.7.11 Linux/5.4.92-flatcar

File hashes

Hashes for myst_alpha-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7c0d3d8eff0bfaf5bcf2a97ef706c5a7d833e3f9e6117e24f439a942878fb25
MD5 7538ff866c6521b085ff161ca0c3b9bb
BLAKE2b-256 d57ed1a1c248962f1909ccbfd1b6f9237e2834667d35e2a90d0e88cbba1c585a

See more details on using hashes here.

Supported by

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