Batched workitems in inProcess cook

   1823   4   0
User Avatar
Member
209 posts
Joined: Nov. 2010
Offline
Is there any way to properly run batched workitem with inProcess cook?

It gives me this warning:
Batch work item 'pythonprocessor1_10' was marked as cooked before all of its sub items were cooked. This likely indicates an issue with the work item's node or scheduler configuration.

Is there anything that I'm doing wrong?
for upstream_item in range(2):
    new_item = item_holder.addWorkItem(inProcess=True,
                                        batch=True,
                                        batchSize=2)

Attachments:
batched_inprocess.hipnc (42.0 KB)

User Avatar
Staff
585 posts
Joined: May 2014
Offline
The reason for that warning message is that the batch itself is done cooking, but none of the items in the batch reported a status back to PDG. When that happens PDG assumes that all of the items have the same status as the batch itself. The warning exists because typically that occurs when there's a problem with the way the scheduler is handling batch work items.

Normally, the notification for starting and stopping a batch comes from RPC calls from a job running out of process. When running in-process it's not possible to use that same mechanism. To partially fix that, I've exposed two new API methods that will be available in the next daily build (H18.5.492) which can be used instead. Both methods can only be called on in-process batch sub items, or they'll throw an exception.

pdg.WorkItem.startSubItem(wait=True)

This method will ensure that the dependencies for the sub item are cooked, and will put the item into the cooking state. The wait argument is needed because a batch can be created with the pdg.batchActivation.First activation mode, which will start cooking the batch as soon as the first sub item's dependencies are ready. The batch is then responsible for waiting for the dependencies on subsequent items.

pdg.WorkItem.cookSubItem(state, duration=0)

Marks a batch sub item as completed with the specified state.


Here is an example of an in-process batch cook implementation that could be used in a Python Processor's onCookTask callback:

import time

for sub_item in work_item.batchItems:
    sub_item.startSubItem(True)
    time.sleep(1) # Process the batch sub item -- in this example, just sleep
    sub_item.cookSubItem(pdg.workItemState.CookedSuccess)

Additional, here's an example .gif of that cooking -- note that the UI will correctly display the batch sub items as cooking after calling startSubItem, and downstream dependencies can begin processing after calling cookSubItem.

Attachments:
batch_api.gif (49.1 KB)

User Avatar
Member
209 posts
Joined: Nov. 2010
Offline
That is wonderful!

Looking to try the new build: H18.5.492
But is there any chance to have backported it to H18.0 (all features relevant to inProcess Batch Workitems)?
User Avatar
Staff
585 posts
Joined: May 2014
Offline
We can take a look at doing that, but due to internal changes between 18.0 and 18.5 some of the in process batch improvements may be difficult to backport to 18.0. I'll try to get the ones mentioned in this forum thread backported by the end of this week. Are there any other changes from different threads or RFEs that you think should also be backported to 18.0?
User Avatar
Member
209 posts
Joined: Nov. 2010
Offline
It can help definitely to make a smoother transition to H18.5

Now can't even remember what else from important can be backported to H18.0

Thank you!
  • Quick Links