Transforms on several materialised datasets

i’ve currently got a calculation job object that materialises and kicks off a transform. The transform depends on other materialized datasets which may or may not be built-in time when the transform is called… how can i get around this ‘race condition’ problem?

Which kind of materialization do you mean? An object-edits materialized dataset and a normal transform output behave differently here.

Either way, I wouldn’t kick the transform off directly. Put it on a schedule instead:

  • Use an event trigger on each upstream dataset, joined with AND, so it only runs once all of them have updated.
  • Or include the upstream datasets in the same schedule, so Foundry builds them in order first.

If it has to start from the action, use the “trigger schedule build” rule. The action doesn’t wait for the build, so the ordering has to come from the schedule. You can also write the schedule run RID to a property on your calculation job object to see whether it finished.

@mdc curious if the AND trigger on the upstream datasets sorted out the race condition, or did you go with putting the upstreams in the same schedule? let me know if it’s still building out of order

Hey @sriniN ,

So, for context this is a Financial ‘Calculator’ that performs many different calculations/formulas with various different inputs, that gets updated at different times.

Therefore, wrapping into AND conditions would not be feasible.

What I ended up architecting was a “Job Request” object that has a function-backed Action which is responsible for resolving the relevant inputs for a formula and then using the Ontology API to get the last updated timestamp, and putting in one of the object’s property.

Then, inside of my transform, I check the relevant materialised datasets of my inputs against my dataset registry and checks that the last updated time was greater than or equal to the last update time marked on my Job Request object.

This seems to have done the trick for me.

@mdc nice, that’s a clean way to handle inputs on different cadences. one thing I’d check - what happens when the timestamp check fails? I’d make the transform fail loudly rather than skip or write stale results, otherwise the job looks green but the numbers are old. also worth deciding who re-triggers it once the input lands. maybe mark your post as the solution too so others find the pattern

Can the calculation be done in the Ontology layer instead?

Hey @jason2

The # of calculation output(s) was greater than 10k (c. 3m+) and so doing this at the Ontology layer was going to be difficult.

And, thanks for your help on this @sriniN , I agree there’s the need for this to fail loudly. We have a sequential dataset that runs after the main calculation results are computed, which certifies whether the job request has failed or succeeded.