Forráskód Böngészése

Added the structure of the Python wrapper, still needs to be filled in

Yentl Van Tendeloo 8 éve
szülő
commit
97692e45fb
4 módosított fájl, 294 hozzáadás és 5 törlés
  1. 3 3
      doc/internal.rst
  2. 1 0
      doc/problems.rst
  3. 288 0
      doc/wrappers.rst
  4. 2 2
      wrappers/modelverse.py

+ 3 - 3
doc/internal.rst

@@ -166,14 +166,14 @@ The initial graph consists of several parts:
 
 * The Modelverse Root node;
 * A global definition of all primitives;
-* The stack frame of the initial user *user_manager*, which manages all other users;
-* The code for the *user_manager* user;
+* The stack frame of the initial task *task_manager*, which manages all other tasks;
+* The code for the *task_manager* task;
 * The code for all new users, as assigned by the *user_manager*;
 * Bindings in the compilation manager for bootstrap files.
 
 These are all fairly simple in themselves.
 For some parts, such as the code, the HUTN compiler is invoked on a temporary piece of code.
-All bootstrap files are also compiled and made available to the compilation manager with their MD5 hash.
+All bootstrap files are also compiled and made available to the Modelverse.
 
 How to add a primitive
 ----------------------

+ 1 - 0
doc/problems.rst

@@ -1,2 +1,3 @@
 Common problems and solutions
 =============================
+

+ 288 - 0
doc/wrappers.rst

@@ -0,0 +1,288 @@
+Wrappers
+========
+
+Several wrappers can be defined for the Modelverse, as the Modelverse is merely a service running externally.
+To communicate effectively, and automatically, a programming language wrapper is recommended.
+Nonetheless, it is possible to communicatie manually as well.
+These are some of the implemented wrappers.
+
+Prompt
+------
+
+The simplest wrapper is the prompt wrapper, which merely sends the input and output directly to the user.
+This wrapper has almost no code, but requires users to manually decide which content to send next.
+It has no built-in integration with any model or action language compilers.
+Nonetheless, it is an easy way to test out the raw communication protocol manually.
+
+Python
+------
+
+The first real wrapper is the Python-based wrapper.
+It provides a set of functions for use by Python code.
+These functions wrap not only the interface, but also provides simple error handling through the use of Python exceptions and contains the model and action language compilers.
+An overview of all functions and associatied exceptions is provided below.
+All operations happen *synchronously*, meaning that they block until the Modelverse has performed the requested operation.
+
+Note that some functions are only applicable in a certain *context*.
+In practice, this means that you should first issue the *init* and *login* operations, as otherwise your connection with the Modelverse will not have started up yet.
+
+Functions
+^^^^^^^^^
+
+.. function:: init(address_param="http://127.0.0.1:8001", timeout=20.0)
+
+   Explanation of init.
+
+.. function:: login(username, password)
+
+   Explanation
+
+.. function:: model_add(model_name, metamodel_name, model_code=None)
+
+   Explanation
+
+.. function:: upload_code(code)
+
+   Expl
+
+.. function:: model_delete(model_name)
+
+   Expl
+
+.. function:: model_list()
+
+   Expl
+
+.. function:: model_list_full()
+
+   Expl
+
+.. function:: verify(model_name)
+
+   Expl
+
+.. function:: model_overwrite(model_name, new_model_code=None)
+
+   Expl
+
+.. function:: user_logout()
+
+   Expl
+
+.. function:: user_delete()
+
+   Expl
+
+.. function:: model_render(model_name, mapper_name)
+
+   Expl
+
+.. function:: transformation_between(source, target)
+
+   Expl
+
+.. function:: transformation_add_MT_language(metamodels, RAMified_name)
+
+   Expl
+
+.. function:: transformation_add_MT(RAMified_metamodel, source_metamodels, target_metamodels, operation_name, code)
+
+   Expl
+
+.. function:: transformation_add_AL(source_metamodels, target_metamodels, operation_name, code)
+
+   Expl
+
+.. function:: transformation_add_MANUAL(source_metamodels, target_metamodels, operation_name)
+
+   Expl
+
+.. function:: transformation_execute_AL(operation_name, input_models_dict, output_models_dict, callback=lambda i: None)
+
+   Expl
+
+.. function:: transformation_execute_MANUAL(operation_name, input_models_dict, output_models_dict, callback=lambda i: None)
+
+   Expl
+
+.. function:: transformation_execute_MT(operation_name, input_models_dict, output_models_dict, callback=lambda i: None)
+
+   Expl
+
+.. function:: transformation_list()
+
+   Expl
+
+.. function:: transformation_RAMify(metamodel_name, RAMified_metamodel_name)
+
+   Expl
+
+.. function:: process_execute(process_name, prefix, callbacks)
+
+   Expl
+
+.. function:: permission_modify()
+
+   Expl
+
+.. function:: permission_owner()
+
+   Expl
+
+.. function:: permission_group()
+
+   Expl
+
+.. function:: group_create()
+
+   Expl
+
+.. function:: group_delete()
+
+   Expl
+
+.. function:: group_owner_add()
+
+   Expl
+
+.. function:: group_owner_delete()
+
+   Expl
+
+.. function:: group_join()
+
+   Expl
+
+.. function:: group_kick()
+
+   Expl
+
+.. function:: admin_promote()
+
+   Expl
+
+.. function:: admin_demote()
+
+   Expl
+
+.. function:: element_list(model_name)
+
+   Expl
+
+.. function:: types(model_name)
+
+   Expl
+
+.. function:: types_full(model_name)
+
+   Expl
+
+.. function:: read(model_name, ID)
+
+   Expl
+
+.. function:: read_attrs(model_name, ID)
+
+   Expl
+
+.. function:: instantiate(model_name, typename, edge=None, ID="")
+
+   Expl
+
+.. function:: delete_element(model_name, ID)
+
+   Expl
+
+.. function:: attr_assign(model_name, ID, attr, value)
+
+   Expl
+
+.. function:: attr_assign_code(model_name, ID, attr, code)
+
+   Expl
+
+.. function:: attr_delete(model_name, ID, attr)
+
+   Expl
+
+.. function:: read_outgoing(model_name, ID, typename)
+
+   Expl
+
+.. function:: read_incoming(model_name, ID, typename)
+
+   Expl
+
+.. function:: read_association_source(model_name, ID)
+
+   Expl
+
+.. function:: read_association_destination(model_name, ID)
+
+   Expl
+
+Exceptions
+^^^^^^^^^^
+
+.. exception:: ModelverseException
+
+   Expl
+
+.. exception:: UnknownError
+
+   Expl
+
+.. exception:: UnknownIdentifier
+
+   Expl
+
+.. exception:: UnknownType
+
+   Expl
+
+.. exception:: NotAnAssociation
+
+   Expl
+
+.. exception:: UnsupportedValue
+
+   Expl
+
+.. exception:: CompilationError
+
+   Expl
+
+.. exception:: NoSuchAttribute
+
+   Expl
+
+.. exception:: UnknownModel
+
+   Expl
+
+.. exception:: ConnectionError
+
+   Expl
+
+.. exception:: ModelExists
+
+   Expl
+
+.. exception:: PermissionDenied
+
+   Expl
+
+.. exception:: InvalidMode
+
+   Expl
+
+.. exception:: InterfaceMismatch
+
+   Expl
+
+Custom
+------
+
+Other wrappers can be made as desired, in whatever language required.
+This is due to the fact that the Modelverse communicates only through XML/HTTPRequests.
+As such, all languages that support this, can simply mimic the interface used by any of the implemented wrappers.

+ 2 - 2
wrappers/modelverse.py

@@ -407,7 +407,7 @@ def user_delete():
     _input("self-destruct")
     mode = MODE_UNCONNECTED
 
-def model_render(model, mapper):
+def model_render(model_name, mapper_name):
     """Fetch a rendered verion of a model."""
     # return JSON_representation
     # raises UnknownError
@@ -415,7 +415,7 @@ def model_render(model, mapper):
     # raises InterfaceMismatch
     _goto_mode(MODE_MODELLING)
 
-    _input(["model_render", model, mapper])
+    _input(["model_render", model_name, mapper_name])
     return _handle_output("Success: ", split=" ")
 
 def transformation_between(source, target):