"On demand" formulas

未关闭
#207 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@jqnatividad 已经在做这个了。

开始于 2025年5月29日。

评估

这个 Issue 还没有评估数据。

描述

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

主要语言
Python
星标
47
派生
33
平均合并
2 小时 28 分钟
30 天内合并 PR
10

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

dathere/datapusher-plus 的其他 Issue

查看 dathere/datapusher-plus 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。