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

Add Hasura Events Views #1418

Merged
merged 4 commits into from
Apr 26, 2024
Merged

Add Hasura Events Views #1418

merged 4 commits into from
Apr 26, 2024

Conversation

Mythicaeda
Copy link
Contributor

@Mythicaeda Mythicaeda commented Apr 24, 2024

Description

Creates a SQL function to get the event logs for a specified Hasura event, and three views that select from this function, one for each of our Hasura events.

While the views could not be necessary had I actually created and tracked a custom table for the function return type in order to satisfy the Hasura Custom Function API (as is done with our other Hasura functions), by using views we can establish relationships between the results and the mission_model table, allowing for queries like so:

query {
  mission_model{
    id
    refresh_activity_type_logs { success }
    refresh_resource_type_logs { success }
    refresh_model_parameter_logs { success }
  }
}

Note that using a function for the view definitions is required, as the Hasura tables the views reference do not exist during database initialization (Hasura creates and manages them). View definitions must be executable at the time of creation, but functions do not have this restriction.

This PR also fixes some minor bugs in our Migrations pipeline. Specifically:

  • Fixed the PGCMP Workflow. Checking out develop requires re-cloning the PGCMP repo. The workflow was doing this pre-2.8.0, but I accidentally removed it when updating it for 2.8.0.
  • Fixed a bug in the migration script that was causing hasura to reapply migration 1 when bulk migrating down from version 1. This bug was introduced in 2.8.0.
  • Fixed a typo in the migration script preventing the "mark correct version" command from applying. The hasura command is case-sensitive. This bug was introduced in 2.8.0.

Verification

Manual verification was done to figure out the schema for errors and to check the Hasura metadata.

An E2E test was added to the MissionModelTests suite for testing the ability to get these logs. Additionally, the model upload process now awaits these logs, replacing the Thread.sleep in HasuraFunctions.uploadMissionModel

While checking if any tests were delaying for these events to complete, I noticed that SchedulingTests.BeforeEach was inconsistent in how it uploaded the model compared to other tests classes (it caught and rethrew the potential InterruptedException as a RuntimeException). This has been resolved.

Documentation

Docs ticket here: NASA-AMMOS/aerie-docs#147

Future work

A front-end ticket is needed to track displaying success/failures for model uploads.

- Make Model Upload await logs rather than delay 1.5s
- Fix inconsistency in SchedulingTests.beforeEach
@Mythicaeda Mythicaeda added database Anything related to the database hasura Changes that affect the Hasura metadata labels Apr 24, 2024
@Mythicaeda Mythicaeda self-assigned this Apr 24, 2024
@Mythicaeda Mythicaeda requested a review from a team as a code owner April 24, 2024 01:12
Fixed the PGCMP Workflow. Checking out `develop` requires re-cloning the `PGCMP` repo

Fixed a bug in the migration script that was causing hasura to reapply migration 1 when bulk migrating down from version 1.

Fixed a typo in the migration script preventing the "mark correct version" command from applying
@Mythicaeda Mythicaeda requested review from skovati and removed request for joswig April 24, 2024 20:25
@Mythicaeda Mythicaeda added the feature A new feature or feature request label Apr 24, 2024
@Mythicaeda Mythicaeda requested review from adrienmaillard and removed request for cohansen April 25, 2024 00:07
Copy link
Contributor

@skovati skovati left a comment

Choose a reason for hiding this comment

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

Looks good to me! Excited to have our first migration in the new DB!

@skovati
Copy link
Contributor

skovati commented Apr 26, 2024

Forgot to ask in my review, where is the migration script "typo" that you fixed? Just the "aerie" vs "Aerie"?

@Mythicaeda
Copy link
Contributor Author

Just the "aerie" vs "Aerie"?

Yeah, apparently Hasura's case sensitive 🥲

@Mythicaeda Mythicaeda merged commit ad93e95 into develop Apr 26, 2024
10 checks passed
@Mythicaeda Mythicaeda deleted the feat/hasura-events-view branch April 26, 2024 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database Anything related to the database feature A new feature or feature request hasura Changes that affect the Hasura metadata
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show error if mission model upload fails
2 participants