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
187 stars 107 forks source link

`tm1.bedrock` module to expose bedrock processes conveniently #928

Open MariusWirtz opened 1 year ago

MariusWirtz commented 1 year ago

We could introduce a module to TM1py that offers bedrock process execution most conveniently.

Based on the existing bedrock processes, we could introduce functions to TM1py that map 1 to 1 to the bedrock processes. Example:

with TM1Service(**tm1_params) as tm1:
    success, status, error_log_file = tm1.bedrock.bedrock_cube_data_clear(
        pStrictErrorHandling=1,
        pCube='Sales',
        pFilter='Year¦ 2022 + 2023 & Scenario¦ Actual + Budget & Organization¦ North America Operations')

This provides two advantages over calling bedrock processes the "normal way":

I imagine that Bedrock process injection is switched off by default. It could be passed to the bedrock_cube_data_clear function through an argument like create_if_necessary.

The actual code for the TM1py module could be generated by script based on the bedrock process JSON definitions.

onefloid commented 6 months ago

Hello Marius, do you already have an idea how to check if the existing Bedrock processes have a minimum version?

Is there already a solution? I thought about this and maybe a solution is to introduce a Front Matter (inspired by Jekyll Link) in the TI, where the version of the ti is exposed.

Example:

#Section Prolog
#****Begin: Generated Statements***
#****End: Generated Statements****

#---
# version = 1.1.3
#---

sText = 'IBM Cognos TM1';

Happy to hear if anyone have a other/better solution.

MariusWirtz commented 6 months ago

TBH my first thought was that TM1py uses whatever bedrock version is available in the instance. Only if bedrock isn't installed at all would TM1py "inject" it. This is would be the least invasive approach I think.

But I do agree that it would be right for bedrock processes to have a kind of "Front Matter" in the prolog. If this existed, the TM1py bedrock functions could be more intelligent and raise version errors.

@lotsaram What are your thoughts on the version comments?

lotsaram commented 6 months ago

Is this already covered by the existing comment header present in the prolog of all bedrock processes?

################################################################################################# 
##~~Join the bedrock TM1 community on GitHub https://github.com/cubewise-code/bedrock Ver 4.0~~##
#################################################################################################

Currently however AFAIK the version portion of the header isn't updated with each release. It's frozen at 4.0. But this would be the minimum version.