atoti v0.6.5: Make way for more intuitive programming

Comes with concise functional calls to improve your coding experience

I remember when I first learned to program, I didn’t have a clue about classes, functions and variables, etc (in the case of Java back then). Silly old me thought variables must be named alphabetically, ranging from a to z until I exhaust all of them. 😀 

Java code snippet from W3Schools

As with most sample code snippets, function names are usually just symbolic. Looking at the code snippet above, are we able to tell what the function myMethod does? What exactly is the variable Z with regards to the input parameter x and y?

Function names shouldn’t be random. It should be as informative as possible to the person reviewing the code, and also as intuitive to the person writing the code. For instance, IMHO mySum would be more informative than myMethod in this case. In like manner, is mySum or mySummation better? K.I.S.S.-Keep It Short, Stupid…

What gets deprecated in atoti v0.6.5?

What has the above got to do with the new atoti v0.6.5 recently released? In this article, we are going to zoom in on the Deprecated section in the changelog.

Deprecated modules from atoti changelog

To begin with, we see the verb “create” has been dropped from most deprecated functions and users are able to instantiate the classes directly. We went from a class and a function to create it to just a class, so the API is smaller and easier to learn. 

Deprecating atoti.create_session

This change affects all users of atoti. We can quickly instantiate an atoti session by invoking atoti.Session directly. K.I.S.S. Remember it’s Session with a capital letter S.

One benefit of this change is that now we can directly pass the configurations as input parameters to the constructor. Consequently, we will be able to use the “Tab” key to see the available parameters for the function. This is definitely more user-friendly than the previous JSON input for the configuration to create_session

Syntax comparison for instantiating session in atoti v0.6.4 and v0.6.5, using example from Burrito notebook.
Reference from the burritos notebook in atoti notebook gallery

Client-side encryption in atoti for Cloud connectivity

Similarly, in client-side encryption for Azure or AWS connection, we can now quickly instantiate the classes atoti_azure.AzureKeyPair or atoti_aws.AwsKeyPair as demonstrated below:

client_side_encryption_config = AwsKeyPair(
    region="eu-west-3",
    private_key="private_key",
    public_key="public_key",
)

Alternatively, if you are using KMS configuration for AWS:

from atoti_aws import AwsKmsConfig

client_side_encryption_config = (
    AwsKmsConfig(
        region="eu-west-3",
        key_id="key_id",
    ),
)

Predefined ordering for members of levels

When we query a cube, we can define the default order for the members of the level. In the previous versions, we had:

  • atoti.comparator.ASCENDING
  • atoti.comparator.DESCENDING
  • atoti.comparator.first_members()

The functions are now streamlined to the following:

So, to order a level in descending order:

h, l, m = cube.hierarchies, cube.levels, cube.measures

l["date"].order = tt.NaturalOrder(ascending=False)
Ordering in descending order in atoti v0.6.5, using example from Global Covid Data notebook.
Dates arranged in descending order (Refer to Global Covid Data notebook)

On the other hand, atoti.CustomOrder allows us to fix the order of the members to any predefined sequence:

l["Month"].order = tt.CustomOrder(
    first_elements=[
        "January",
        "February",
        "March",
        "April",
        "May",
        "June",
        "July",
        "August",
        "September",
        "October",
        "November",
        "December",
    ]
)
Custom ordering in atoti v0.6.5, using example from Bike Sales notebook.
Months sorted in predefined sequence (Refer to Bike Sales notebook)

Integrate atoti with Kafka for real-time messaging

For real-time messaging, atoti is able to integrate with Kafka as shown below. We can use the default JSON_DESERIALIZER to consume incoming messages.

trade_attributes.load_kafka(
    bootstrap_server="localhost:9092",
    topic="trades",
    group_id="atoti-trades-consumer",
    deserializer=atoti_kafka.JSON_DESERIALIZER,  
)

Check out our Real-time Risk notebook if you’re interested to learn more. 

Improving syntax for better user experience

If you’re unsure of the syntax, use the “Tab” key to auto-suggest the list of available functions. Use “Shift+tab” to display the function description.

We are constantly improving our library to provide a better experience for our users. For that reason, we have prepared a wide variety of examples across different topics in our atoti notebook gallery for your reference.

Finally, we love to hear from you. Reach out to us on the atoti GitHub discussions forum.

Latest posts

Understanding Logs in Atoti
From the default log to how to configure additional logging Application logs are extremely important in any system! Most commonly, they are used to troubleshoot any issue that users may encounter while using an application. For instance, developers use them for debugging and the production support crew uses them to investigate outages. Not just that, in production, they are used to monitor an application’s performance and health. For instance, monitoring tools can pick up certain keywords to identify events such as “server down” or “system out of memory”. It can also serve as an audit trail to track user activity...
Atoti: Working with dates in Python
What is the most problematic data type you have ever dealt with when working with data? I would say dates! Depending on the locale, dates come in different formats such as YYYY-mm-dd, d/m/YYYY, d-mmm-yy etc. Not to mention, sometimes it comes with timestamps and time zones! We can let programs infer the date format or explicitly cast the data to date with a specific format e.g. in Python with Pandas DataFrame: What if we open the CSV file in Microsoft Excel, update it, and try to read it again? The above code snippet will throw out exceptions such as this:...
Understanding conditional statements in Atoti
When do we use filter, where and switch statements? We know that we can perform aggregations and multi-dimensional analysis with Atoti. Aggregation is not always as simple as 1 + 2. Sometimes we end up in an “if…else” situation, and that is where conditional statements come in. Let’s explore some examples with the XVA use case from the Atoti CE Notebook Gallery. Some definitions before moving on: Measures – we refer to metrics or quantifiable data that measure certain aspects of our goals. In the code snippets below, they are represented by measure[<name of metrics>]. Members of a level –...

Join our Community


    Like this post ? Please share

    Documentation
    Information
    Follow Us

    atoti Free Community Edition is developed and brought to you by ActiveViam. Learn more about ActiveViam at activeviam.com.