spacetx / slicedimage

MIT License
7 stars 3 forks source link

Switch write path to transact in URLs #109

Closed ttung closed 5 years ago

ttung commented 5 years ago

Previously, the read path for slicedimage operated with URLs. This allowed us to have manifests on local disk that referred to network resources for tiles. This PR will use URLs as the destination for manifest files and tile data.

This PR also changes the way users can control the behavior of writing. Previously, we allowed for two callbacks: one allowed callers to designate where a sub-manifest is located on disk, and the other allowed callers to open a file for writing tile data. This turns out not to capture all the use cases for how we might want to control writing, so this PR creates WriterContract. It has three callbacks: one to designate where a sub-manifest is located in URL-space, another to designate where a tile is located in URL space, and one to write tile data to a URL.

Furthermore, we provide a CompatibilityWriterContract that mostly mimics the behavior of the old callbacks. The one notable exception is that the tricks utilized to perform in-place tile writing no longer work. CompatibilityWriterContract finds the destination in tile_url_generator by opening the tile data file, find out where it is on disk, and then closing the file. The new callback (write_tile_data) just opens the path and writes to it. There is not a way to maintain the file handle between tile_url_generator and write_tile_data.

Because this is a slight change in behavior, we bump the version of the library to 4.0.0.

Test plan: verified existing tests pass. verify existing starfish imagestack and experiment tests pass with this library (except for in-place tile construction). verify that the new in-place code for starfish passes with this library.

codecov-io commented 5 years ago

Codecov Report

Merging #109 into master will decrease coverage by 3.57%. The diff coverage is 51.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #109      +/-   ##
==========================================
- Coverage   78.96%   75.38%   -3.58%     
==========================================
  Files          29       29              
  Lines         832      902      +70     
==========================================
+ Hits          657      680      +23     
- Misses        175      222      +47
Impacted Files Coverage Δ
slicedimage/io/__init__.py 100% <100%> (ø) :arrow_up:
slicedimage/__init__.py 100% <100%> (ø) :arrow_up:
slicedimage/backends/_disk.py 100% <100%> (+4.76%) :arrow_up:
slicedimage/io/_v0_0_0.py 95.55% <100%> (-0.41%) :arrow_down:
slicedimage/io/_v0_1_0.py 58.24% <20%> (+3.24%) :arrow_up:
slicedimage/io/_base.py 58.75% <48.07%> (-25.98%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9a84941...3273775. Read the comment docs.