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

Track constraint checking #1013

Merged
merged 22 commits into from
Jul 11, 2023
Merged

Track constraint checking #1013

merged 22 commits into from
Jul 11, 2023

Conversation

cohansen
Copy link
Contributor

@cohansen cohansen commented Jun 29, 2023

Closes #997
Closes #514
Closes #637

  • Review: By file
  • Merge strategy: Merge (no squash)

Description

This PR adds constraint run tracking. The way it's currently working is each constraint_run record is tied to a constraint that was checked. Regardless on if that constraint had violations or not we save a record to the constraint_run table that includes basic constraint information and the violations that were encountered. This allows us to reuse those violations in subsequent constraint violation checks.

There is also staleness checking for the runs through a field called definition_outdated. This field tracks if the constraint definition has changed since the violations were checked last.

There is also staleness checking for the runs, each record gets the status resolved when it has been saved to the db. If the user makes a change to a constraint with any resolved runs, those affected runs get a status change to constraint-outdated. This works the same way for simulations, if a violation check happened and then the user runs a new simulation all constraint runs for that previous dataset are marked as simulation-outdated.

This is my first big PR for aerie-merlin so please hit me with some feedback!

Verification

Manual tests, I need to work on adding some real tests but I wanted to get the PR up for review first. Expect another commit with tests.

To verify everything is working properly you can do the following:

  1. Create a model and a plan.
    Add a constraint to the plan (I used return Real.Resource('/peel').greaterThan(x); for a lot of my testing).
  2. Add an activity to the plan and simulate.
  3. Do a constraint violation check, the constraint_run table now should be populated with a single entry and it shouldn't be marked as outdated.
  4. Go modify your constraint, that entry in the definition_outdated field should now be true.
  5. Do another constraint violation check, the entry should be marked as not outdated again.

1. Create a model and a plan.
2. Add a constraint to the plan (I used return Real.Resource('/peel').greaterThan(x); for a lot of my testing).
3. Add an activity to the plan and simulate.
4. Do a constraint violation check, the constraint_run table now should be populated with a single entry with a status resolved.
7. Go modify your constraint, that entry in the db should be now marked as constraint-outdated.
8. Do another constraint violation check, a new entry should exist in the table with a status resolved.
9. Add another activity and re-simulate.
10. The newest entry in the constraint_run table should now be marked simulation-outdated.

You can also run the constraint violation check in succession to test the caching behavior.

Documentation

I'll update aerie docs to add information about constraint run tracking after this PR is created. Link will be added here.

Future work

Going to work on #514 as a separate ticket.

@cohansen cohansen requested a review from a team as a code owner June 29, 2023 20:11
@cohansen cohansen requested review from mattdailis and jmdelfa June 29, 2023 20:11
@cohansen cohansen self-assigned this Jun 29, 2023
@cohansen cohansen temporarily deployed to e2e-test June 29, 2023 20:11 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test June 29, 2023 20:11 — with GitHub Actions Inactive
@camargo camargo changed the title Feature/track constraint checking Track constraint checking Jun 30, 2023
@camargo camargo added feature A new feature or feature request constraints Anything related to the constraints domain labels Jun 30, 2023
cohansen added 8 commits July 6, 2023 13:20
	new file:   merlin-server/sql/merlin/tables/constraint_run.sql
	new file:   merlin-server/src/main/java/gov/nasa/jpl/aerie/merlin/server/remotes/ConstraintRepository.java
	new file:   merlin-server/src/main/java/gov/nasa/jpl/aerie/merlin/server/remotes/postgres/ConstraintRunRecord.java
	new file:   merlin-server/src/main/java/gov/nasa/jpl/aerie/merlin/server/remotes/postgres/CreateConstraintRunAction.java
	new file:   merlin-server/src/main/java/gov/nasa/jpl/aerie/merlin/server/remotes/postgres/GetConstraintRunsAction.java
	new file:   merlin-server/src/main/java/gov/nasa/jpl/aerie/merlin/server/remotes/postgres/InsertConstraintRunsAction.java
	new file:   merlin-server/src/main/java/gov/nasa/jpl/aerie/merlin/server/remotes/postgres/PostgresConstraintRepository.java
	new file:   merlin-server/src/main/java/gov/nasa/jpl/aerie/merlin/server/services/ConstraintAction.java
	new file:   merlin-server/src/main/java/gov/nasa/jpl/aerie/merlin/server/services/ConstraintService.java
	new file:   merlin-server/src/main/java/gov/nasa/jpl/aerie/merlin/server/services/LocalConstraintService.java
	new file:   merlin-server/src/test/java/gov/nasa/jpl/aerie/merlin/server/mocks/StubConstraintService.java
@cohansen cohansen force-pushed the feature/track-constraint-checking branch from 8969a15 to 8fe0b14 Compare July 6, 2023 23:24
@cohansen cohansen temporarily deployed to e2e-test July 6, 2023 23:24 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 6, 2023 23:24 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 6, 2023 23:24 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 7, 2023 19:03 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 7, 2023 19:03 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 7, 2023 19:03 — with GitHub Actions Inactive
@camargo camargo requested review from camargo and skovati and removed request for mattdailis and jmdelfa July 10, 2023 16:33
@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 15:46 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 15:46 — with GitHub Actions Inactive
Copy link
Member

@camargo camargo left a comment

Choose a reason for hiding this comment

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

Works great! Tested with a couple constraints in the demo mission model. Created NASA-AMMOS/aerie-ui#770 to update the UI to use the new table. Good to go.

@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 17:05 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 17:05 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 17:05 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 17:46 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 17:46 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 17:46 — with GitHub Actions Inactive
@cohansen
Copy link
Contributor Author

Works great! Tested with a couple constraints in the demo mission model. Created NASA-AMMOS/aerie-ui#770 to update the UI to use the new table. Good to go.

Thanks Chris!

Copy link
Contributor

@Mythicaeda Mythicaeda left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks Cody!

@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 18:26 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 18:27 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 18:27 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 18:43 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 18:54 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 18:54 — with GitHub Actions Inactive
@cohansen cohansen temporarily deployed to e2e-test July 11, 2023 18:54 — with GitHub Actions Inactive
@cohansen cohansen merged commit 87988cf into develop Jul 11, 2023
@cohansen cohansen deleted the feature/track-constraint-checking branch July 11, 2023 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
constraints Anything related to the constraints domain feature A new feature or feature request
Projects
None yet
3 participants