diff --git a/src/caosadvancedtools/cfoods/h5.py b/src/caosadvancedtools/cfoods/h5.py index cbf9d0baefa435b71eeaeefe63a9b018faabe7ea..4e6832f2e96e0950ed99146d4907f1ffb70d8494 100644 --- a/src/caosadvancedtools/cfoods/h5.py +++ b/src/caosadvancedtools/cfoods/h5.py @@ -97,7 +97,7 @@ def h5_attr_to_property(val): # TODO this can eventually be removed - if(hasattr(val, 'ndim')): + if hasattr(val, 'ndim'): if not isinstance(val, np.ndarray) and val.ndim != 0: print(val, val.ndim) raise Exception( diff --git a/src/doc/index.rst b/src/doc/index.rst index 9aa045349ab05d3f5130a7f33b38c7eca0c4f32e..5fdb78da4eddfd0145d0357202246d4b5352dcf4 100644 --- a/src/doc/index.rst +++ b/src/doc/index.rst @@ -13,9 +13,8 @@ This documentation helps you to :doc:`get started<getting_started>`, explains th Getting started <README_SETUP> Concepts <concepts> - tutorials - Caosdb-Crawler <crawler> - YAML Interface <yaml_interface> + The Caosdb Crawler <crawler> + YAML data model specification <yaml_interface> _apidoc/modules diff --git a/src/doc/yaml_interface.rst b/src/doc/yaml_interface.rst index 476e92829238a0fc9dac851c61790c022e9fcde9..52d33a174e6c98f77f4bc55b1593545f864ee0b2 100644 --- a/src/doc/yaml_interface.rst +++ b/src/doc/yaml_interface.rst @@ -1,10 +1,14 @@ -YAML-Interface --------------- -The yaml interface is a module in caosdb-pylib that can be used to create and update +=============================== + YAML data model specification +=============================== + +The ``caosadvancedtools`` library features the possibility to create and update CaosDB models using a simplified definition in YAML format. -Let's start with an example taken from https://gitlab.indiscale.com/caosdb/src/caosdb-advanced-user-tools/-/blob/dev/unittests/model.yml. +Let's start with an example taken from `model.yml +<https://gitlab.indiscale.com/caosdb/src/caosdb-advanced-user-tools/-/blob/dev/unittests/model.yml>`__ +in the library sources. .. code-block:: yaml @@ -44,7 +48,7 @@ Let's start with an example taken from https://gitlab.indiscale.com/caosdb/src/c -This example defines 3 ``RecordType``s: +This example defines 3 ``RecordTypes``: - A ``Project`` with one obligatory property ``datatype`` - A Person with a ``firstName`` and a ``lastName`` (as recommended properties) @@ -69,8 +73,10 @@ Note the difference between the three property declarations of ``LabbookEntry``: If the data model depends on record types or properties which already exist in CaosDB, those can be added using the ``extern`` keyword: ``extern`` takes a list of previously defined names. + + Datatypes ---------- +========= You can use any data type understood by CaosDB as datatype attribute in the yaml model. @@ -90,7 +96,7 @@ would declare a list of elements with datatype Project. Keywords --------- +======== - **parent**: Parent of this entity. - **importance**: Importance of this entity. Possible values: "recommended", "obligatory", "suggested" @@ -105,7 +111,7 @@ Keywords - **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: @@ -124,3 +130,6 @@ the model with a CaosDB instance, e.g.: .. code-block:: python model.sync_data_model() + +.. LocalWords: yml projectId UID firstName lastName LabbookEntry entryId textElement labbook +.. LocalWords: associatedFile extern Textfile DataModel diff --git a/unittests/test_base_table_exporter.py b/unittests/test_base_table_exporter.py index 3b8276cdf947c5b22e829e050295dd47f3cfe9ea..8a65b71aa489f8fca457c0e700452a6dc5956eed 100644 --- a/unittests/test_base_table_exporter.py +++ b/unittests/test_base_table_exporter.py @@ -82,13 +82,13 @@ def test_simple_record(): assert my_exporter.prepare_csv_export( delimiter='\t', print_header=True) == "Test_Prop_1\tTest_Prop_2\nbla\tblabla" # remove optional entry from info - del(my_exporter.info["Test_Prop_2"]) + del my_exporter.info["Test_Prop_2"] assert my_exporter.prepare_csv_export(skip_empty_optionals=True) == "bla" assert my_exporter.prepare_csv_export( delimiter='\t', print_header=True) == "Test_Prop_1\tTest_Prop_2\nbla\t" # reload info, and delete mandatory entry my_exporter.collect_information() - del(my_exporter.info["Test_Prop_1"]) + del my_exporter.info["Test_Prop_1"] with raises(te.TableExportError) as exc: my_exporter.prepare_csv_export() assert "Test_Prop_1" in exc.value.msg @@ -184,7 +184,7 @@ def test_info_collection(): assert "optional_value" not in my_exporter.info # now error in mandatory value - del(export_dict["optional_value"]) + del export_dict["optional_value"] export_dict["mandatory_value"] = { "find_func": "find_function_with_error" }