Nov 2, 2017

Cleanup your TM1 application

Sometimes our TM1 models (especially non-production environments) become messed up with temporary and unwanted objects, like

  • subsets and views that were used in TI processes, but not properly deleted
  • temporary processes that were used to test stuff
  • cubes and dimensions for prototyping

In many cases we do use certain naming conventions when we create temporary objects, like we prefix all the processes with ‘temp_’ or ‘test’. It can be a tedious task though, to walk through your model object by object and delete stuff that matches a certain naming convention.

Writing a TM1 process which loops through TM1 objects

Writing a TI process on the other Hand can be cody and might rely on the data directory (which is not a sustainable approach anymore, considering recent developments in the TM1 server, such as Encryption for Data at Rest)

Neither option is convenient. TM1py can help!

Through TM1py you can Read, Update, Create and Delete all kind of TM1 objects.
When we combine this with the power of Regular Expressions we can write scripts that clean our models from all temporary or unwanted objects with the ease of python and regular expressions.

This article explains how to run the TM1py scrip cleanup If you have downloaded the TM1py samples, you can find this script in the folder called Other:

The objective is to delete all TM1 objects starting with TM1py in the Canvas Sample TM1 instance:

1. Update TM1 settings and the regular expression

Open the script with any text editor or using PyCharm, update the TM1 connection settings (address, port, user, password, ssl). Before running the script you should make sure that TM1py can connect to TM1 instance.

To delete all TM1 objects starting with TM1py we are using the following regular expression:

  • regex_list = [‘^TM1py*’]

Your script should look like this:

2. Run the script

In a command line, navigate to the folder where the script is located and then type:

  • python “cleanup”

If you check now your TM1 instance, all TM1 objects starting with TM1py should have been deleted.

Related content

Loading related content