appengine-pipelines icon indicating copy to clipboard operation
appengine-pipelines copied to clipboard

Create promise from handle

Open billy1380 opened this issue 10 years ago • 5 comments

I have a generator task that creates a promise then spawns further generator tasks that rely on the same promise but there is no way to share that promised value with the child jobs. I cannot pass it as a job parameter because that will cause the children to wait for the promise.

I cannot also pass the promise and hold onto it when the child jobs are created because promised values are not serialisable.

Ideally I would like to be able to pass the child jobs a handle to the promise and then be able to convert that handle into a PromisedValue when I need it.

billy1380 avatar Jan 30 '15 15:01 billy1380

I am not sure I explained myself very well so I have submitted a pull request ( #14 )... I suspect it is not correct for merging... but something along those lines

billy1380 avatar Jan 30 '15 20:01 billy1380

+1

although I'm not entirely clear why you don't want the child jobs to wait on the PromisedValue, if indeed they need its value at some point. But I have a similar need to be able to create a PromiseValue from a handle.

Specifically, I'm pulling in a bunch of data from a 3rd party API using a single fetch job. I have other calculation jobs that depend on that data. I want to start the fetch as soon as my user does the OAuth grant giving my app access, as it potentially takes a while. But I don't yet know the exact data ranges that user will want for the calculation, so the fetch job can't trigger the calculation jobs. Hence I want to start the fetch job, get a PromisedValue for its completion, store its handle somewhere, and then use that handle to make my calculation jobs wait until the data fetch is complete before they actually run (or run immediately if it is indeed complete when they're created).

Alternatively, creating a FutureValue from a JobInfo instance (retrieved using a job handle) could also meet my need. But JobInfo.getOutput() provides a value (an Object) only after the job is complete - not a Value<T> that you could use as an input slot to another job.

eschultink avatar May 07 '15 19:05 eschultink

I need to sort out a bunch of comments and some unit tests for this to go forward, there are no technical obstacles to the changes. I will try to get it done by Monday 11th May 2015.

billy1380 avatar May 07 '15 22:05 billy1380

@billy1380 great, waiting to see your updates.

@eschultink why don't you start the calculation job with and make it depends on a PromisedValue X. pass the X's handle to your fetch job and fill the promised value once fetch is completed (you can have more than X promised values to store the ranges that you need for the calculation.

aozarov avatar May 07 '15 23:05 aozarov

@aozarov Updates are now in, thanks for the patience.

billy1380 avatar May 09 '15 14:05 billy1380