Atoti Python API
This section walks you through integrating Atoti Limits with the Atoti Python API.
note
The process differs between Atoti Limits 1.1.0 and earlier releases. Please see the previous release notes if you are connecting the Atoti Python API with a Atoti Limits 1.0.X release.
Prerequisites
Tool | Minimum Version |
---|---|
Atoti Python API | 0.6.4 |
Integration
Overview
We have created and published a Python plugin that will allow the Python API to auto-connect to a running Limits server once the session and cube have been created. To use the plugin:
Steps to connect
1. Install the plugin
note
To install the plugin, you must be in the Crowd groups granting you access to the required Artifactory repositories. If you don’t already have access, contact the Customer Success team.
Like the core atoti
package and the other plugin packages, atoti-limits
can be installed as a Python package or as a Conda package but pip
, poetry
, or conda
need some extra configuration to be able to download the package from private repositories.
In the commands below, replace {{username}}
and {{password}}
with your credentials, escaping them if they
contain reserved characters.
pip
pip install atoti-limits --extra-index-url https://{{username}}:{{password}}@activeviam.jfrog.io/artifactory/api/pypi/bas-tools-pypi-release/simple
Poetry
First, follow Poetry’s instructions to configure https://activeviam.jfrog.io/artifactory/api/pypi/bas-tools-pypi-release/ as a private repository:
# Name our repo `jfrog`
poetry source add jfrog https://activeviam.jfrog.io/artifactory/api/pypi/bas-tools-pypi-release/
# Note that if your password contains reserved characters you should enclose it in quotes (eg `pa$$word`)
# Percent-encoding will not work here
poetry config http-basic.jfrog <username> <password>
Then:
poetry add atoti-limits
Conda
Add the atoti channel:
conda config --add channels https://{{username}}:{{password}}@conda.atoti.io
Install atoti-limits
:
conda install atoti-limits
2. Start the Limits server
Start the Limits server using the installation instructions and wait for a connection request.
3. Start the Python API
Create a session using the Python API, create a cube and wait for the python API to connect to the running Limits server. By default, the atoti-limits plugin will attempt to connect to Limits using the following properties:
Property | Default |
---|---|
limits.rest.url |
http://localhost:3090/limits/rest/v1/ |
limits.auth |
YWRtaW46YWRtaW4= |
ap.auth |
YWRtaW46YWRtaW4= |
content.server.auth |
YWRtaW46YWRtaW4= |
Note that it is no longer required to register the LookUpPostProcessor
as per previous Atoti Limits versions.
Example code to create the session and cube would look as follows:
import atoti as tt
from atoti import Session
# Create the session
session = tt.Session(
name="atoti",
port=6060
)
# At this point the Atoti session will attempt to connect to the module. However, as the cube
# has not yet been created the connection request will not be sent.
# So let's create the cube:
# 1. Create the data table
session.create_table(
name="Cars",
types={
"CarName": tt.type.STRING,
"Price": tt.type.FLOAT,
"Date": tt.type.LOCAL_DATE,
},
keys=["CarName", "Date"]
)
# Note that we need to supply a slicing "Date" hierarchy. This is required by the LookUpPostProcessor
# to evaluate the Limit.
# 2. Load some data into the table
cars_table.load_csv("cars.csv")
# 3. Create the cube from the table
cube = session.create_cube(
base_table=cars_table,
name="Cars_Cube",
)
# 4. Set the date hierarchy as slicing, as per above
cube.hierarchies["Date"].slicing = True
At this point the Atoti session will send a connection request to the running Limits server and Atoti Limits will connect to the cube.
Limits is registered!
Now your Atoti Python instance is ready to wire into Atoti Limits.
You can now create Limit definitions in Atoti Limits and configure the module to use your Atoti Pyhthon API instance as an AP instance.