Main concepts¶
Every project that is loaded in Geppetto has a Geppetto model associated to it. The Geppetto Model is a dynamic typed abstraction of the data structures we need for our project. In other words, Geppetto imports the project specific data into a model with fully typed object descriptions.
When the frontends loads a project, the model (coming from the backend) is loaded; while loading the model, the declared variables are instantiated with the default values which are specified in the model. The model comes with a full-featured reflection mechanism, which allows to inspect and instantiate values through the Meta-Model specification.
Why the Geppetto Model Abstraction?¶
Geppetto was born from the need of describing computational models coming from neuroscience. In this context, each model has its own structure and values that can evolve during the experiments we are running upon the model.
The Geppetto Model is dynamic¶
We can represent the model with the usual tools that we use in programming to represent data structures: variables, classes, values, parameters within a life cycle in which variable values can change and can be represented visually.
Nothing that we cannot do with any programming language, except the fact that all of this definitions in Geppetto are made dynamically: when we load a model, we are defining a complete new set of typed data structures based on the Geppetto Meta-Model. We have no limits on the models we can define, still having a fully typed model system.
The Geppetto Model is fully serializable¶
The Geppetto Model can be serialized and is shared and synched between the backend and the frontend of the application.
The Geppetto Model is typed¶
There are simpler ways than the Geppetto Model to defined dynamic structures. For instance, we could define variables with any structure with a JSON markup. JSON markup is not typed though. When we parse a JSON markup we must implicitly know its semantics and write a specific manipulation logic consequently. By defining the types we are kind of declaratively programming the visualization and behaviours which can be automatically associated to the data through Geppetto apis and components. For example, a visual type can be visualized on the canvas, time series can be plotted, etc. On the frontend, instances of different types can have different capabilities, i.e. actions that can be activated from the variables of that types.
Geppetto Meta-Model¶
The Geppetto Meta-Model is a description of what can be found inside a Geppetto model, hence the “meta”. The main concepts to understand from the Geppetto Meta-Model are Type, Variable and Value, and they will be familiar to pretty much every developer. A Geppetto model defines variables, which at some point will be instantiated; each variable has a value and a type. With the use of composite types we can define complex data structures.
Type¶
A Type represents the structure of an entity and therefore defines something that can be associated to one of multiple variables. In modern programming languages this same concept is often referred to as Class.
There are different built-in types defined in the Geppetto Meta-Model; the CompositeType allows the developer to specify structured types with one or more variables.
Every type belongs to the Geppetto library which contains it.
Variable¶
A variable represents an instance of a given type. This concept exists in every programming language. Every variable knows its type and initial value.
Value¶
A value is something that can be assigned to a variable or to a type (the default value) a concept that once again exists in every programming language. There are different kinds of values defined in the Geppetto meta-model and every existing type has pretty much one or more corresponding values defined.
Model at runtime¶
The Geppetto model is created on the backend usually from a EMF specification file (xmi). Domain specific Geppetto types and values are created dynamically at runtime from possibly any file format provided a Model Interpreter is available for that format.
Upon receiving a Geppetto Model from the backend, when loading a given Geppetto Project, the frontend will instantiate it.
Instantiated Geppetto Types are mapped to JavaScript objects (e.g. a population of one cell Type would become a JavaScript array containing Instances of that Type) and augmented with specific Capabilities which confer on them the ability to be accessed via a specific API.
Instances¶
Variables are defined with a type and a default value. When the Geppetto model is loaded on the frontend its top-level variables are instantiated (the model is only instantiated in the client). Every instance knows its value and variable, each variable knows its type(s). A type in turn may contain multiple variables (as is the case of CompositeType) that can be instantiated. The instantiation of inner variables is done on demand at runtime when needed.
For example, let’s start from a model having a top level variable x of type T. The
type T is a CompositeType defining the variables t1 and t2.
When the model is loaded we will have an instance called x
on our Geppetto runtime.
So we can:
- Use that instance
x
in the Geppetto console - Access the instance through the global Javascript variable
x
- Create the instance from Javascript through
Instances.getInstance('x')
- Create the instance from Javascript through
Instances.getInstance('x.t1')
- Use the instance sub variables through
x.t1
,x.t2
from the Geppetto console
Note that we are not guaranteed to access x.t1
from Javascript until
Instances.getInstance('x.t1')
is invoked: sub instances are created on demand.
Capabilities¶
The client will inject Capabilities to an instance depending on their type. A capability will confer to the Javascript object an API to interact with the specifics of its type. Thus we have type-specific methods as in OOP languages.
So, for instance, if a Model Interpreter in the backend defined a custom Type including a State Variable, upon instantiation in the frontend, this would become a JavaScript object with an injected StateVariableCapability containing methods specific for state variables, e.g. getUnit(), getInitialValue(), etc.
This has the advantage of giving developers the ability to build UI components that can interact with the Geppetto Model in an object-oriented way, and allow all the user operations to be fully scriptable, reproducible and testable (e.g. a UI button designed to plot a state variable would call Plot.plotData(myStateVariable.getTimeSeries()
). The same principles apply when a custom Type defining a cell morphology (Values like Sphere and Cylinder are available to this end in the Geppetto Model Abstraction) is sent to the frontend and passed to the 3D Canvas component using its API for display.
Instances and UI Components: behaviours¶
Some UI component are initialized from instances and use their knowledge of the types and the capabilities to initialize the visualization or other behaviours.
- ControlPanel: loads by default all Instances of type VisualType
- Canvas: shows Instances of type VisualType on the 3D Canvas
[comment]: <> (TO be completed)