Process Enactment
=================

A final operation that is useful to modellers, is the enactment of process models.
When enacting a process model, a series of operations on models is automatically executed.

Finding process models
----------------------

To find process models, you can easily query the Modelverse for models that conform to *ProcessModel*.
All such models can be executed, given that the models and operations they refer to, exist.

Enacting process models
-----------------------

To enact the process model, such as *query_state_space*, you must execute the following operation::

    >>> process_execute("models/query_state_space", "my_", {})

There are three parameters to this function, the first obviously being the name of the process model.
The second parameter is a prefix for the models used in the process model.
When executing a process model, data is processed and produced.
By providing a prefix, the names of these models are first prefixed with the prefix, before they are resolved.
As such, it becomes possible to execute a process in different contexts.

.. note::
   This behaviour is likely to change in the future, with the process taking a mapping from the terms in the process model, to actual names.

The third parameter is a dictionary of callbacks.
For each activity, it is possible for users to define a callback function.
This function will be invoked when the specific activity is executed.
For example, a manual operation will require user input, for which this callback function can then serve.
In this case, lets assume that an activity in the process model, termed *refine_petrinet*, is a manual operation and requires user interaction.
The call then becomes::

    >>> def callback():
    ...     # Any code required to create the Petrinet
    ...     p = instantiate(None, "Place")
    ...     t = instantiate(None, "Transition")
    ...     instantiate(None, "P2T", (p, t))
    ...     # Alternatively, we could have used raw_input() or so to prompt the user
    ...
    >>> process_execute("models/query_state_space", "my_", {"models/refine_petrinet": callback})

When the process executes *refine_petrinet*, the callback function is executed, and the manual operation is terminated when the function terminates.
Other types of operation, such as *model transformations* and *action language* can also have a callback function, but this is usually less important to end users and is therefore not elaborated on here.
