-
Notifications
You must be signed in to change notification settings - Fork 1
Add entity_management_async #26
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #26 +/- ##
==========================================
- Coverage 80.98% 80.13% -0.85%
==========================================
Files 24 52 +28
Lines 1551 3206 +1655
==========================================
+ Hits 1256 2569 +1313
- Misses 295 637 +342 ☔ View full report in Codecov by Sentry. |
f84e134
to
80bc27a
Compare
More details about possible errors: in the example in the description, when a nested entity is accessed before it's instantiated, a RuntimeError is raised:
but the message can be made clearer, for example:
|
Minor: there is a bunch of warnings on |
Since we are not happy with the async API, I'm thinking to close this PR without merging, while keeping the branch as a prototype for future reference. |
This PR adds async code to allow using entity_management in async code without using threads or subprocesses.
Structure:
Usage:
The async classes are similar to sync classes, but to automatically resolve the lazy attributes (linked Identifiables that need to be retrieved from Nexus) we need to explicitly await them.
Awaiting the same attribute multiple times doesn't have any effect (i.e. the attribute is not retrieved from Nexus multiple times)
Usage example:
Pros:
Cons:
Comparison with SQLAlchemy approaches:
awaitable_attrs
attribute.from_id
orfrom_url
, they could be specified and all eagerly retrieved immediately.Documentation: it should be updated after discussion.