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.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"],
)

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.1.tar.gz (121.5 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.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for piscada_foresight-0.6.1.tar.gz
Algorithm Hash digest
SHA256 668754e2e41aedf9b1ef3d3533e9bc2a835efd3ee0b693f1eabca630429cd8da
MD5 10504a49fda7e04e5c1846316451f784
BLAKE2b-256 6b43707af3c594fe18e76410c9d4afd3c945a8547d967fddfecc80fdce9452a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for piscada_foresight-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 67a6de98bde110f72ddd82f885c44c3790ce5e1904a4400f11ac7623a0c06813
MD5 03b7c90224a466894d3a760d656584a3
BLAKE2b-256 92cd525d3e2cdded14f3fafd09345de9912d9a14f47ee81254d4785b780574e1

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