Is there any way to delete multiple elements together?
This function deletes only one element at a time.
def delete(self, dimension_name: str, hierarchy_name: str, element_name: str, **kwargs) -> Response:
url = format_url(
"/api/v1/Dimensions('{}')/Hierarchies('{}')/Elements('{}')",
dimension_name,
hierarchy_name,
element_name)
return self._rest.DELETE(url, **kwargs)
Hi
Maybe this has been foreseen in tm1py, I don’t know, but you could also:
Best regards,
Wim
Op vr 25 jun. 2021 om 08:17 schreef pal-16 @.*>
Is there any way to delete multiple elements together?
This function deletes only one element at a time.
def delete(self, dimension_name: str, hierarchy_name: str, element_name:
str, *kwargs) -> Response:
url = format_url(
"/api/v1/Dimensions('{}')/Hierarchies('{}')/Elements('{}')",
dimension_name,
hierarchy_name,
element_name)
return self._rest.DELETE(url, *kwargs)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/cubewise-code/tm1py/issues/556, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AEDHULP265UEB5H7OEA6P2DTUQNQRANCNFSM47JHY2HA
.>
Best regards / Beste groeten,
Wim Gielis
MS Excel MVP 2011-2014
https://www.wimgielis.com http://www.wimgielis.be
@rkvinoth Yes, looping is a solution. Could you describe a few reasons why not use multi threading
It could create some IX locks and not sure how much performance gain you would see even if there are no locks.
The "default" way to delete multiple elements from a dimension/hierarchy is this:
from TM1py import TM1Service
with TM1Service(address="", port=12354, user="admin", password="apple", ssl=True) as tm1:
hierarchy = tm1.hierarchies.get(dimension_name="d1", hierarchy_name="d1")
hierarchy.remove_element(element_name="e1")
hierarchy.remove_element(element_name="e2")
hierarchy.remove_element(element_name="e3")
tm1.hierarchies.update(hierarchy)
The code retrieves the full hierarchy into python, manipulates it, and sends it back. The update (= deleting 1 or n elements) is one single operation.
Depending on the size of the hierarchy and the number of elements you want to delete, this can be faster or slower than calling the delete function on tm1.elements
If you want to delete one or two elements from a hierarchy with 1M elements you should probably use tm1.elements.delete.
In most cases, the above approach will be more appropriate.
@wimgielis made a good point as well. You could create a public subset with TM1py and use a Turbo Integrator process (perhaps bedrock or an unbound process) to delete the subset elements from the dimension/hierarchy.
@MariusWirtz Could we not create a function to delete multiple elements with the logic you just mentioned. Let me know if I can go ahead with it
@pal-16 I'm not sure I understand your question. All three approaches discussed above are perfectly valid.
Please evaluate which one is the most suitable for your situation and let us know your findings and reasons!
@pal-16 may I close this issue?
Yes sure