diff --git a/.gitignore b/.gitignore index 5f112e2..daae7c4 100644 --- a/.gitignore +++ b/.gitignore @@ -149,3 +149,4 @@ checklink/cookies.txt # Quarto .quarto +.devenv-corebridge/ diff --git a/README.md b/README.md index 9ec32b0..84cdd09 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,20 @@ This package provides functions and classes to run wodan style processing functions in the Stactics AICore environment. -## Install +## Installation + +Use ``` sh pip install corebridge ``` +to install corebrdige. + ## How to use ### Introduction -#### Wodan processing functions - Wodan is a proprietary backend service that applies high performance, custom analytical processing to timeseries data in the Whysor data and dashboarding environment. @@ -38,13 +40,17 @@ def multiply(data:np.ndarray, multiplier:float=1.0): ``` -#### AICore modules +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 one defines a class, always named `Module` with a constructor -`__init__` and a method `infer`. +For AICore users define a class, always named `Module` with a +constructor `__init__` and a method `infer`. This package defines a baseclass to quickly construct a custom `Module` -class that uses a wodan processor function inside the AICore system: +class that is able to use a wodan processor function inside the AICore +system: ``` {python} import numpy as np @@ -55,23 +61,32 @@ def multiply(data:np.ndarray, multiplier:float=1.0): class Module(corebridge.aicorebridge.AICoreModule): def __init__(self, save_dir, assets_dir, *args, **kwargs): - super().__init__(read, 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 and you could override `infer` for the same reason. +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. -``` python -``` +## Development + +Setup a virtual environment, activate it and install the development +package and dependencies with, on linux + + pip install -e ‘.\[dev\]’ + +or on Windows - 2 + pip install -e .\[dev\] -## nbdev cycle +### nbdev cycle - edit - nbdev_export -- pip install -e ‘.\[dev\]’ - nbdev_test - nbdev_clean - nbdev_readme diff --git a/corebridge/__init__.py b/corebridge/__init__.py index 788da1f..fe404ae 100644 --- a/corebridge/__init__.py +++ b/corebridge/__init__.py @@ -1 +1 @@ -__version__ = "0.2.4" +__version__ = "0.2.5" diff --git a/corebridge/core.py b/corebridge/core.py index 121005d..32245fa 100644 --- a/corebridge/core.py +++ b/corebridge/core.py @@ -95,15 +95,17 @@ def timeseries_dataframe_from_datadict( if orient == 'records': df = pd.DataFrame.from_records(data) - time_column = [C for C in df.columns if C.lower() in timecolumns][0] + time_column = [C for C in df.columns if C in timecolumns][0] elif orient == 'table': time_column = data['schema']['primaryKey'][0] df = pd.DataFrame.from_dict(data['data']).set_index(data['schema']['primaryKey']) df.index.name = 'time' + else: + time_column = [C for C in df.columns if C in timecolumns][0] + - df.columns = [C.lower() for C in df.columns] - time_column = [C for C in df.columns if C in timecolumns][0] + df.columns = list(df.columns) df[time_column] = pd.to_datetime(df[time_column],utc=True,format='ISO8601') df.set_index(time_column, inplace=True) #df.index = pd.DatetimeIndex(df.index).round('ms') diff --git a/settings.ini b/settings.ini index 6f1546e..222b403 100644 --- a/settings.ini +++ b/settings.ini @@ -5,7 +5,7 @@ ### Python library ### repo = corebridge lib_name = %(repo)s -version = 0.2.4 +version = 0.2.5 min_python = 3.7 license = apache2 black_formatting = False @@ -39,5 +39,5 @@ user = fenke ### Optional ### requirements = python-dateutil pytz numpy pandas scipy scikit-learn fastcore twine -dev_requirements = python-dateutil pytz numpy pyarrow pandas scipy scikit-learn fastcore jupyter ipywidgets jupyterlab>4 jupyter_contrib_nbextensions jupyterlab-git jupyterlab-quarto nbdev aiohttp asyncpg apscheduler twine +dev_requirements = python-dateutil pytz numpy pyarrow pandas scipy scikit-learn fastcore jupyter ipywidgets jupyterlab>4 jupyter_contrib_nbextensions jupyterlab-git jupyterlab-quarto nbdev aiohttp asyncpg apscheduler twine addroot # console_scripts = \ No newline at end of file