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 Seriesget_value()
: Get latest value before a given timeget_values()
: Get values between start and end timeget_all_values()
: Extract all values from a graph query response
-
domains
module: Access domain definitions and trait hierarchiesDomain
class: Contains traits and relationships for a domainget_trait_by_id()
: Gets a trait by its ID
get_domains()
: Retrieve list of all available domainsget_trait_by_id()
: Get a trait from any domain by its ID stringget_parent_traits()
: Get all parent traits for a given trait
-
http
module: OAuth2 authenticated transportForesightHTTPXTransport
class: HTTPX transport with OAuth2 authenticationconnect()
: 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 uuid import UUID
from gql import Client
from piscada_foresight.data import get_value, get_values
from piscada_foresight.http import ForesightHTTPXTransport
# Create a transport with authentication and a GraphQL client:
transport = ForesightHTTPXTransport("foresight.piscada.cloud")
fs_client = Client(transport=transport, fetch_schema_from_transport=False)
# Retrieve timeseries values for a specific entity:
get_values(
fs_client,
UUID("ENTITY_ID"),
datetime.now(tz=timezone.utc) - timedelta(hours=8),
)
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
Built Distribution
File details
Details for the file piscada_foresight-0.3.1.tar.gz
.
File metadata
- Download URL: piscada_foresight-0.3.1.tar.gz
- Upload date:
- Size: 99.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.30
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af4bd53349d45bb4989c9eb198238bae32761ff17cabf00719ffed5b21eed920 |
|
MD5 | bcb770e657741299e1f8ffe2b8b436e0 |
|
BLAKE2b-256 | 1edc83356d881292ceefc97c2016ae52aab31f8853f50f883e3143e56c56dbff |
File details
Details for the file piscada_foresight-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: piscada_foresight-0.3.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.30
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | da0fcfe3ad0c84bceb032d30ac950320e4170663a0458a19e905f54c27036984 |
|
MD5 | 79d44d3381daf34f770ba8bd0629bb87 |
|
BLAKE2b-256 | 7cd45ff540ad31d756928d2471757f3c4035d2ff4bc9a508c440d1de7e64cfbf |