Add the simulation job store and background result collection without leases
维护者通常 1 天内回复
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 20/100
调研方向
The issue specifies the simulation.jobs and simulation.job_results tables, collection and sweep routes, and concurrency tests, but names no source files or test paths. Start by locating the API's database models, route registration, and test conventions, then trace how Modal calls and Cloud Tasks are handled. Done means jobs can be submitted idempotently, results collected safely without leases, status read from the database, and the stated operator prerequisites are configured; linked PR #848 is already open.
由索引模型根据 Issue 内容生成。
描述
Context
Step 1 of the API v2 migration (item 1A-4, result collection option B) needs a durable record of every calculation the Simulation Entrypoint sends to Modal, and a way to store each finished result without relying on clients that poll. The migration plan's rules: client polling never advances work, and Modal applications get no database credentials.
Scope
simulation.jobs: one row per calculation, recording the submitter, an input hash that includes the policyengine.py bundle version, the Modal call ID, status, timings and any error.- Idempotent submission:
INSERT ... ON CONFLICTon the input hash, so identical requests share one job. - A conditional
pending->dispatchingupdate before the Modalspawn, so one Modal call starts per job. - An authenticated internal collection route that Cloud Tasks calls: it checks the Modal call without waiting, writes a finished result to Postgres with a conditional update (
... WHERE status = 'running') so a second collector changes nothing, and re-enqueues itself with backoff while the call runs. No Postgres leases. simulation.job_resultsfor results that are not reports (report results go tosimulation.report_results, added separately).- A sweep route that Cloud Scheduler calls, which enqueues a collection task for unfinished jobs not checked recently.
- Status reads that use only the database and accept either a job UUID or a Modal
fc-...call ID. - Tests showing the conditional writes are safe when two collectors run at once.
Nothing in production submits jobs yet; no job kind is registered until Step 2.
Operator prerequisites (both environments, before merge)
- Create the Cloud Tasks queue, its invoker service account and the IAM bindings (the Simulation Entrypoint runtime service accounts may create tasks and act as the invoker; the invoker may invoke the Cloud Run service).
- Create the Cloud Scheduler job that calls the sweep route with the invoker's OIDC token, audience set to the stable service URL.
- Confirm the Simulation Entrypoint's ingress setting accepts requests from Cloud Tasks and Cloud Scheduler.
- Set the
RECONCILIATION_QUEUEandRECONCILIATION_INVOKER_SERVICE_ACCOUNTvariables in this repository'sbetaandprodGitHub environments.
- 主要语言
- Python
- 星标
- 1
- 派生
- 1
- 平均合并
- 1 天 16 小时
- 30 天内合并 PR
- 53
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PolicyEngine/policyengine-sim-api 的其他 Issue
-
Update policyengine to 6.7.3可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 半天 新手友好度 70/100
PolicyEngine/policyengine-sim-api#823 ·
维护者通常 1 天内回复
-
Integration tests fail due to missing UV virtual environment setup可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
PolicyEngine/policyengine-sim-api#314 ·
维护者通常 1 天内回复
-
Add the simulation report tables (reports and report_results)可能已有人在做 @anth-volk 于 1 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
PolicyEngine/policyengine-sim-api#846 ·
维护者通常 1 天内回复
-
Add the Simulation Entrypoint's own Postgres schema, persistence library and migration chain可能已有人在做 @anth-volk 于 1 天前认领。 未关闭
难度 5/5 一周以上 新手友好度 15/100
PolicyEngine/policyengine-sim-api#844 ·
维护者通常 1 天内回复
-
v2 Modal household functions for every country in the PolicyEngine.py bundle可能已有人在做 @anth-volk 于 1 天前认领。 未关闭
难度 5/5 一周以上 新手友好度 20/100
PolicyEngine/policyengine-sim-api#840 ·
维护者通常 1 天内回复
查看 PolicyEngine/policyengine-sim-api 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
-
[Device Support Request] HOBEIAN ZG-204ZL (Tuya PIR motion sensor with illuminance)可能已有人在做 @lenucksi 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
zigpy/zha-device-handlers#5493 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
drevendev/BeautifulRepo#42 ·
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 84/100
writerslogic/holographic-memory#93 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
antoine-tena/kiln#47 ·
维护者通常 1 天内回复