Skip to main content

Bridge for Stactics AICore

Project description

corebridge

This package provides functions and classes to run wodan style processing functions in the Stactics AICore environment.

Installation

Use

pip install corebridge

to install corebrdige.

How to use

Introduction

Wodan is a proprietary backend service that applies high performance, custom analytical processing to timeseries data in the Whysor data and dashboarding environment.

Each wodan module defines one function that operates as the entry point. The parameter annotations in this function definition are used to format data and retrieve parameters from the originating call to the wodan api. This function is called with data retrieved according to a specification and with additional parameters as annotated.

A simple function might look like:

import numpy as np

def multiply(data:np.ndarray, multiplier:float=1.0):
    return data * multiplier
    

Wodan binds this function to a service endpoint and takes care of fetching data and parameters and converting the result for the caller.

AICore modules

For AICore users define a class, always named CustomModule with a constructor __init__ and a method infer.

This package defines a baseclass to quickly construct a CustomModule class that is able to use a wodan processor function inside the AICore system:

import numpy as np
import corebridge

def multiply(data:np.ndarray, multiplier:float=1.0):
    return data * multiplier

class CustomModule(corebridge.aicorebridge.AICoreModule):
    def __init__(self, save_dir, assets_dir, *args, **kwargs):
        super().__init__(multiply, save_dir, assets_dir, *args, **kwargs)
    

That’s it. Well, you can add parameters to __init__ that can be used as hyperparameters in the web-interface and you could override infer for the same reason. The baseclass takes care of converting call parameters and data to the function specification and, calls the function and converts the result for the caller, similar to the original Wodan service.

Development

NBDev

This library is developed with NBDev - a literate programming toolkit that supports developing code using jupyter notebooks and mix code with documentation.

Literate programming is a methodology - introduced in 1984 by Donald Knuth - that combines a programming language with a documentation language. In this approach, a program is explained in a human language (such as English) alongside code snippets. The literate source file is then processed by a preprocessor to produce both source code and formatted documentation.

This paradigm enhances program robustness, portability, and maintainability, making it a valuable tool in scientific computing and data science[^1]

Quarto

Documentation is prepared from the notebook with Quarto. Quarto too combines code with documentation but it does not extract source code into modules like nbdev.

Installation

Quarto

Quarto uses Pandoc and, for pdf format, LaTeX. These must be available on your system.

Install Quarto as you see fit, there is a VSCode extension which handles this.

NBDev

NBDev is available as PyPi package and is installed with

pip install nbdev

or if you are using conda

conda install -c fastai -y nbdev

If so desired you can let NBDev install Quarto with

nbdev_install_quarto

But this ask for the system admin password.

Local editing & testing

Setup a virtual environment, activate it and install the development package and dependencies with, on linux

    pip install -e ‘.[dev]’

or on Windows

    pip install -e .[dev]

Jupyter

The above pip install should also install jupyter but to use it the kernel needs to be installed with:

    python -m ipykernel install --user --name=corebridge.venv

nbdev cycle

  • edit
  • nbdev_prepare

The latter performs - nbdev_export - nbdev_test - nbdev_clean - nbdev_readme

Then commit and to upload to Pypi with nbdev_pypi

[^1]: Wikipedia on ‘Literate Programming’

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

corebridge-0.3.1.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

corebridge-0.3.1-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file corebridge-0.3.1.tar.gz.

File metadata

  • Download URL: corebridge-0.3.1.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for corebridge-0.3.1.tar.gz
Algorithm Hash digest
SHA256 d774be6a6619a92601a0e4e35215158c63110d2e285ec3242161dec6c13aa8b0
MD5 6ad5b6faf17680a617cef6a100b2bfc8
BLAKE2b-256 8e07e5c87c522afe916b7067d905566efe86cf84492277ded014e50f6756269a

See more details on using hashes here.

File details

Details for the file corebridge-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: corebridge-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for corebridge-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b0f688f44629fc0eaed39f6fb5d0b409ab97745d16657aa72d4792430645e1a
MD5 f01b4fe0cbb3fba9e79d7874adce8c7e
BLAKE2b-256 75dc49f2e38833ff8d921f849195b57e9fa4335a50dbe9ae2bba53e15fc31db0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page