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

[AERIE-1935] Expose plan start time to mission model #278

Merged
merged 5 commits into from
Aug 25, 2022

Conversation

pcrosemurgy
Copy link
Contributor

@pcrosemurgy pcrosemurgy commented Aug 4, 2022

  • Tickets addressed: AERIE-1935
  • Review: By commit
  • Merge strategy: Merge (no squash)

Description

Mission modelers currently don't have access to a plan's start time.
With this PR a plan start time Instant parameter can optionally be declared in the top-level mission model ("Mission.java") constructor.

If a top-level mission model defines a constructor with Instant as the 2nd argument then the sim. start time will be passed to the mission model upon instantiation. If the Instant parameter (or Registrar parameter and optionally a "Configuration" parameter) is declared out-of-order then an actionable error message is now presented at compile-time. See the section below for examples.

More concretely, the following top-level mission model constructor parameters are allowed (lifted from MissionModelParser.java):

    // - (Registrar, Instant, Configuration)
    // - (Registrar, Configuration)
    // - (Registrar, Instant)
    // - (Registrar)

As seen above, both sim. start time and mission model configuration parameters are optional. However, if both are defined "Configuration" must be declared last. This ensures backwards compatibility with existing mission models while allowing future mission models to make use of this Instant.

See the future work section for a discussion on alternative approaches for this PR.

Verification

See foo-missionmodel's MissionConfigurationTest.

Error Handling

When the following Mission constructor parameters are declared in an allowable order no compile-time error is thrown:

public Mission(final Registrar registrar, final Instant planStart, final Configuration config) {
  ...
}

However, when Instant (or any of the above parameters) are declared out of expected order a custom error message will appear:

.../foomissionmodel/package-info.java:21: error: The top-level model's constructor is expected to accept [gov.nasa.jpl.aerie.merlin.framework.Registrar, java.time.Instant, gov.nasa.jpl.aerie.foomissionmodel.Configuration], found: [gov.nasa.jpl.aerie.merlin.framework.Registrar, gov.nasa.jpl.aerie.foomissionmodel.Configuration, java.time.Instant]

In this example, Mission's constructor was declared with a plan start Instant in the wrong expected order:

public Mission(final Registrar registrar, final Configuration config, final Instant planStart) {
  ...
}

Documentation

Future work

Initially a @PlanStart annotation was considered but in prototyping this implementation it was found that this change would require plan information to be passed in at our GQL layer (to allow any configured context to have plan information).
This would break existing GQL queries and more tightly couple our plan and model "domains".

See Slack thread for more context and discussion on this.

@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch 2 times, most recently from f1078c6 to 2976b19 Compare August 5, 2022 20:16
@pcrosemurgy pcrosemurgy changed the title [AERIE-1935] Expose plan timeline to mission model [AERIE-1935] Expose simulation start time & duration to mission model Aug 8, 2022
@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch from 2976b19 to 8b36139 Compare August 8, 2022 20:58
@pcrosemurgy pcrosemurgy changed the title [AERIE-1935] Expose simulation start time & duration to mission model [AERIE-1935] Expose simulation timeline to mission model Aug 8, 2022
@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch 3 times, most recently from 3c414b4 to d2d2979 Compare August 11, 2022 22:07
@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch from d2d2979 to 8bcd5a3 Compare August 15, 2022 20:13
@pcrosemurgy pcrosemurgy temporarily deployed to e2e-test August 15, 2022 20:13 Inactive
@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch from 8bcd5a3 to 5d210cb Compare August 15, 2022 20:33
@pcrosemurgy pcrosemurgy temporarily deployed to e2e-test August 15, 2022 20:33 Inactive
@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch from cf28708 to 1f182f0 Compare August 15, 2022 20:50
@pcrosemurgy pcrosemurgy temporarily deployed to e2e-test August 15, 2022 20:50 Inactive
@pcrosemurgy pcrosemurgy changed the title [AERIE-1935] Expose simulation timeline to mission model [AERIE-1935] Expose simulation start time to mission model Aug 15, 2022
@pcrosemurgy pcrosemurgy marked this pull request as ready for review August 15, 2022 21:08
@mattdailis
Copy link
Collaborator

From reading the PR description, it sounds like the annotation approach would be preferable, but we're concerned that having different annotations for records vs regular classes would cause confusion. Am I reading that correctly?

Would it help to have two similarly named annotations in different names paces, or would that make it even more confusing?

@Twisol
Copy link
Contributor

Twisol commented Aug 17, 2022

  • I don't believe it's possible to define a single annotation for use as both a class member variable and constructor parameter but may be wrong.

I'd expect this to be possible. Annotations don't do anything on their own -- it's up to our processor how to interpret them.

If you're concerned about how to set java.lang.annotation.Target to specify where the annotation is allowed, @Target can accept a list of locations:

@Target({ElementType.RECORD_COMPONENT, ElementType.FIELD})
@interface SimulationStart {
}

(Also, can you remind me what the difference is between the simulation start time and the plan start time?)

@Twisol
Copy link
Contributor

Twisol commented Aug 17, 2022

That question is asking about propagating annotations on records to their synthesized constructors. I don't think this matters to us -- if we know it's a record, we can look at the record's components directly, which IIRC is how the other record-based analyses in our processor work.

@pcrosemurgy
Copy link
Contributor Author

Also, can you remind me what the difference is between the simulation start time and the plan start time?

Sim. start time is passed through from a "create sim. message". Currently I believe they should always be the same but we're carefully making sure to use sim. start time here since I believe in the future we may have sim. and plan start time differ (for example when re-running part of a sim. I believe).

@pcrosemurgy
Copy link
Contributor Author

pcrosemurgy commented Aug 22, 2022

@Twisol

If you're concerned about how to set java.lang.annotation.Target to specify where the annotation is allowed, @ Target can accept a list of locations:

Thanks for the help! I'll rework this PR to use a single annotation with multiple targets. Having this annotation apply to only config. types will complicate our mapper code-gen. but an annotation does seem like the correct approach. :)

@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch from 916ed77 to b535e66 Compare August 25, 2022 19:38
@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch from b535e66 to 7e89761 Compare August 25, 2022 19:49
@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch from 7e89761 to 5e38754 Compare August 25, 2022 19:55
@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch from 5e38754 to 2ac4e84 Compare August 25, 2022 20:00
@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch from 2ac4e84 to a10a0c5 Compare August 25, 2022 20:05
@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch from a10a0c5 to e09f61d Compare August 25, 2022 20:15
@pcrosemurgy pcrosemurgy temporarily deployed to e2e-test August 25, 2022 20:20 Inactive
@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch from 29c7e1d to ec642fe Compare August 25, 2022 20:29
@pcrosemurgy pcrosemurgy temporarily deployed to e2e-test August 25, 2022 20:30 Inactive
@pcrosemurgy
Copy link
Contributor Author

Everything is now stable. Done making changes :)

@pcrosemurgy pcrosemurgy force-pushed the feat/aerie-1935-expose-plan-timeline-to-mm branch from ec642fe to 6c98d18 Compare August 25, 2022 20:57
@pcrosemurgy pcrosemurgy temporarily deployed to e2e-test August 25, 2022 20:57 Inactive
@goetzrrGit
Copy link
Contributor

Just to understand it better the mission model will use the UNTRUE_PLAN_START by default unless specified by the user in their queries?

@pcrosemurgy
Copy link
Contributor Author

Just to understand it better the mission model will use the UNTRUE_PLAN_START by default unless specified by the user in their queries?

The mission model will actually use UNTRUE_PLAN_START for every mission model instantiation besides the instantiation done for a simulation run. So any of these:
Screen Shot 2022-08-25 at 11 37 42 AM

@pcrosemurgy
Copy link
Contributor Author

When running a simulation the actual plan start time will be used :)

@goetzrrGit
Copy link
Contributor

Thanks for the info!! I also just read through the slack thread I missed between you, Matt, and Jonathan, which gave me more context.

@pcrosemurgy
Copy link
Contributor Author

Thanks Ryan, appreciate you spending time on this w/ us!

Copy link
Contributor

@goetzrrGit goetzrrGit left a comment

Choose a reason for hiding this comment

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

Not much I would improve upon. Just make sure you create another ticket for the mission model redesign.

Copy link
Collaborator

@mattdailis mattdailis 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. If you haven't already, let's make a ticket to come up with the longer term solution.

EDIT: Whoops, just saw that Ryan said the same thing

@pcrosemurgy pcrosemurgy merged commit 6ead5b6 into develop Aug 25, 2022
@pcrosemurgy pcrosemurgy deleted the feat/aerie-1935-expose-plan-timeline-to-mm branch August 25, 2022 22:00
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.

4 participants