Update Utils.py
Add a short function to sort lists of names like hierarchy names. Example use case for a dimnesion called Product. Retrieve the hierarchy names with: hiers = tm1.hierarchies.get_all_names('Product')
Then use: print(reorder_with_priority(items=hiers, priority=['Product', 'Leaves'])
Obviously 'Product' will typically be a variable and not hardcoded in the 2 lines of code.
Hello, After that the review and when the merge is done, I will do a second pull request. Since using the function, I added 1 more argument (an exclude_list) which proves useful too. Apologies for the double work.
Thanks @wimgielis
Please add a few test cases here: https://github.com/cubewise-code/tm1py/blob/master/Tests/Utils_test.py
Then we can merge.
Hello Marius,
I can do that. However, what is the specific context? I need 1 dimension and a few extra hierarchies in the dimension. Do I need to set up that code too or can I assume, when the test is run, that some dimensions and hierarchies exist (by name) ?
Best regards / Beste groeten,
Wim Gielis IBM Champion 2024-2025 MS Excel MVP 2011-2014 https://www.wimgielis.com http://www.wimgielis.be
Op wo 25 jun 2025 om 17:12 schreef Marius Wirtz @.***>:
MariusWirtz left a comment (cubewise-code/tm1py#1245) https://github.com/cubewise-code/tm1py/pull/1245#issuecomment-3005153677
Thanks @wimgielis https://github.com/wimgielis
Please add a few test cases here: https://github.com/cubewise-code/tm1py/blob/master/Tests/Utils_test.py
Then we can merge.
— Reply to this email directly, view it on GitHub https://github.com/cubewise-code/tm1py/pull/1245#issuecomment-3005153677, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDHULJYVACJJACCIJBIWBL3FK34NAVCNFSM6AAAAAB73FU3SKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAMBVGE2TGNRXG4 . You are receiving this because you were mentioned.Message ID: @.***>
@wimgielis,
you don't need to create assets in TM1 to run the test case I think.
The test function could be self-contained. You can call the function with a defined set of parameters and then do an assert statement to compare it with the expected outcome.
You can use this test case as an example: https://github.com/cubewise-code/tm1py/blob/cef4ae3c17ff3e896cbb808edf28d48bd05ccee0/Tests/Utils_test.py#L492C9-L492C62