Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

[TASK]: Stub model composition API endpoint #10

Closed
bencodrington opened this issue Nov 1, 2022 · 0 comments · Fixed by #17
Closed

[TASK]: Stub model composition API endpoint #10

bencodrington opened this issue Nov 1, 2022 · 0 comments · Fixed by #17
Assignees

Comments

@bencodrington
Copy link
Contributor

Description
Create an endpoint to solidify the proposed API for composing two models in Petri Net form.
Should not rely on any integration with Catlab or TA2 performers.

The input payload should include:

  • modelA: a JSON-serialized petri net
  • modelB: a JSON-serialized petri net
  • commonStates: a list of pairs of states (one from each model) that should be combined as part of this operation.

An example of what the commonStates input might look like:

[
  // In this example, modelA and modelB both contain a state called "p1". The output will merge these two states
  {
    modelA: “p1”,
    modelB: “p1”
  },
  // In this example, modelA and modelB contain states with two different names("foo" and"bar") that we want to merge despite their differing names.
  {
    modelA: “foo”,
    modelB: “bar” 
  },
  ...
]

Behaviour and return value
Assuming there are no errors, this endpoint should return a new JSON-serialized petri net that includes the states from both input petri nets, merges the states listed in commonStates, and preserves the transitions from each input petri net (updating any transitions that involve states that were merged).

Note that since petri net components do not currently have unique IDs, there can be some ambiguity if a model contains multiple states with the same label. For now, it's fine to use the first state you find with the correct label. It's also fine to output a petri net that includes multiple states with the same label.

Edge cases
This work includes writing tests to confirm the endpoint behaves reasonably for cases like:

  • invalid input formats: return an error
  • commonStates is empty: preserve all states and transitions from both input models
  • a pair in commonStates doesn't have keys for both models: return an error
  • a commonStates pair contains a state label that can't be found in the model: return an error
  • successfully merge two states with the same name
  • successfully merge two states with different names
  • successfully handle an array of commonStates with length > 1
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants