F refactor high level api
Summary
This is a new version of the old high level API that was previously contained in apiutils. I completely refactored the structure of the entities, to make use of more up-to-date concepts:
- Usage can be completely offline now (including resolving references), e.g. without a running CaosDB which also allows for comprehensive unit tests.
- Clear separation between resolved and unresolved Entities.
- Transparent yaml serialization and deserialization
- Planned: Transparent support for multi properties.
The main motivation for reactivating and refactoring this module was to facilitate usage of complex entities wihtin simulations and data analysis scripts.
Please also see the included documentation (to be expanded) and lots of unit tests with examples.
Note: This MR includes commits from f-plantuml, f-merge-entities and f-copy-entity, so please review the corresponding MRs first.
Test Environment
There are many unit tests supplied.
Please also test the resolve functions e.g. CaosDBPythonEntity.resolve_references() manually.
Integration tests will be handed in in a later release.
I recommend at least two independent reviewers and this MR is of course still open for discussions and suggestions.
Check List for the Author
-
All automated tests pass -
Reference related issues -
Up-to-date CHANGELOG.md (or not necessary) -
Annotations in code (Gitlab comments) - Intent of new code
- Problems with old code
- Why this implementation?
Check List for the Reviewer
-
I understand the intent of this MR -
All automated tests pass -
Up-to-date CHANGELOG.md (or not necessary) -
The test environment setup works and the intended behavior is reproducible in the test environment -
In-code documentation and comments are up-to-date. -
Check: Are there specifications? Are they satisfied?
For further good practices have a look at our review guidelines.
Merge request reports
Activity
added EnhancementProposed label
assigned to @salexan
mentioned in issue #110 (closed)
136 122 return Entity 137 123 138 124 139 class CaosDBPythonEntity(object): added 19 commits
-
4c8ba355...dd86fe37 - 18 commits from branch
dev
- f13660c0 - Merge branch 'dev' into f-refactor-high-level-api
-
4c8ba355...dd86fe37 - 18 commits from branch
added 1 commit
- 09c1d74b - MAINT: move doc file from f-merge-entities here
added 22 commits
-
09c1d74b...694f981c - 20 commits from branch
dev
- 6c1d336e - Merge branch 'dev' into f-refactor-high-level-api
- 15b7ecf7 - TST: allow tests to be called from src dir; import pytest
-
09c1d74b...694f981c - 20 commits from branch
added 8 commits
-
15b7ecf7...0cd4df88 - 7 commits from branch
dev
- 7f4a8c5b - Merge branch 'dev' into f-refactor-high-level-api
-
15b7ecf7...0cd4df88 - 7 commits from branch
- src/caosdb/high_level_api.py 0 → 100644
247 @description.setter 248 def description(self, val: str): 249 self._description = val 250 251 @property 252 def version(self): 253 """ 254 Getter for the version. 255 """ 256 return self._version 257 258 @version.setter 259 def version(self, val: str): 260 self._version = val 261 262 def _set_property_from_entity(self, ent: db.Entity, importance: str, - src/caosdb/high_level_api.py 0 → 100644
352 # if yes: Turn the attribute into a list and 353 # place all the elements into that list. 354 att = self.__getattribute__(name) 355 356 if isinstance(att, list): 357 # just append, see below 358 pass 359 else: 360 old_att = self.__getattribute__(name) 361 self.__setattr__(name, [old_att]) 362 att = self.__getattribute__(name) 363 att.append(value) 364 else: 365 self.__setattr__(name, value) 366 367 def __setattr__(self, name: str, val: Any): added 4 commits
-
7f4a8c5b...4916fd45 - 3 commits from branch
dev
- cf2e2d09 - Merge branch 'dev' into f-refactor-high-level-api
-
7f4a8c5b...4916fd45 - 3 commits from branch
added 1 commit
- de8b26c3 - DOC: added a real world example for high level API to the docs
enabled an automatic merge when the pipeline for f116a460 succeeds
mentioned in commit d355c12a