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
190 stars 110 forks source link

Deploy a TI process (create or update) from one instance to another #1189

Closed abetschenIBM closed 2 weeks ago

abetschenIBM commented 2 weeks ago

Hi,

I would like to build a JupyterNotebook or py code, that allows me to publish/push a process from one TM1 instance to another. I am still new to tm1py so I looked at available code such as :

I tried the following but it does not seem to work. I get an syntax error: "SyntaxError: invalid syntax". Can you help me with the correct syntax or code

import TM1py

tm1_src = TM1py.TM1Service(
    base_url= "URL/api/Instance_ID/v0/tm1/DEV/",
    user= "apikey",
    password= "actual apikey",
    async_requests_mode= True,
    ssl= True,
    verify= True
)

tm1_tgt = TM1py.TM1Service(
    base_url= "URL/api/Instance_ID /v0/tm1/PRE_PROD/",
    user= "apikey",
    password= "actual apikey",
    async_requests_mode= True,
    ssl= True,
    verify= True
)

# Specify the process name
pName = "zzz_Test_TVA"

# get the process from both src 
p = tm1_src.processes.get(pName)

# create process in tgt environment
tm1_tgt.processes.create(process:pName, p)

Version

Thank you for your help. Andre

abetschenIBM commented 2 weeks ago

With the help of a colleague, I figured out the correct synthax

tm1_tgt.processes.update_or_create(p)