cubewise-code / tm1py

TM1py is a Python package that wraps the TM1 REST API in a simple to use library.
http://tm1py.readthedocs.io/en/latest/
MIT License
189 stars 109 forks source link

Slow connections to TM1 REST API on own laptop #559

Closed wimgielis closed 2 years ago

wimgielis commented 3 years ago

Hello all,

Describe what did you try to do with TM1py I posted a question about CubeCalc: https://github.com/cubewise-code/cubecalc/issues/13 As it involves tm1py and TM1 REST API coding, this might attract the interest of followers of tm1py.

But my main question here is about the connection with the TM1 REST API to my own TM1 models on my own laptop.

Describe what's not working the way you expect I have 2 models, called "BV" and "TI processes". Small models, most of it is TI library processes and some personal stuff like finances. Next to that, I did some development to use the TM1 REST API (without tm1py, in Excel VBA / PowerShell / AutoHotyKey) and also with tm1py (in Python).

What strikes me is the time needed to connect to those TM1 models. It's literally 2-3 seconds. I also connect to customer models remotely, on IBM cloud but also on premise, and then it's almost instantaneous. IntegratedSecurityMode = 1 in both occasions.

What could potentially explain why it takes so "long" (relatively speaking) ? Are there causes I could look into ?

Version

MariusWirtz commented 3 years ago

Hi @wimgielis,

I can confirm your finding. Connecting to my local TM1 instance with basic security takes ~2 sec:

from datetime import datetime

from TM1py import TM1Service

start = datetime.now()

with TM1Service(address="", port=12354, user="admin", password="apple", ssl=True) as tm1:
    print(f"Elapsed time: {datetime.now() - start}")

Elapsed time: 0:00:02.080807

It's slightly slower than postman (< 1sec). We should look into this and see if we can be faster. However, I guess in most TM1py use cases this initial delay is not dramatic and barely noticeable. Does anyone feel differently about this one?

Re your situation in cubecalc, this feature (multiple executions/projects in one run) is something that has long been asked for. I just didn't find time to build it yet. Feel free to open a MR and I will review and comment. Otherwise, I would probably build it in Q3 this year.