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.13b2.tar.gz (86.6 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.13b2-py3-none-any.whl (119.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: oianalytics-0.6.13b2.tar.gz
  • Upload date:
  • Size: 86.6 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.13b2.tar.gz
Algorithm Hash digest
SHA256 bf361dca0d89ffb807ec2528f4149d8e7576b41991a23d293f399254c1b07ff2
MD5 8f2e4046c2043ce23c8b19e10a5110b5
BLAKE2b-256 454361934ce55ca144d578b738355320627f836df2d6193ef5ddf76bb6cd5857

See more details on using hashes here.

Provenance

The following attestation bundles were made for oianalytics-0.6.13b2.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.13b2-py3-none-any.whl.

File metadata

  • Download URL: oianalytics-0.6.13b2-py3-none-any.whl
  • Upload date:
  • Size: 119.0 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.13b2-py3-none-any.whl
Algorithm Hash digest
SHA256 f030cbaf23f089ebe81d894dcb8c6922607cb3efeb4444e7451b2d42a1ba5d96
MD5 f7cbeb35f6a7eecf1a8933eb89d39999
BLAKE2b-256 5819109c6298a16fa22ca72ee9bae4417095cc5e719367b7fd12a49f13cf60a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for oianalytics-0.6.13b2-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