Make work item indices unique

   2077   3   1
User Avatar
Member
104 posts
Joined: Nov. 2007
Offline
Hello,

I have a merge in my network which means I end up with duplicate pdg_index values. What's the best way to make these unique again?
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
hi, this code in a python processor should do fine and manages to keep the original attribs, but you will lose the the dependencies, since you are creating brand new workitems:

i = 0
for w in upstream_items:
    newItem = item_holder.addWorkItem(index= i, cloneTarget=w)
    i += 1
Edited by Andr - July 10, 2019 08:59:55
User Avatar
Member
104 posts
Joined: Nov. 2007
Offline
Thanks Andr. I came up with another solution which is to use a python partitioner to create a partitions with one work item each. This produces a new index but keeps dependencies.

count = 0
for item in work_items:
    partition_holder.addItemToPartition(item, count)
    count += 1
Edited by lloydwood - July 10, 2019 09:33:53
User Avatar
Member
603 posts
Joined: Sept. 2016
Offline
You can also use the sort node if you have an attribute to sort by.
  • Quick Links