TM1py

What is TM1py?

TM1py - logo small.png

TM1py is a Python package that wraps the TM1 REST API in a simple to use library. That makes it easy to build stuff with TM1 and python.


Python is a widely-used general-purpose programming language that lets you work quickly and integrate systems more effectively.
 

Why you should use it?

  • Use Pandas for Data Analysis and Statistics on top of your TM1 model.
  • Build Machine Learning and Forecasting Algorithms with Python and scikit-learn based on your TM1 data.
  • Load data (e.g. FX, stock data) from web services into TM1 such as Quandl financial.
  • Do stuff across different TM1 instances (e.g. reschedule all chores on all instances by -1 hour, synchronize cubes throughout TM1 instances)
  • Get insights from your TM1 model. (e.g. Which views use this subset?, which process has an ODBC Datasource?)
  • Export TM1 data to XML, JSON, YAML, XLSX, …
  • Bring Regular Expressions, Lists, Dictionaries, Classes, Functions and all kind of programming concepts to the TM1 world, that make your life easier as a developer.
  • Run TM1 processes and write to TM1 in parallel.
  • Generate MDX Queries from cube views.

Examples

All samples can be downloaded from the github.com/cubewise-code/TM1py-samples.

Reschedule all chores on once instance by - 1 hour:

with TM1Service(address='localhost', port=8001, user='admin', password='apple', ssl=True) as tm1:
    for chore in tm1.chores.get_all():
        chore.reschedule(hours=-1)
        tm1.chores.update(chore)
 

Find unused dimensions

from TM1py.Services import TM1Service

# Connect to TM1
with TM1Service(address='localhost', port=8001, user='admin', password='apple', ssl=True) as tm1:
    # get all dimensions
    all_dimensions = tm1.dimensions.get_all_names()
    # get all cubes
    all_cubes = tm1.cubes.get_all()
    # find used dimensions
    used_dimensions = set()
    for cube in all_cubes:
        used_dimensions.update(cube.dimensions)
    # determine unused dimensions
    unused_dimensions = set(all_dimensions) - used_dimensions

    print(unused_dimensions)
 

Generate a TM1 MDX Query from cube view

from TM1py.Services import TM1Service


# Establish connection to TM1 Server
with TM1Service(address='localhost', port=8001, user='admin', password='apple', ssl=True) as tm1:

    # Instantiate TM1py.NativeView object
    nv = tm1.views.get_native_view('Plan_BudgetPlan', 'High Level Profit And Loss', private=False)

    # Retrieve MDX from native view. Print it
    print(nv.MDX)

Warranties

All of the code, documents and information in TM1py are to be deemed without warranty.


Contributions

The source code is hosted at github.com/cubewise-code/tm1py. If you find a bug or feel like you can contribute please fork the repository, update the code and then create a pull request so we can merge in the changes.