Skip to content

Simulation's data input option accepts arbitrary dictionaries #156

@anth-volk

Description

@anth-volk

Based on the documentation here, The Simulation initializer's data arg accepts an arbitrary dictionary as an input, but will only work if this dictionary is a properly-configured household object. This dictionary (it appears) is only used if the simulation type is household-level, while a macro-typed sim expects a str | policyengine_core.Dataset | None-type.

This introduces quite a few drawbacks:

  1. If data can be str | Dataset | dict[Any, Any] | None, that's basically every type; we start to lose the advantages of applying typing
  2. data must be handled by both the household and macro calculation processes, meaning both will need to evaluate the existence of any of these types
  3. Passing an arbitrary dict will mean we either need manual validation on the household calculation side, or we will create strange breakage patterns for users unacquainted with the schema
  4. The datasets we use are, under the hood, merely an array of households. Let's say we allowed the passage of custom subsets of households for calculation purposes. Because we've tied ourselves to a dict, this would require schema migration. I think it'd be better if we just started out using a list[dict] structure and just confirmed for the time being that these are just single-entry lists.

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