Skip to content

Create household reports through POST /reports and calculate them in one household function call #1055

Open

Description

@anth-volk

The detailed-save API's household reports need the Simulation Entrypoint to create household simulations and household reports in the Public API's run tables, and the household functions to calculate them and write each simulation run's household_result. The Public API's /v2/reports will create household reports through this route.

Needed:

  • POST /reports takes a household report, told apart from an economy report by report_type: "household": a stored household, the baseline's stored policy and, optionally, the reform's (none for a report of the baseline alone), and add_missing_variables. The report is for the household's default_year. Refused fields are located as an economy report's are, without the type.
  • The service checks every row the request names before writing, then creates, in one transaction, a household simulation and a pending simulation run for each side, the report (type household, its options in inputs) and its pending report run.
  • It starts one household function call for the report run, passing the report run's ID and each side's household calculation request, whose calculation ID is the side's simulation run. It records the call's ID on the report run, or fails the report run and its simulation runs at once when Modal refuses the call or doesn't confirm it in time.
  • The household function claims the report run and each simulation run under its own Modal call ID. It writes each run's result or failure document to simulation_runs.household_result, then marks the report run succeeded, or failed with the failed side's summary. A restarted call keeps the sides it already recorded, and the stuck-run sweep covers these runs as it covers report runs.
  • The answers are an economy report's, plus unknown_household and no_household_function (400) and household_not_calculable (422).

Stacks on #1052, which adds POST /reports for economy reports.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions