Open jerry-kobold opened 16 hours ago
Maybe assert should be
assert self.final or can_flush(write)
From what I can tell that's basically the same thing as what I did, right? Happy to make a PR for this if it would help.
edit: would it make more sense to move the if self.final
check to the top of can_flush
so that condition gets evaluated first? Or is there a scenario where that could cause problems?
At my company we have been using
save_cog_with_dask
very heavily to produce COGs from very large rasters. For certain raster/chunk combinations we have observed the function failing with anAssertionError
. I did some digging and isolated the problem to the following code:It seems that for certain combinations of raster dimensions and chunking scheme, a situation can arise in which
self.write_credits
is0
but the write has not completed. The following code below should reproduce the problem:The dimensions in this example were chosen because they match the dimensions of an actual raster for which this problem arose with this specific chunking. Using the time-honored method of
distributed.print
-based debugging, I isolated the error to the line that checks forself.write_credits < 1
. Playing around with the source, I noticed that changing this line tomakes the error go away and nothing else seems to break, but I don't know if that's the right decision or not.