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

Fix various AI endpoint issues #2006

Merged
merged 14 commits into from
Nov 25, 2024
Merged
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: 8 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- bump: minor
changes:
changed:
- Refactored AI endpoints to match new routes/services/jobs architecture
- Disabled default buffering on App Engine deployments for AI endpoints
- Updated relevant tests
added:
- Testing for simulation payload validators
5 changes: 0 additions & 5 deletions policyengine_api/ai_prompts/__init__.py

This file was deleted.

128 changes: 0 additions & 128 deletions policyengine_api/ai_prompts/simulation.py

This file was deleted.

16 changes: 0 additions & 16 deletions policyengine_api/ai_prompts/tracer.py

This file was deleted.

16 changes: 10 additions & 6 deletions policyengine_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

# Endpoints
from policyengine_api.routes.economy_routes import economy_bp
from policyengine_api.routes.simulation_analysis_routes import (
simulation_analysis_bp,
)
from policyengine_api.routes.tracer_analysis_routes import tracer_analysis_bp
from .endpoints import (
get_home,
get_metadata,
Expand All @@ -25,15 +29,13 @@
get_policy_search,
get_household_under_policy,
get_calculate,
execute_simulation_analysis,
set_user_policy,
get_user_policy,
update_user_policy,
set_user_profile,
get_user_profile,
update_user_profile,
get_simulations,
execute_tracer_analysis,
)

print("Initialising API...")
Expand Down Expand Up @@ -90,10 +92,12 @@
)
)

# Routes for economy microsimulation
app.register_blueprint(economy_bp, url_prefix="/<country_id>/economy")

app.route("/<country_id>/simulation-analysis", methods=["POST"])(
execute_simulation_analysis
# Routes for AI analysis of economy microsim runs
app.register_blueprint(
simulation_analysis_bp, url_prefix="/<country_id>/simulation-analysis"
)

app.route("/<country_id>/user-policy", methods=["POST"])(set_user_policy)
Expand All @@ -112,8 +116,8 @@

app.route("/simulations", methods=["GET"])(get_simulations)

app.route("/<country_id>/tracer-analysis", methods=["POST"])(
execute_tracer_analysis
app.register_blueprint(
tracer_analysis_bp, url_prefix="/<country_id>/tracer-analysis"
)


Expand Down
4 changes: 0 additions & 4 deletions policyengine_api/endpoints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@
update_user_policy,
)

# from .economy import get_economic_impact
from .simulation_analysis import execute_simulation_analysis

from .user_profile import (
set_user_profile,
get_user_profile,
update_user_profile,
)
from .simulation import get_simulations
from .tracer_analysis import execute_tracer_analysis
2 changes: 1 addition & 1 deletion policyengine_api/endpoints/household.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import json
import logging
from datetime import date
from policyengine_api.helpers import validate_country
from policyengine_api.utils.payload_validators import validate_country


def add_yearly_variables(household, country_id):
Expand Down
2 changes: 1 addition & 1 deletion policyengine_api/endpoints/metadata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from policyengine_api.helpers import validate_country
from policyengine_api.utils.payload_validators import validate_country
from policyengine_api.country import COUNTRIES


Expand Down
2 changes: 1 addition & 1 deletion policyengine_api/endpoints/policy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from policyengine_api.helpers import validate_country
from policyengine_api.utils.payload_validators import validate_country
from policyengine_api.data import database
from policyengine_api.utils import hash_object
from policyengine_api.constants import COUNTRY_PACKAGE_VERSIONS
Expand Down
68 changes: 0 additions & 68 deletions policyengine_api/endpoints/simulation_analysis.py

This file was deleted.

Loading
Loading