Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Add the simulation job store and background result collection without leases

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

维护者通常 1 天内回复

@anth-volk 已经在做这个了。

开始于 2026年10月19日。

  • #848 来自 @anth-volk —— 未关闭

评估

难度
5/5
预计耗时
一周以上
新手友好度
20/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
停滞
技术栈
github-actions, google-cloud, postgresql, python

调研方向

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 CONFLICT on the input hash, so identical requests share one job.
  • A conditional pending -> dispatching update before the Modal spawn, 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_results for results that are not reports (report results go to simulation.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_QUEUE and RECONCILIATION_INVOKER_SERVICE_ACCOUNT variables in this repository's beta and prod GitHub environments.
主要语言
Python
星标
1
派生
1
平均合并
1 天 16 小时
30 天内合并 PR
53

环境准备

从这里开始

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

PolicyEngine/policyengine-sim-api 的其他 Issue

查看 PolicyEngine/policyengine-sim-api 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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