Skip to content

Conversation

@sud0woodo
Copy link
Contributor

@sud0woodo sud0woodo commented Apr 9, 2024

Due to a misinterpretation of the length argument of shutil.copyfileobj, it was being wrongly used. Using RangeStream here will give the correct behaviour.

Added the use of a RangeStream for the _write_block function in the
AsdfWriter. This allows to write ASDF files given a list of blocks. For
some reason it would not update the offset and keep seeking to the same
offset within the given range, using the RangeStream as a source for
shutil.copyfileobj fixes this.
@codecov-commenter
Copy link

codecov-commenter commented Apr 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.03%. Comparing base (d3ebc32) to head (be15db2).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #28   +/-   ##
=======================================
  Coverage   64.03%   64.03%           
=======================================
  Files          11       11           
  Lines        1012     1012           
=======================================
  Hits          648      648           
  Misses        364      364           
Flag Coverage Δ
unittests 64.03% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

After digging into it somewhat deeper it turns out that the way we use
`shutil.copyobj` was wrong and the `size` argument was interpreted
differently. Using the `RangeStream` still fixes the issue that we only
read a specified length of bytes, whilst before the `size` argument was
interpreted as the size that the buffer should have after reading whilst
this is actually the block size for reading the bytes.

Removed the `size` as an argument to `shutil.copyobj`, using
`RangeStream` to make sure we read the specified amount of bytes in
`size`.
@Schamper Schamper changed the title Add RangeStream to _write_block for ASDF Use RangeStream when writing a block to ASDF Apr 10, 2024
@Schamper Schamper merged commit b41eb09 into main Apr 10, 2024
@Schamper Schamper deleted the add-rangestream-to-asdf-write-block branch April 10, 2024 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants