Add close() and flush() methods to stream classes for full file-like compatibility#205
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #205 +/- ##
=======================================
Coverage 99.63% 99.63%
=======================================
Files 8 8
Lines 1932 1938 +6
=======================================
+ Hits 1925 1931 +6
Misses 7 7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I thought about implementing a protocol to enforce this somehow like it was done in #194. But in the end the bug comes from its usage in aiida-core where ignore the type error. I move the consideration of some enforcement through a protocol to PR #194 because I am not really sure what interface we want to enforce. EDIT: Looking at aiida-core, I think we could solve the issue by just implementing |
|
Ok, agreed with @agoscinski to merge this now and consider the |
These test on aiida-core are flaky
The flakiness comes down to whether objects are loose or packed in the disk-objectstore at the time the test reads from the repository. The point is disk-objectstore packs objects automatically when certain thresholds are reached.
If the packed object are returned they still should support close() and flush(), becausein aiida-core TextIOWrapper is used as a context manager, its exit calls close(), which propagates to the underlying stream.
The commit adda no-op close() and flush() methods to PackedObjectReader, CallbackStreamWrapper, and ZlibLikeBaseStreamDecompresser.
This was discovered in aiidateam/aiida-core#7206, where async changes results in different tests ordering or something resulting to this issue to pop out.
The methods are intentionally no-ops because these readers don't own the underlying file handles they read from.