diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a0d6cc5339fc1db13358a02e0f80be17ccef848..627ee4e4e96626a9228a0bf319c9d1725f7e31b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 h5py is now an optional dependency - table importer implementations for csv and tsv - string-in-list check for table imports +- Documentation and test for the `extern` keyword used by the YAML interface ### Changed ### diff --git a/integrationtests/insert_model.py b/integrationtests/insert_model.py index ae3dd7701b44f5008bd976d81f8ecc8d9a02bf89..d793b041549812aa00a030d5c7a456f45da66b09 100755 --- a/integrationtests/insert_model.py +++ b/integrationtests/insert_model.py @@ -5,6 +5,10 @@ from caosadvancedtools.cfoods.h5 import H5CFood from caosadvancedtools.models.data_model import DataModel from caosadvancedtools.models.parser import parse_model_from_yaml +# for teseting existing data model parts for the YANL Interface +db.RecordType(name="TestRT1", datatype=db.TEXT).insert() +db.Property(name="TestP1", datatype=db.TEXT).insert() + model = parse_model_from_yaml("model.yml") model.sync_data_model(noquestion=True) diff --git a/integrationtests/model.yml b/integrationtests/model.yml index e1753a9f84d6eff7a9a59c5d17ca4f9f9da7c4c6..cad7958803edf1a01f0649353443ffab350cc5e5 100644 --- a/integrationtests/model.yml +++ b/integrationtests/model.yml @@ -69,3 +69,6 @@ Report: - Publication hdf5File: datatype: REFERENCE +extern: + - TestRT1 + - TestP1 diff --git a/src/doc/yaml_interface.rst b/src/doc/yaml_interface.rst index 06248f2b5c17f40b6f15f5f55664c5a4a5530a86..dcf4c5d6c7a674bd8d32d92df0a509e511af26f5 100644 --- a/src/doc/yaml_interface.rst +++ b/src/doc/yaml_interface.rst @@ -39,6 +39,9 @@ Let's start with an example taken from https://gitlab.indiscale.com/caosdb/src/c table: datatype: FILE description: 'A table document associated with this recording' + extern: + - Textfile + This example defines 3 ``RecordType``s: @@ -46,6 +49,9 @@ This example defines 3 ``RecordType``s: - A ``Project`` with one obligatory property ``datatype`` - A Person with a ``firstName`` and a ``lastName`` (as recommended properties) - A ``LabbookEntry`` with multiple recommended properties of different data types +- It is assumed that the server knows a RecordType or Property with the name + "Textfile". + One major advantage of using this interface (in contrast to the standard python interface) is that properties can be defined and added to record types "on-the-fly". E.g. the three lines for ``firstName`` as sub entries of ``Person`` have two effects on CaosDB: @@ -60,6 +66,8 @@ Note the difference between the three property declarations of ``LabbookEntry``: - ``responsible``: This defines and adds a property with name "responsible" to ``LabbookEntry`, which has a datatype ``Person``. ``Person`` is defined above. - ``firstName``: This defines and adds a property with the standard data type ``TEXT`` to record type ``Person``. +If the data model depends on already existing parts, those can be added using the ``extern`` keyword. + Datatypes ---------