Skip to content

Commit

Permalink
Add 'test lite' mode to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilwoodruff committed Sep 17, 2024
1 parent d98f649 commit 7e7e707
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/ci_cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
POLICYENGINE_US_DATA_GITHUB_TOKEN: ${{ secrets.POLICYENGINE_US_DATA_GITHUB_TOKEN }}
- name: Build datasets
run: make data
env:
TEST_LITE: true
- name: Run tests
run: pytest
- name: Test documentation builds
Expand Down
3 changes: 2 additions & 1 deletion policyengine_us_data/datasets/cps/enhanced_cps.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
CPS_2024,
)
import torch
import os


def reweight(
Expand Down Expand Up @@ -51,7 +52,7 @@ def loss(weights):
optimizer = torch.optim.Adam([weights], lr=1e-2)
from tqdm import trange

iterator = trange(10_000)
iterator = trange(10_000) if not os.environ.get("TEST_LITE") else trange(100)
for i in iterator:
optimizer.zero_grad()
l, worst_name, worst_val = loss(torch.exp(weights))
Expand Down
4 changes: 4 additions & 0 deletions policyengine_us_data/datasets/cps/extended_cps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .cps import *
from ..puf import *
import pandas as pd
import os

# These are sorted by magnitude.
# First 15 contain 90%.
Expand Down Expand Up @@ -110,6 +111,9 @@ def generate(self):
data = cps_sim.dataset.load_dataset()
new_data = {}

if os.environ.get("TEST_LITE"):
IMPUTED_VARIABLES = IMPUTED_VARIABLES[:1]

for variable in list(data) + IMPUTED_VARIABLES:
variable_metadata = cps_sim.tax_benefit_system.variables.get(
variable
Expand Down

0 comments on commit 7e7e707

Please sign in to comment.