-
Notifications
You must be signed in to change notification settings - Fork 21
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 External Events #1513
Merged
Merged
Add External Events #1513
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 tasks
pranav-super
force-pushed
the
feature/external-event
branch
from
July 29, 2024 20:17
0e6ceaf
to
060d2c3
Compare
pranav-super
force-pushed
the
feature/external-event
branch
from
July 30, 2024 20:50
0649272
to
58f6d44
Compare
Mythicaeda
reviewed
Oct 21, 2024
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.
Final three changes, all minor
db-tests/src/test/java/gov/nasa/jpl/aerie/database/ExternalEventTests.java
Outdated
Show resolved
Hide resolved
db-tests/src/test/java/gov/nasa/jpl/aerie/database/ExternalEventTests.java
Outdated
Show resolved
Hide resolved
db-tests/src/test/java/gov/nasa/jpl/aerie/database/ExternalEventTests.java
Outdated
Show resolved
Hide resolved
Mythicaeda
approved these changes
Oct 22, 2024
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.
LGTM!
pranav-super
force-pushed
the
feature/external-event
branch
from
October 22, 2024 16:17
c40f05c
to
616c53d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
A new construct in AERIE is that of External Events. In this PR, we will introduce External Events, their containing entities (External Sources), their grouping mechanisms (Derivation Groups), as well as how they manifest in the UI and in the backend. Detail on what External Events are is provided in the aerie-ui PR, but as a quick summary:
One component of that discussion that is deferred to this description, as it is here that it is primarily handled, is that of derivation. We discuss that in detail here.
Derivation
Derivation was an operation conceived for the reconciliation of overlapping External Sources. The problem at hand was that it is entirely possible for sources to be generated at later points in time, that cover slightly different windows on plan time than their predecessors.
If this is the case, some reconciliation scheme is needed to determine which External Events from these External Sources are valid and should be visible on the timeline.
Reconiciliation Mechanism
To begin this discussion, we should first talk about when External Sources apply.
External Sources, as discussed earlier, have within them a
valid_at
field, which was described as a more particular form of a version number. With this, we know we can impose an ordering of External Sources. Given that ordering, figuring out when each External Source actually applies is as simple as determining for a given time (or slot of time), what the most recently valid External Source is. For example, the following set of 4 External Sources would be applicable in the following order. Note that one of the Exteranl Sources,B
, is valid twice, as it is the most recently valid External Source for a given slot of time:Given this, we can now discuss how to compare the External Events within each External Source, based on how they fall across these windows/against future External Sources. There are 4 rules (though the first two are effectively cases of each other):
A diagram illustrating each of these cases follows. We also have External Sources formatted to align with this diagram here.
Derivation Groups
The final question remaining is the 'who' - who is this derivation operation run against? One possible candidate for this could be the source type. External Events that share a source type include events of the same types and will likely overlap in key namespace as well. This is a nearly ideal solution except in the case of contingencies.
Imagine we have 4 sources of the same source type. Two of these relate to an ideal contingency, and two of these relate to a degenerate contingency:
If we were to derive solely based on source type, we would effectively be stacking all of these sources against each other to produce one result:
Given that these are different cases, despite sharing a source type, it would be useful to have different groups under which derivation is possible. This way, we don't conflate sources just for sharing a source type:
As such, we now define the notion of a Derivation Group. A Derivation Group defines a subgroup within an External Source type of External Sources to derive against each other. Derivation Groups are what we associate with plans (as opposed to individual, underived External Sources, or entire External Source types).
NOTE: to associate events with a plan, we associate not sources, but derivation groups. When merging different plans, the OR of the associated derivation groups is taken. This is expanded on in the documentation.
Verification
Automated tests were primarily added in aerie-ui. By adding tests here and ensuring that all
effects
as well as all new UI features worked as intended, we believe that we have sufficiently tested all new functionality as the majority of it deals with either the front-end itself, or new tables and views. By testing that our requests to Hasura from the front-end work via said tests, we believe we have thoroughly tested AERIE's new functionality.Documentation
No documentation was invalidated. That being said, new documentation is in the works and will eventually see a PR against aerie-docs.
Future work
The next major step is to add integration with the scheduler and the constraints engine to allow scheduling and constraining of activities and resources relative to uploaded External Events. In doing so, we would also seek to define more thoroughly what the relationship between derivation groups/external events and plans (as well as activities) are, which would primarily play a role in plan merging and snapshotting functionalities which have been foregone for this PR as further discussion is necessary. We also seek at some point to define a comprehensive JSON Schema for External Sources and External Events, which was deferred until after this batch so that we had a very concrete and informed view of the problem prior to defining any constraining design. Finally, we might want to introduce an ownership and role scheme around External Sources, though the utility of this is yet to be confirmed and agreed upon.
Specific note: in
external_source.sql
, we have a constraint,dg_unique_valid_at
, which holds that a given derivation group cannot have two sources with the samevalid_at
value. Going forward, we may want to consider making an exception if sources have no overlap. That being said, this could be too particular of an exception that may introduce unnecessary complication to our general, simple set of rules.Specific note (2): it might become possible in the future to allow users (or source owners?) and admin to change the
derivation_group_name
on anexternal_source
to re-link a source to a new derivation group. This warrants further discussion (and trivially, also lacks any UI support currently). As such, there are no update permissions listed, even in the comments, ofexternal_source.yaml
.Discussion Items and TODOS:
Discussion Items
TODOS: