Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lower employment income by 10% #1

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/review_pull_request.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pandas as pd
from policyengine_us_data.data_storage import STORAGE_FOLDER
from IPython.display import Markdown
from policyengine_us_data.utils.github import set_pr_auto_review_comment

def main():
df = pd.read_csv(STORAGE_FOLDER / "evaluation.csv")
Expand All @@ -11,11 +11,15 @@ def main():
diff = (most_recent_rows - second_most_recent_rows)
# Convert to df
diff = diff.reset_index()
diff.Total = diff.Total.apply(lambda x: f"{x:+.1f}")
diff = diff[diff.Variable == "household_net_income"].set_index("Time period")[["Total"]].T
table = diff.to_markdown(index=False)

review_text = f"""## National projection changes\n\n{table}"""
review_text = f"""## National projection changes\n\nThis pull request makes the following changes to economic estimates.\n\n### Household net income\n\n{table}"""

print(review_text)

set_pr_auto_review_comment(review_text)

if __name__ == "__main__":
main()
1 change: 0 additions & 1 deletion .github/upload_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from policyengine_us_data.data_storage import STORAGE_FOLDER

if __name__ == "__main__":
main()
upload(
"policyengine",
"policyengine-us-data",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR_NUMBER: ${{ github.event.number }}

steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion policyengine_us_data/datasets/cps/policyengine_cps.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def add_personal_income_variables(
assert isinstance(p, dict)

# Assign CPS variables.
cps["employment_income"] = person.WSAL_VAL
cps["employment_income"] = person.WSAL_VAL * 0.9

cps["weekly_hours_worked"] = person.HRSWK * person.WKSWORK / 52

Expand Down
21 changes: 21 additions & 0 deletions policyengine_us_data/utils/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,24 @@ def upload(
)

return response.json()

def set_pr_auto_review_comment(text: str):
# On a pull request, set a review comment with the given text.

pr_number = os.environ["GITHUB_PR_NUMBER"]

url = f"https://api.github.com/repos/{os.environ['GITHUB_REPOSITORY']}/pulls/{pr_number}/reviews"

response = requests.post(
url,
headers=auth_headers,
json={
"body": text,
"event": "COMMENT",
},
)

if response.status_code != 200:
raise ValueError(
f"Invalid response code {response.status_code} for url {url}. Received: {response.text}"
)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"tqdm",
"requests",
"policyengine_us",
"tabulate",
],
},
)
Loading