Skip to main content

Python tools for working with OIAnalytics

Project description

Installation

pip install oianalytics

Requirements: Python 3.9+, pandas 2.x, pydantic 2.x

Basic structure of the oianalytics package

The OIAnalytics SDK is mainly built around two modules: api, and models.
The api module is made for interacting with the OIAnalytics public API.
The models module is made for building and testing "custom models", which is custom Python script designed to be deployed on OIAnalytics.

API

The api module is mainly built with the following structure:

.
├── api                      # api module
│   ├── endpoints            # Basic implementations of endpoints of the OIAnalytics public API
│   ├── utils                # Some utilitaries
│   ├── _dataframes          # This submodule contains pandas wrappers around enpoints. Its content is usually called through aliases (e.g. api.get_data_list() instead of api._dataframes.data.get_data_list())
│   ├── _crendentials        # A few objects and functions required to authenticate to OIAnalytics. Usually called via aliases

Most basic usage consists in using functions from the _dataframes submodules via their aliases (e.g. api.get_data_list()).
These functions call the OIAnalytics endpoints and parse the results into pandas structures (usually dataframes), which make them convenient for data exploration and data processing.

Models

The models module is mainly built with the following structure:

.
├── models                   # models module
│   ├── templates            # Templates for building custom code intended to be deployed on OIAnalytics
│   ├── utils                # Some utilitaries
│   ├── testing              # Tools for testing custom code intended to be deployed on OIAnalytics
│   ├── outputs              # All the output objects that must be the outputs of custom code deployed on OIAnalytics, in order to make the application capable of gathering properly the results

This module is only used when developing a custom model, which is custom code intended to be deployed on OIAnalytics.

Basic usage

There are currently two main use cases for the oianalytics Python package:

  • Interacting with the OIAnalytics public API: This is done using the api module, for data manipulation, or individual operations on OIAnalytics
  • Building custom models for OIAnalytics: This is done using the models module, and usually by interacting with the OIAnalytics public API for data retrieval, for deploying scripts onto OIAnalytics

The basic import for the package is the following:

from oianalytics import api, models

Interacting with the OIAnalytics public API

Credentials

When interacting externally with the OIAnalytics public API, the first step is to setup access credentials.
After having created an API access key inside OIAnalytics (see OIAnalytics documentation), these can be used in a Python code using:

from oianalytics import api

cred = api.OIAnalyticsAPICredentials(  # (1)!
    base_url="https://{{platform_name}}.oianalytics.com",
    login="{{user_login}}",
    pwd="{{user_password}}"
)

cred.set_as_default_credentials()  # (2)!
  1. The content of the credentials must be adjusted in regard to your platform's url, and the access key attached to the user, created in OIAnalytics
  2. This method allows all further api calls to use these credentials without the need of specifying them (usually through the argument api_credentials=)

Raw endpoint call

For a low level interaction, raw endpoints are implemented in the api.endpoints module.
These functions return the raw JSON as retrieved from the public API.

from oianalytics import api

data_list_json = api.endpoints.data.get_data_list()

The endpoints are spread among several submodules: assets, azure_blob_sources, batches, computation_jobs, dashboard, data, events, files, model_instances, profiles, quantities, tags, units, users

Pandas wrappers

In most cases, it is more convenient for data processing to use the wrappers implemented in api._dataframes.
These functions usually call the raw endpoint then parse the results into pandas structures (series or dataframes), with parsing alternatives (e.g. retrieve the id or the description of an object).
These functions are embedded in submodules as well, but are made accessible at a higher level (hence the fact that it is a private module).
For instance, instead of calling api._dataframes.data.get_data_list() it is recommended to use the following:

from oianalytics import api

data_list_df = api.get_data_list()

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oianalytics-0.6.13b1.tar.gz (85.2 kB view details)

Uploaded Source

Built Distribution

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

oianalytics-0.6.13b1-py3-none-any.whl (116.8 kB view details)

Uploaded Python 3

File details

Details for the file oianalytics-0.6.13b1.tar.gz.

File metadata

  • Download URL: oianalytics-0.6.13b1.tar.gz
  • Upload date:
  • Size: 85.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oianalytics-0.6.13b1.tar.gz
Algorithm Hash digest
SHA256 01668361a29a1d6778317d7b6c456a997eb96bd01f56e43b0793e78c0ef357ca
MD5 12534edfbd85e7bb9185b77d8860c3e8
BLAKE2b-256 6fc890d973d8f115e16a70e78d257828bcba4328753fead1a02057a1d6092c68

See more details on using hashes here.

Provenance

The following attestation bundles were made for oianalytics-0.6.13b1.tar.gz:

Publisher: publish.yml on OptimistikSAS/oianalytics-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oianalytics-0.6.13b1-py3-none-any.whl.

File metadata

  • Download URL: oianalytics-0.6.13b1-py3-none-any.whl
  • Upload date:
  • Size: 116.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oianalytics-0.6.13b1-py3-none-any.whl
Algorithm Hash digest
SHA256 08b205be25b33b30d3b0fe392dfe00b9d2f8898363472f2264c3117e68a1c903
MD5 200846e35510b5c460a54d282c601646
BLAKE2b-256 d55d445ea7edef4ddc4a86ce52e18016ce5ca040ed40de0788db10483a7314bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for oianalytics-0.6.13b1-py3-none-any.whl:

Publisher: publish.yml on OptimistikSAS/oianalytics-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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