Foundry writebacks - is it possible to restore an edited record to it's unedited version (BaseVersion)

274 Views Asked by At

Palantir-Foundry - We have a workflow that needs updates from the backing dataset of an object with a writeback to persist in the writeback, but this fails on rows that have previously been edited. Due to the "Edits-win" model the writeback it will always choose the edited version of the row, which makes sense. Short of re-architecting the entire app, I am looking into ways to take care of this by using the Foundry REST API.

Is it possible to revert an edited row in Foundry writebacks to the original unedited version? I found some API documentation in our instance for phonograph2 BaseVersion, but I have not been able to find/understand anything that would restore a row to BaseVersion. I would need to be able to do this from a functions repository using typescript, on certain events.

1

There are 1 best solutions below

1
On

One way to overwrite the edits with the values from a backing datasets is to build a transform off of the backing dataset that makes a new, identical dataset. Then you can use the new dataset as backing dataset for a new object.

Transform using a simple code repo:

from transforms.api import transform_df, Input, Output

@transform_df(
    Output(".../static_guests"),
    source_df=Input("<backing dataset RID>"),
)
def compute(source_df):
    return source_df 

You can then build up the ontology of a static object that will always equal the writeback dataset.

Data Lineage graph showing how components fit

Then create an action that will modify your edited object (in my example that is Test Guest) by reverting a value to equal a value in the static object type.

enter image description here

You can then use the Apply Action API to automatically apply this action to certain values on a schedule or based on a certain condition. Documentation for the API is here.