Skip to main content

Library for Piscada Foresight; Access knowledge-graph and timeseries data.

Project description

Piscada Foresight

Access knowledge-graph and timeseries data.

Overview

This library provides access to the knowledge-graph and timeseries data in the Foresight platform. It implements a Transport using HTTPX to be used with the GQL GraphQL client. It provides the following modules:

  • data module: Read timeseries values as Pandas DataFrames or Series

    • get_value(): Get latest value before a given time
    • get_values(): Get values between start and end time
    • get_all_values(): Extract all values from a graph query response
  • domains module: Access domain definitions and trait hierarchies

    • Domain class: Contains traits and relationships for a domain
      • get_trait_by_id(): Gets a trait by its ID
    • get_domains(): Retrieve list of all available domains
    • get_trait_by_id(): Get a trait from any domain by its ID string
    • get_parent_traits(): Get all parent traits for a given trait
  • http module: OAuth2 authenticated transport

    • ForesightHTTPXTransport class: HTTPX transport with OAuth2 authentication
      • connect(): Establish authenticated connection

Installation

pip install piscada-foresight

You will need access to a Piscada Foresight instance. The library uses the OAuth2 Authorization Code Flow with Proof Key for Code Exchange (PKCE) to act on behalf of your user. After an initial interactive login, the library persists the session state in $HOME/.<client_id>_state and will use that to authenticate non-interactive the next time.

Usage

from datetime import datetime, timedelta, timezone

from piscada_foresight.data import get_value, get_values
from piscada_foresight.queries_templates.query_manager import QueryManager

domain = "foresight.piscada.cloud"
query_manager = QueryManager(domain)

# Retrieve timeseries values for two specific entites:
get_values(
  query_manager,
  entity_ids=["ENTITY_ID", "ENTITY_ID2"],
  start=datetime.now(tz=timezone.utc) - timedelta(hours=8),
)

# Retrieve aggregated timeseries values for two specific entites:
get_values(
  query_manager,
  entity_ids=["ENTITY_ID", "ENTITY_ID2"],
  start=datetime.now(tz=timezone.utc) - timedelta(hours=8),
  interval="1h",
  aggregation_functions=["min", "max", "avg", "count", "last"],
)

Note: Not all interval values are accepted (e.g. 30m work but 45m won't work)

Contributing

Contributions are welcome! You can contact us at foresight@piscada.com.

Support

If you have any questions, issues, or suggestions, please contact us at foresight@piscada.com.

Copyright

© Piscada AS 2024

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

piscada_foresight-0.6.2.tar.gz (121.8 kB view details)

Uploaded Source

Built Distribution

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

piscada_foresight-0.6.2-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file piscada_foresight-0.6.2.tar.gz.

File metadata

  • Download URL: piscada_foresight-0.6.2.tar.gz
  • Upload date:
  • Size: 121.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.30

File hashes

Hashes for piscada_foresight-0.6.2.tar.gz
Algorithm Hash digest
SHA256 c48687e1919369ccb6c2c00f1693cc5ba32db2ee01035304b8aed29349447e3f
MD5 cd44f5830bb37090d48aacde9dd2bfbb
BLAKE2b-256 c4a4c264ef1d9a84d4af69fdf66679453aeec1113be0b94bba1a891aa3c2fde4

See more details on using hashes here.

File details

Details for the file piscada_foresight-0.6.2-py3-none-any.whl.

File metadata

File hashes

Hashes for piscada_foresight-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f0a664aa5078b93aac74ea7285f0f15a87f616c769cc00b005f107b891cb51e5
MD5 cab46b6f7eb76f7e6c346498c36b7e27
BLAKE2b-256 2fcc3755702d19f83812d55607cc939cb8e9a8a6f464c63f41e85291495cebce

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