Skip to content

Commit

Permalink
Merge pull request #2009 from PolicyEngine/feat/1986-enable-state-ecps
Browse files Browse the repository at this point in the history
Enable state ECPS runs
  • Loading branch information
anth-volk authored Nov 27, 2024
2 parents 7deec7f + 9c7cfa6 commit 1b11eea
Show file tree
Hide file tree
Showing 32 changed files with 321 additions and 39,215 deletions.
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: minor
changes:
added:
- dataset descriptor to various endpoints and controllers enabling enhanced CPS runs for any specified region
25 changes: 25 additions & 0 deletions policyengine_api/country.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,15 @@ def build_microsimulation_options(self) -> dict:
dict(name=2028, label="2028"),
dict(name=2029, label="2029"),
]
datasets = [{}]
options["region"] = region
options["time_period"] = time_period
options["datasets"] = datasets
elif self.country_id == "us":
region = [
dict(name="us", label="the US"),
# enhanced_us is a legacy option maintained for users
# accessing via an outdated URL
dict(name="enhanced_us", label="the US (enhanced CPS)"),
dict(name="al", label="Alabama"),
dict(name="ak", label="Alaska"),
Expand Down Expand Up @@ -157,35 +161,56 @@ def build_microsimulation_options(self) -> dict:
dict(name=2023, label="2023"),
dict(name=2022, label="2022"),
]
datasets = [
dict(
name="cps",
label="CPS",
title="Current Population Survey",
default=True,
),
dict(
name="enhanced_cps",
label="enhanced CPS",
title="Enhanced Current Population Survey",
default=False,
),
]
options["region"] = region
options["time_period"] = time_period
options["datasets"] = datasets
elif self.country_id == "ca":
region = [
dict(name="ca", label="Canada"),
]
time_period = [
dict(name=2023, label="2023"),
]
datasets = [{}]
options["region"] = region
options["time_period"] = time_period
options["datasets"] = datasets
elif self.country_id == "ng":
region = [
dict(name="ng", label="Nigeria"),
]
time_period = [
dict(name=2023, label="2023"),
]
datasets = [{}]
options["region"] = region
options["time_period"] = time_period
options["datasets"] = datasets
elif self.country_id == "il":
region = [
dict(name="il", label="Israel"),
]
time_period = [
dict(name=2023, label="2023"),
]
datasets = [{}]
options["region"] = region
options["time_period"] = time_period
options["datasets"] = datasets
return options

def build_variables(self) -> dict:
Expand Down
4 changes: 4 additions & 0 deletions policyengine_api/data/initialise.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CREATE TABLE IF NOT EXISTS reform_impact (
reform_policy_id INT NOT NULL,
country_id VARCHAR(3) NOT NULL,
region VARCHAR(32) NOT NULL,
dataset VARCHAR(255) NOT NULL,
time_period VARCHAR(32) NOT NULL,
options_json JSON,
options_hash VARCHAR(255),
Expand All @@ -64,6 +65,8 @@ CREATE TABLE IF NOT EXISTS analysis (
status VARCHAR(32) NOT NULL
)

-- The dataset row below was added while the table is in prod;
-- we must allow NULL values for this column
CREATE TABLE IF NOT EXISTS user_policies (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
country_id VARCHAR(3) NOT NULL,
Expand All @@ -74,6 +77,7 @@ CREATE TABLE IF NOT EXISTS user_policies (
user_id VARCHAR(255) NOT NULL,
year VARCHAR(32) NOT NULL,
geography VARCHAR(255) NOT NULL,
dataset VARCHAR(255),
number_of_provisions INTEGER NOT NULL,
api_version VARCHAR(32) NOT NULL,
added_date BIGINT NOT NULL,
Expand Down
4 changes: 4 additions & 0 deletions policyengine_api/data/initialise_local.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ CREATE TABLE IF NOT EXISTS reform_impact (
reform_policy_id INT NOT NULL,
country_id VARCHAR(3) NOT NULL,
region VARCHAR(32) NOT NULL,
dataset VARCHAR(255) NOT NULL,
time_period VARCHAR(32) NOT NULL,
options_json JSON NOT NULL,
options_hash VARCHAR(255) NOT NULL,
Expand All @@ -73,6 +74,8 @@ CREATE TABLE IF NOT EXISTS analysis (
status VARCHAR(32) NOT NULL
);

-- The dataset row below was added while the table is in prod;
-- we must allow NULL values for this column
CREATE TABLE IF NOT EXISTS user_policies (
id INTEGER PRIMARY KEY,
country_id VARCHAR(3) NOT NULL,
Expand All @@ -83,6 +86,7 @@ CREATE TABLE IF NOT EXISTS user_policies (
user_id VARCHAR(255) NOT NULL,
year VARCHAR(32) NOT NULL,
geography VARCHAR(255) NOT NULL,
dataset VARCHAR(255),
number_of_provisions INTEGER NOT NULL,
api_version VARCHAR(32) NOT NULL,
added_date BIGINT NOT NULL,
Expand Down
Loading

0 comments on commit 1b11eea

Please sign in to comment.