-
Notifications
You must be signed in to change notification settings - Fork 19
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
base: develop
Are you sure you want to change the base?
Add External Events #1513
Conversation
0e6ceaf
to
060d2c3
Compare
0649272
to
58f6d44
Compare
Not completely confident on placing it in external_event.sql, open to comment there.
add duration to derived_events (helpful quantity to include without need for cross-referencing), change check on end time for source to be > start time, not >=
Was not pointing to external_event pkey!
Branching, for now, is made up of 2 behaviors: - when a new branch is created, all associated derivation groups in the parent are copied to the child - on merge, the parent gets a superset (OR operation) of the derivation groups the parent and child have. The child is unaffected.
fd9e2ae
to
70d36cf
Compare
properties jsonb, | ||
|
||
constraint external_event_pkey | ||
primary key (key, source_key, derivation_group_name, event_type_name), |
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.
I'm not a fan of large composite primary keys, especially when one or all of the components are strings. Please make a column id integer generated by default as identity
and set that as the primary key. I don't think it'll be a very impactful change.
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.
I haven't had a chance to take a look and form an opinion, but I'd like to leave as a reminder that this pk would need to be replaced with a unique
constraint if this change is made.
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.
I believe Pranav et al started with synthetic keys for everything, and then based on an initial review (with @Mythicaeda ?) refactored everything to use natural keys instead.
Sounds like maybe there's a middle ground where sometimes we prefer one or the other? @JoelCourtney and @Mythicaeda , if you have some time, talk this over amongst yourselves and see if you can come to a consensus on the guidance to give Pranav
The UI no longer uses it, per this comment: NASA-AMMOS/aerie-ui#1396 (comment)
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).
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. 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.
Discussion Items and TODOS:
Discussion Items
TODOS: