Skip to content
Snippets Groups Projects

F refactor high level api

Merged Alexander Schlemmer requested to merge f-refactor-high-level-api into dev

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.

Edited by Henrik tom Wörden

Merge request reports

Pipeline #22008 passed

Pipeline: LinkAhead

#22009

    Pipeline passed for f116a460 on f-refactor-high-level-api

    Approval is optional

    Merged by Henrik tom WördenHenrik tom Wörden 3 years ago (Apr 22, 2022 9:23am UTC)

    Merge details

    • Changes merged into dev with d355c12a.
    • Deleted the source branch.
    • Auto-merge enabled

    Pipeline #22139 passed

    Pipeline: LinkAhead

    #22140

      Pipeline passed for d355c12a on dev

      Activity

      Filter activity
      • Approvals
      • Assignees & reviewers
      • Comments (from bots)
      • Comments (from users)
      • Commits & branches
      • Edits
      • Labels
      • Lock status
      • Mentions
      • Merge request status
      • Tracking
      136 122 return Entity
      137 123
      138 124
      139 class CaosDBPythonEntity(object):
    • Alexander Schlemmer changed the description

      changed the description

    • added 19 commits

      Compare with previous version

    • added 1 commit

      • 09c1d74b - MAINT: move doc file from f-merge-entities here

      Compare with previous version

    • 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

      Compare with previous version

    • added 8 commits

      Compare with previous version

    • 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,
    • 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

      Compare with previous version

    • Loading
    • Loading
    • Loading
    • Loading
    • Loading
    • Loading
    • Loading
    • Loading
    • Loading
    • Loading
    • Please register or sign in to reply
      Loading