Skip to content

Add a setting to Simulation to Automatically Check Constraints Afterwards #1783

@Mythicaeda

Description

@Mythicaeda

It can be confusing to users that just because their simulation returned with a green checkmark does not mean the simulation data passes constraints.

To address this, I propose adding a setting to simulation, similar to the Force Resimulate setting, that, when enabled, automatically checks constraints after the simulation completes. The user would need to have both the "can simulate" and "can check constraints" permissions on the plan to simulate with this option enabled. The state of this flag should be stored in the database as part of the simulation dataset information.

Because Simulation and Constraints run in separate containers, I expect that this automation will need to happen in one of two ways:

  1. (and my recommendation) A DB listener is added to the Merlin Server that watches for "complete"d simulations with the "check constraints" flag enabled. When it finds one, it starts a constraints run on that dataset.
  2. The simulation workers submit a constraint request (either via Hasura or an HTTP request) under the user's name. I don't recommend this, as the token information needed to submit the constraint request is only in the Merlin Server part of the request and never passed to the workers.
  3. Sort of a combination of (1) and (2), but instead of an always-running DB Listener, the simulation endpoint in the Merlin Server will start a daemon thread to await the simulation, then trigger constraints. While this would avoid the token issues with (2) (as the Server would have the token), this pattern isn't how we usually code these sorts of things.

By the by, I think the "check constraints after" flag itself can be handled in one of two ways:

  1. it's passed as an argument to the simulate hasura action.
  2. it's stored on the simulation specification

I wrote this ticket assuming (1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    constraintsAnything related to the constraints domainfeatureA new feature or feature requestsimulationAnything related to the simulation domain

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions