Skip to content

Commit

Permalink
Merge branch 'ru-tracts-minimal-deployment' of https://github.com/Bas…
Browse files Browse the repository at this point in the history
…isResearch/cities into ru-tracts-model
  • Loading branch information
rfl-urbaniak committed Oct 18, 2024
2 parents 33631a6 + 247902c commit f2a36fb
Show file tree
Hide file tree
Showing 12 changed files with 513 additions and 223 deletions.
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source venv/bin/activate
dotenv
export PASSWORD=VA.TlSR#Z%mu**Q9
2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3
FROM python:3.12

WORKDIR /usr/src/app

Expand Down
47 changes: 22 additions & 25 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,37 +197,34 @@ async def read_blue_zone(year: Year, radius: Radius, db=Depends(get_db)):
],
}


@app.get("/predict")
async def read_predict(
blue_zone_radius: Radius,
yellow_zone_line_radius: Radius,
yellow_zone_stop_radius: Radius,
blue_zone_limit: Limit,
yellow_zone_limit: Limit,
year: Year,
db=Depends(get_db),
predictor=Depends(get_predictor),
):
result = predictor.predict_cumulative(
blue_zone_radius: Radius,
yellow_zone_line_radius: Radius,
yellow_zone_stop_radius: Radius,
blue_zone_limit: Limit,
yellow_zone_limit: Limit,
year: Year,
db=Depends(get_db),
predictor=Depends(get_predictor),
):

result = predictor.predict_cumulative_by_year(
db,
intervention=(
{
"radius_blue": blue_zone_radius,
"limit_blue": blue_zone_limit,
"radius_yellow_line": yellow_zone_line_radius,
"radius_yellow_stop": yellow_zone_stop_radius,
"limit_yellow": yellow_zone_limit,
"reform_year": year,
}
),
intervention={
"radius_blue": blue_zone_radius,
"limit_blue": blue_zone_limit,
"radius_yellow_line": yellow_zone_line_radius,
"radius_yellow_stop": yellow_zone_stop_radius,
"limit_yellow": yellow_zone_limit,
"reform_year": year,
},
)
return {
"census_tracts": [str(t) for t in result["census_tracts"]],
"housing_units_factual": [t.item() for t in result["housing_units_factual"]],
"housing_units_counterfactual": [
t.tolist() for t in result["housing_units_counterfactual"]
],
"years": result["years"],
"housing_units_factual": result["housing_units_factual"],
"housing_units_counterfactual": result["housing_units_counterfactual"],
}


Expand Down
Loading

0 comments on commit f2a36fb

Please sign in to comment.