You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -54,14 +55,22 @@ class SimulationOptions(BaseModel):
54
55
None,
55
56
description="How many, if a subsample, households to randomly simulate.",
56
57
)
57
-
title: str|None=Field(
58
+
title: Optional[str]=Field(
58
59
"[Analysis title]",
59
60
description="The title of the analysis (for charts). If not provided, a default title will be generated.",
60
61
)
61
-
include_cliffs: bool|None=Field(
62
+
include_cliffs: Optional[bool]=Field(
62
63
False,
63
64
description="Whether to include tax-benefit cliffs in the simulation analyses. If True, cliffs will be included.",
64
65
)
66
+
model_version: Optional[str] =Field(
67
+
None,
68
+
description="The version of the country model used in the simulation. If not provided, the current package version will be used. If provided, this package will throw an error if the package version does not match. Use this as an extra safety check.",
69
+
)
70
+
data_version: Optional[str] =Field(
71
+
None,
72
+
description="The version of the data used in the simulation. If not provided, the current data version will be used. If provided, this package will throw an error if the data version does not match. Use this as an extra safety check.",
73
+
)
65
74
66
75
67
76
classSimulation:
@@ -73,12 +82,16 @@ class Simulation:
73
82
"""The baseline tax-benefit simulation."""
74
83
reform_simulation: CountrySimulation|None=None
75
84
"""The reform tax-benefit simulation."""
85
+
data_version: Optional[str] =None
86
+
"""The version of the data used in the simulation."""
Check the package versions of the simulation against the current package versions.
337
+
"""
338
+
ifself.options.model_versionisnotNone:
339
+
target_version=self.options.model_version
340
+
package=f"policyengine-{self.options.country}"
341
+
try:
342
+
installed_version=metadata.version(package)
343
+
self.model_version=installed_version
344
+
exceptmetadata.PackageNotFoundError:
345
+
raiseValueError(
346
+
f"Package {package} not found. Try running `pip install {package}`."
347
+
)
348
+
ifinstalled_version!=target_version:
349
+
raiseValueError(
350
+
f"Package {package} version {installed_version} does not match expected version {target_version}. Try running `pip install {package}=={target_version}`."
351
+
)
352
+
353
+
defcheck_data_version(self) ->None:
354
+
"""
355
+
Check the data versions of the simulation against the current data versions.
356
+
"""
357
+
ifself.options.data_versionisnotNone:
358
+
ifself.data_version!=self.options.data_version:
359
+
raiseValueError(
360
+
f"Data version {self.data_version} does not match expected version {self.options.data_version}."
0 commit comments