From 653792f4dfa2b616da95c78041abf21cdbfcc619 Mon Sep 17 00:00:00 2001 From: Alexander Schlemmer <alexander@mail-schlemmer.de> Date: Tue, 20 Jul 2021 11:21:38 +0200 Subject: [PATCH] DOC: corrections and usage example for yaml interface documentation --- src/doc/yaml_interface.rst | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/doc/yaml_interface.rst b/src/doc/yaml_interface.rst index 165e0814..05f92c93 100644 --- a/src/doc/yaml_interface.rst +++ b/src/doc/yaml_interface.rst @@ -69,13 +69,13 @@ List attributes are a bit special: .. code-block:: yaml - datatype: LIST(DOUBLE) + datatype: LIST<DOUBLE> would declare a list datatype of DOUBLE elements. .. code-block:: yaml - datatype: LIST(Project) + datatype: LIST<Project> would declare a list of elements with datatype Project. @@ -84,8 +84,8 @@ Keywords -------- - **parent**: Parent of this entity. -- **importance**: Importance of this entity. -- **datatype**: The datatpye of this property, e.g. TEXT, INTEGER or Project. +- **importance**: Importance of this entity. Possible values: "recommended", "obligatory", "suggested" +- **datatype**: The datatype of this property, e.g. TEXT, INTEGER or Project. - **unit**: The unit of the property, e.g. "m/s". - **description**: A description for this entity. - **recommended_properties**: Add properties to this entity with importance "recommended". @@ -94,3 +94,24 @@ Keywords - **inherit_from_recommended**: Inherit from another entity using the specified importance level including the higher importance level "obligatory". This would add a corresponding parent and add all obligatory and recommended properties from the parent. - **inherit_from_suggested including higher importance levels**: Inherit from another entity using the specified importance level. This would add a corresponding parent and add all obligatory, recommended and suggested properties from the parent. - **inherit_from_obligatory**: Inherit from another entity using the specified importance level. This would add a corresponding parent and add all obligatory properties from the parent. + +Usage +----- + +You can use the yaml parser directly in python as follows: + + +.. code-block:: python + + from caosadvancedtools.models import parser as parser + model = parser.parse_model_from_yaml("model.yml") + + +This creates a DataModel object containing all entities defined in the yaml file. + +You can then use the functions from caosadvancedtools.models.data_model.DataModel to synchronize +the model with a CaosDB instance, e.g.: + +.. code-block:: python + + model.sync_data_model() -- GitLab