bluesky / suitcase-tiff

http://nsls-ii.github.io/suitcase
Other
3 stars 6 forks source link

REF: Use the Manager's close method. #8

Closed danielballan closed 5 years ago

codecov-io commented 5 years ago

Codecov Report

Merging #8 into master will increase coverage by 0.11%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #8      +/-   ##
==========================================
+ Coverage   95.18%   95.29%   +0.11%     
==========================================
  Files           3        3              
  Lines          83       85       +2     
  Branches       14       14              
==========================================
+ Hits           79       81       +2     
  Misses          2        2              
  Partials        2        2
Impacted Files Coverage Δ
suitcase/tiff/__init__.py 94.02% <100%> (+0.18%) :arrow_up:

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 579a168...aa48522. Read the comment docs.

licode commented 5 years ago

LGTM. It is more consistent now to use self.manager for both file open and close.

awalter-bnl commented 5 years ago

I will need to check if this actually works. There is a whole lot of state inside the tifffile.Tiffwriter obnject that needs to be cleaned up first, that is why in this case I did not use the manager.close() function

danielballan commented 5 years ago

That would suggest to me that you would need additional code in close() from what is there now, then. But having the manager close the files it opened vs having the serializer do the same should be equivalent.

awalter-bnl commented 5 years ago

So I just confirmed this does not actually work (by manual testing), if you have more than one image per file (say by generating a run using count(det, num=5) ) then only the first image is stored in the output file if closing using self.manager.close().

There is extra processes that occur in the tifffile.Tiffwriter objects close call that cleans up the appending of the other images

To be clear this is a breaking change and should not be merged without a solution

danielballan commented 5 years ago

Can you explain the difference? I'm not seeing it. I think the manager holds a reference to all the file handles, and so does the serializer. Either one could loop through those file handles and call file.close() on each one. It does not matter where it's the serializer or the manager that does it.

awalter-bnl commented 5 years ago

the serializer holds a reference to the tifffile.Tiffwriter objects not the file objects that are associated with the manager. see this line.

https://github.com/NSLS-II/suitcase-tiff/blob/124795befe4b2202437f7b1eb9b6091e573f65b1/suitcase/tiff/__init__.py#L252

closing the tiffile.TiffWriter object performs extra cleanup not done by calling close on the file object.

danielballan commented 5 years ago

Ah ha! Thanks for explaining. You are right.

awalter-bnl commented 5 years ago

no problem, I will put through a new PR later this afternoon with a better test that will catch this issue in the future !-)

I am happy with these changes now.

danielballan commented 5 years ago

@licode Can you take one more look at this and merge?

licode commented 5 years ago

LGTM. We need two steps on closing files.