You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As suggested by @MariusWirtz it would be good to have a function that returns the ordered hierarchy names for a dimension. I think that the suggestion is to also physically change the ordering of the hierarchies, while my use case would return (just) the ordered hierarchy names as strings in a list.
My current coding for the DimensionService.py file:
Line 15: from TM1py.Utils.Utils import case_and_space_insensitive_equals, format_url, CaseAndSpaceInsensitiveSet, reorder_with_priority
A new function:
def get_reordered_hierarchy_names(self, dimension_name: str, exclude_leaves_hierarchy: bool = False) -> List[str]:
"""
Utility function, for instance, when migration dimensions from source to target.
Given a dimension name, return its hierarchy names.
First the same-named hierarchy, then the other hierarchy names (sorted alphabetically). The Leaves hierarchy can be skipped or not.
:return: List of Hierarchy names
"""
return reorder_with_priority(
original_items = self.hierarchies.get_all_names(dimension_name),
priority_items = [dimension_name],
exclude_items = ["Leaves"] if exclude_leaves_hierarchy else None,
sort_remaining = True
)
What do you think? The main use case is migrating dimensions in a specified order, making also sure that we do not try to create the Leaves hierarchy. The purpose (for me) is not to update the dimension object itself.
Also, I am having PC issues at the moment with the Python interpreter and Python/TM1py versions, so testing is not easy (the new function is not recognized in my main script). If happy with this code proposal, can I create the PR as such?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
As suggested by @MariusWirtz it would be good to have a function that returns the ordered hierarchy names for a dimension. I think that the suggestion is to also physically change the ordering of the hierarchies, while my use case would return (just) the ordered hierarchy names as strings in a list.
My current coding for the DimensionService.py file:
Line 15: from TM1py.Utils.Utils import case_and_space_insensitive_equals, format_url, CaseAndSpaceInsensitiveSet, reorder_with_priority
A new function:
def get_reordered_hierarchy_names(self, dimension_name: str, exclude_leaves_hierarchy: bool = False) -> List[str]:
"""
Utility function, for instance, when migration dimensions from source to target.
Given a dimension name, return its hierarchy names.
First the same-named hierarchy, then the other hierarchy names (sorted alphabetically). The Leaves hierarchy can be skipped or not.
What do you think? The main use case is migrating dimensions in a specified order, making also sure that we do not try to create the Leaves hierarchy. The purpose (for me) is not to update the dimension object itself.
Also, I am having PC issues at the moment with the Python interpreter and Python/TM1py versions, so testing is not easy (the new function is not recognized in my main script). If happy with this code proposal, can I create the PR as such?
Best regards,
Wim
Beta Was this translation helpful? Give feedback.
All reactions