DP+ DRUF currently supports two formula types:
formula (aka "direct formulas")
the Jinja2 expression is evaluated at package creation/update and "directly" stored into the designated package/resource field.
suggestion_formula
the Jinja2 expression is evaluated at package creation/update, and is stored in the dpp_suggestions package field (as a JSON object). The dpp_suggestions package field is used to power the Bootstrap-powered Suggestion UI popover
We should create a third formula type - On demand, which is a variant of suggestion_formula.
It is indicated by a new scheming keyword - ondemand_formula.
As the name implies, an ondemand formula is calculated on demand, i.e. while entering metadata in CKAN.
When an ondemand_formula is used, the Suggestion UI will have an "Recalculate" button in addition to "Apply Suggestion" button.
To enable this, DP+ will have a new Action API endpoint - dpp_ondemand_formula:
def dpp_ondemand_formula(context, data_dict):
'''
Evaluate the on_demand formula for the given package/resource field
:param formula: the Jinja2 expression to evaluate.
:param track_invocation: track the formula/result pair with a timestamp (default: false)
'''
When the "Recalculate" button is pressed, the Suggestion UI calls the dpp_ondemand_formula API for the associated field.
Ondemand formulas will be initially used for AI-powered formulas - as they often need repeated invocations while entering metadata.
We offer the ability to "track_invocation", so the user can possibly use/consult previous invocations.
Eventually, ondemand formulas can be also used to have "formula presets", similar to scheming's "presets".
"Formula presets" are traditional jinja2 templates that can render a custom UI for an associated formula that may require additional form controls beyond the generic Suggestion UI (e.g. a field picker to select which fields to use in a formula during data entry).
cc @minhajuddin2510 @samibaig @wardi
DP+ DRUF currently supports two formula types:
formula(aka "direct formulas")the Jinja2 expression is evaluated at package creation/update and "directly" stored into the designated package/resource field.
suggestion_formulathe Jinja2 expression is evaluated at package creation/update, and is stored in the
dpp_suggestionspackage field (as a JSON object). Thedpp_suggestionspackage field is used to power the Bootstrap-powered Suggestion UI popoverWe should create a third formula type -
On demand, which is a variant ofsuggestion_formula.It is indicated by a new scheming keyword -
ondemand_formula.As the name implies, an
ondemandformula is calculated on demand, i.e. while entering metadata in CKAN.When an
ondemand_formulais used, the Suggestion UI will have an "Recalculate" button in addition to "Apply Suggestion" button.To enable this, DP+ will have a new Action API endpoint -
dpp_ondemand_formula:When the "Recalculate" button is pressed, the Suggestion UI calls the
dpp_ondemand_formulaAPI for the associated field.Ondemand formulas will be initially used for AI-powered formulas - as they often need repeated invocations while entering metadata.
We offer the ability to "track_invocation", so the user can possibly use/consult previous invocations.
Eventually, ondemand formulas can be also used to have "formula presets", similar to scheming's "presets".
"Formula presets" are traditional jinja2 templates that can render a custom UI for an associated formula that may require additional form controls beyond the generic Suggestion UI (e.g. a field picker to select which fields to use in a formula during data entry).
cc @minhajuddin2510 @samibaig @wardi