Atoti Python API
This section walks you through integrating Atoti Limits with the Atoti Python API using the Limits Atoti Python plugin.
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 an Atoti Limits 1.0.X release.
Compatability Matrix
Limits version | Limits Atoti Python plugin version | Atoti Python API version | Atoti Server version |
---|---|---|---|
1.1.0 | 0.6.4 | 0.6.4 | 5.11.x |
2.0.0 | 0.7.4 | 0.7.4 | 6.0.4 |
note
The version of the Limits Atoti Python plugin must match the version of the Atoti Python API to which it is trying to connect with.
Integration
Overview
The Limits Atoti Python plugin allows the Atoti Python API to auto-connect to a running Atoti Limits server once the session and Cube have been created.
How It Works
The plugin acts as a bridge between an Atoti Python Cube and a standalone Atoti Limits server. It is not a Python version of Atoti Limits.
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/
# If your password contains reserved characters, enclose them 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/v2/ |
limits.auth |
YWRtaW46YWRtaW4= |
ap.auth |
YWRtaW46YWRtaW4= |
content.server.auth |
YWRtaW46YWRtaW4= |
note
Registering the LookUpPostProcessor
as in previous Atoti Limits versions, is no longer required.
Example code to create the session and Cube would look as follows:
import atoti as tt
from atoti import Session
# Create the session
# JWT config parameters used by the Atoti Python API. These should be the same as the keys in jwt.properties
jwt_config = tt.JwtConfig(
key_pair=tt.KeyPair(
public_key="{publicKey}",
private_key="{privateKey}"
)
)
session = tt.Session(
name="atoti",
port=6060,
jwt=jwt_config,
same_site="none",
authentication=tt.BasicAuthenticationConfig()
)
# Add an authenticated user. This is required in order for Limits to send REST requests to the server. Note that the ACTIVITI Roles must be added.
user_service_client = UserServiceClient.from_session(session)
role_activiti_user = user_service_client.create_role("ROLE_ACTIVITI_USER", restrictions={})
role_activiti_admin = user_service_client.create_role("ROLE_ACTIVITI_ADMIN", restrictions={})
role_managers = user_service_client.create_role("ROLE_MANAGERS", restrictions={})
role_limits = user_service_client.create_role("ROLE_LIMITS", restrictions={})
admin = user_service_client.basic.create_user("admin", password="admin")
user_service_client.individual_roles[admin.username].add(role_activiti_user.name)
user_service_client.individual_roles[admin.username].add(role_activiti_admin.name)
user_service_client.individual_roles[admin.username].add(role_managers.name)
user_service_client.individual_roles[admin.username].add(role_limits.name)
user1 = user_service_client.basic.create_user("user1", password="user1")
user_service_client.individual_roles[user1.username].add(role_activiti_user.name)
user_service_client.individual_roles[user1.username].add(role_limits.name)
user_service_client.individual_roles[user1.username].add("ROLE_USER")
manager1 = user_service_client.basic.create_user("manager1", password="manager1")
user_service_client.individual_roles[manager1.username].add(role_activiti_user.name)
user_service_client.individual_roles[manager1.username].add(role_limits.name)
user_service_client.individual_roles[manager1.username].add("ROLE_USER")
user_service_client.individual_roles[manager1.username].add(role_managers.name)
# 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(
"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 Connected!
Now your Atoti Python instance is ready to use Atoti Limits.
You will be able to use the Atoti Python UI - by default located at http://localhost:6060
- to view limit KPIs in the Cube. To use the Atoti Limits UI,
the user will have to set up their UI as per the UI Activation page.
Note that the default server name for the Atoti Python Cube is atoti
.