Skip to content
Snippets Groups Projects
Commit 67371bad authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

Merge branch 'f-extern2' into 'dev'

MAINT: further tests and docs

See merge request !19
parents 98da8ac3 921dc85e
No related branches found
No related tags found
2 merge requests!22Release 0.3,!19MAINT: further tests and docs
Pipeline #15569 passed
......@@ -31,7 +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
* AbtractCFood has new property, `update_flags`.
- AbtractCFood has new property, `update_flags`.
### Changed ###
......
......@@ -5,6 +5,13 @@ from caosadvancedtools.cfoods.h5 import H5CFood
from caosadvancedtools.models.data_model import DataModel
from caosadvancedtools.models.parser import parse_model_from_yaml
def main():
# for testing existing data model parts with the YAML 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)
......@@ -14,9 +21,13 @@ if len(db.execute_query("FIND Property alias")) == 0:
al.insert()
h5model = db.Container()
h5file = h5py.File('extroot/ExperimentalData/2010_TestProject/2019-02-03/hdf5_dummy_file.hdf5', 'r')
h5file = h5py.File(
'extroot/ExperimentalData/2010_TestProject/2019-02-03/hdf5_dummy_file.hdf5', 'r')
H5CFood.create_structure(h5file, create_recordTypes=True, collection=h5model,
root_name="ExampleH5")
print(h5model)
h5model = DataModel(h5model)
h5model.sync_data_model(noquestion=True)
if __name__ == "__main__":
main()
......@@ -69,3 +69,6 @@ Report:
- Publication
hdf5File:
datatype: REFERENCE
extern:
- TestRT1
- TestP1
......@@ -34,6 +34,8 @@ from caosadvancedtools.models.parser import parse_model_from_yaml
from caosadvancedtools.scifolder import (AnalysisCFood, ExperimentCFood,
PublicationCFood, SimulationCFood)
from insert_model import main as insert_model
def setup_module():
"""Clear problems and remove all entities except for built-in ones."""
......@@ -67,8 +69,7 @@ def test_crawler_with_data_model_problems():
prefix="", dryrun=False, forceAllowSymlinks=False)
# load and damage the model
model = parse_model_from_yaml("model.yml")
model.sync_data_model(noquestion=True)
insert_model()
deleted_entities = {"Experiment", "Poster", "results"}
for ent in deleted_entities:
......
......@@ -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
---------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment