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

Load data into Vercel using GitHub Actions #161

Merged
merged 11 commits into from
Jan 21, 2025
Merged

Conversation

agennadi
Copy link
Collaborator

Description

  • A GItHub Actions workflow that populates Tsunami, Soft Story, and Liquefaction tables is created.
  • The workflow runs on a schedule and can also be triggered manually.
  • The Vercel's database is populated with the Soft-Story Properties, Tsunami, and Liquefaction datasets
  • A UNIQUE constraint in the Soft Story table was added and the ETL scripts were modified to avoid duplicates in the database.
  • Multipolygons in the Liquefaction table are simplified using PostGIS ST_Simplify with the tolerance level of 0.0001

Closes #150, addresses but doesn't close #154

Type of changes

  • Bugfix
  • Chore
  • New Feature

Testing

  • I added automated tests
  • I think tests are unnecessary

How to test

Manually trigger the ETL to Neon workflow.

Copy link

vercel bot commented Jan 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
datasci-earthquake ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 21, 2025 5:27am

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While in development, the workflow is only triggered once a week - to save on data transfer costs. The free limit of data transfer is 5 GB/month.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a neon or Github Actions limit? Just curious.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a neon limit

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got a mypy error: Incompatible types in assignment (expression has type "dict[str, tuple[float, float] | None]", variable has type "dict[str, tuple[float, float]]"). Wasn't sure if I can safely change the type, so temporarily silenced the warning.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duplicate check relied on the auto increment PK, which prevented duplicates from being detected. Replaced the autoincrement key with a composite PK

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a UNIQUE constraint to the Property_address field, so that it can be used to prevent duplicates in the Soft_story_properties table.

Copy link
Collaborator

@elucherini elucherini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one concern, everything else looks good. I will take a look at the mapbox geojson manager type error at a later point.

@@ -3,7 +3,7 @@
from backend.api.config import settings

# Set up the database engine using settings
engine = create_engine(settings.database_url_sqlalchemy, echo=True)
engine = create_engine(settings.neon_url, echo=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there consequences to changing this script to connect to the Neon DB as opposed to the local DB? As in, if I want to test my local DB, do I need to change this line back to connect to database_url_sqlalchemy?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you'd have to change this line back to test locally. If this is a problem, I can add an if-clause that would switch the url based on the environment

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I think it’s fine for now. I would probably prefer putting more data in the test DB.

@agennadi agennadi merged commit ec59e65 into master Jan 21, 2025
5 checks passed
@agennadi agennadi deleted the add_etl_workflow branch January 21, 2025 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimize Handling of Large Multipolygons Project account: Load tables into Vercel and create ETL pipeline
2 participants