-
Notifications
You must be signed in to change notification settings - Fork 5
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
(chore) cost surface data migration script #1501
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
min_val, max_val = min_max if min_max else (None, None) | ||
|
||
# If min and max are null, remove scenario and cost_surface from api_db | ||
if min_val is None or max_val is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please give extra love to this part
INNER JOIN planning_units_geom pug ON pug.id = ppu.geom_id | ||
WHERE ppu.project_id = '{project_id}'; | ||
""") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: insert for each scenario in apiDB
print(len(all_projects), "projects") | ||
except Exception as e: | ||
print(e) | ||
cur_api_db.execute("ROLLBACK;") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: All ops in one single transaction: one commit, one rollback
closing as we included this, with some tweaks, in #1494 |
Script for handling the data migration for existing projects and scenarios.
NOTE: Since this will be run most likely from NOT the host, I haven't add any requirements.txt.
Overview
API:
For each scenario, create a cost surface within the project, and set it as the scenarios cost surface. We use the scenario name as cost surface name
For each project, create a new cost surface using 'Default' as name, and set it as default cost surface for the project.
GEO & API
for each scenario in api, get its cost surface and compute min and max from scenario_pu_cost_data.
update api.cost_surface with said min,max
for each project, get its default cost surface and insert it's default cost in cost_surface_pu_data
update the the api.cost_surface computing the min and max from the new cost
Error handling
There might be scenarios in API that has no cost in GEO. I have assumed this should not happen, so I am deleting the scenario and its cost_surface in API
I don't know if the same could happen for projects
Testing instructions
Basically the above should happen
Feature relevant tickets
Link to the related task manager tickets
Checklist before submitting
develop
.deploying to staging/production, please add brief testing instructions
to the deploy checklist (
docs/deployment-checklist.md
)