vivarium-core
vivarium-core copied to clipboard
Pull Schema, Topology, and Hierarchy Utilities into Separate Library
Scattered throughout Vivarium, we have functions to perform operations on schemas, topologies, and hierarchies, e.g. inverse_topology
. I think the codebase would be easier to understand if we pulled these functions into a new library under vivarium/library
so that we can document and test them thoroughly.
In this library, we would have 3 kinds of entities:
- Hierarchies are trees of data.
- Schemas assign metadata to each node in the tree.
- Topologies are like MongoDB projections. They describe how to retrieve data from a hierarchy and re-shape it into a desired structure.
The library would provide functions to do the following:
- Reach into a hierarchy and retrieve values in the form specified by a topology.
- Invert a topology (this function takes in one topology and returns a new topology).
- Given a set of schemas and a set of topologies, create a hierarchy. This function should take parameters to describe how to initialize the hierarchy values from the schema rather than hard-coding a special key like
_default
. This also shouldn't be dependent on theStore
class. - Take a hierarchy and figure out what schemas need to change to effect a change in that hierarchy. This function will also need to take the schemas as an argument.
- Perform operations (e.g. updates) over a hierarchy based on a set of schemas.
Possibly related: #100