Skip to content

Add upload simulation dataset feature#1852

Draft
remy-rabideau wants to merge 9 commits into
NASA-AMMOS:developfrom
remy-rabideau:feature/upload-simulation-dataset
Draft

Add upload simulation dataset feature#1852
remy-rabideau wants to merge 9 commits into
NASA-AMMOS:developfrom
remy-rabideau:feature/upload-simulation-dataset

Conversation

@remy-rabideau

@remy-rabideau remy-rabideau commented Jul 14, 2026

Copy link
Copy Markdown
  • Review: By commit
  • Merge strategy: Merge (no squash)

REQUIRES_GATEWAY_PR="148"
NASA-AMMOS/plandev-gateway#148

Description

Adds a POST /uploadSimulationDataset Hasura action and merlin-server endpoint that accepts a simulation results JSON payload in SimulationResultsWriter format and persists it to the database associated with an existing plan.

The primary use case is transferring a simulation dataset from one plan to another — for example, a cloned or slightly modified plan using a compatible model — or between PlanDev instances. Ingesting results produced by external simulators is also supported. The SimulationResultsWriter format can be produced by aerie-cli via plans download-simulation-full-results.

The full pipeline: Hasura receives the mutation → forwards the action envelope to merlin-server → SimulationResultsParser parses the JSON → PostgresPlanRepository.uploadSimulationDataset writes the dataset, profiles, segments, activity spans, topics, and events in a single transaction → returns the new simulationDatasetId.

Reviewers should be aware that the Javalin max request size was raised to 256 MB globally (not scoped to this route) to support large uploads.

Changes:

  • deployment/hasura/metadata/actions.graphql — adds uploadSimulationDataset mutation and SimulationResultsInput scalar type; adds missing custom scalar declarations
  • deployment/hasura/metadata/actions.yaml — registers the Hasura action handler pointing to merlin-server with aerie_admin and user permissions
  • merlin-server/.../SimulationResultsParser.java (new) — parses the SimulationResultsWriter JSON format (DOY timestamps, real/discrete profiles with named segments, simulated activities, optional topics/events)
  • merlin-server/.../MerlinBindings.java — registers POST /uploadSimulationDataset route; parses Hasura action envelope, checks insert_ext_dataset permission, delegates to plan service
  • merlin-server/.../HasuraParsers.java — adds hasuraUploadSimulationDatasetActionP parser for the action input envelope
  • merlin-server/.../ResponseSerializers.java — adds serializeCreatedSimulationDatasetId method returning a JSON object with simulationDatasetId
  • merlin-server/.../HasuraAction.java — adds insert_ext_dataset permission and UploadSimulationDatasetInput record
  • merlin-server/.../PlanService.java / LocalPlanService.java — adds uploadSimulationDataset to the service interface and implementation
  • merlin-server/.../PlanRepository.java / PostgresPlanRepository.java / InMemoryPlanRepository.java — adds uploadSimulationDataset to the repository interface; PostgreSQL implementation writes the full dataset in a single transaction
  • merlin-server/.../AerieAppDriver.java — raises Javalin max request size to 256 MB to support large simulation dataset uploads

Verification

  • Unit tests added in UploadSimulationDatasetParserTest covering real profiles, discrete profiles, activities, simulation arguments, topics, and events (including absence defaults). Run locally and pass.
  • End-to-end tests added in UploadSimulationDatasetTests covering: successful upload with empty profiles, discrete profiles, real profiles, and mixed profiles; invalid plan ID (404); missing required field (400); unauthorized user (403).

Documentation

No existing documentation covers this endpoint. The SimulationResultsWriter format it accepts is defined in the aerie-cli repository (see NASA-AMMOS/aerie-cli#187).

Future work

  • Scope the 256 MB request size limit to the uploadSimulationDataset route only rather than applying it globally
  • plandev-ui and plandev-gateway changes (in separate PRs) are required to expose this endpoint to end users

… for creating simulation datasets with profiles
…plement in PostgresPlanRepository and InMemoryPlanRepository
…nstead of individual parameters

Consolidate uploadSimulationDataset parameters into a single SimulationResults object. Update Hasura action definition, parsers, and repository implementations. Add SimulationResultsParser to deserialize JSON format produced by SimulationResultsWriter, including parsing of duration strings, timestamps, profile segments, activities, and events. Update PostgresPlanRepository to extract data from SimulationResults and write
…oadSimulationDataset JSON input

Add simulationArguments Map<String, SerializedValue> field to SimulationResults with constructor overload for backward compatibility. Update SimulationResultsParser to parse optional simulationArguments field from JSON. Modify PostgresPlanRepository to use parsed simulationArguments instead of empty map when creating simulation datasets. Add unit tests verifying parsing with and without simulationArguments fiel
The parser now handles optional "topics" and "events" sections in the
upload JSON. Topics are parsed as a map of name -> schema and converted
to List<Triple<Integer, String, ValueSchema>> with synthesized indices.
Flat events are grouped by (realTime, transactionIndex), then
reconstructed into EventGraph<EventRecord> objects via
EventGraphUnflattener.unflatten() for insertion into the database.

Previously these fields were ignored, resulting in uploaded simulation
datasets always having 0 events.
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.

1 participant