dags: Refactor fetch_images into a helper module#56
Conversation
awilfox
left a comment
There was a problem hiding this comment.
Self-reviewed to point out questions I had during implementation.
224c5da to
b8c9da8
Compare
|
v2:
|
anarchivist
left a comment
There was a problem hiding this comment.
looks good. all my questions/comments are minor and nonblocking. r+
b8c9da8 to
7e58d79
Compare
|
v3:
Need to write tests, then this should be good to go. |
7e58d79 to
530c5da
Compare
|
v4:
|
| if self.size_transform: | ||
| curr_size = self.size_transform(curr_size) | ||
|
|
||
| if self.max_size and curr_size > self.max_size: |
There was a problem hiding this comment.
Image size should scale roughly with the square of the change in side length, i.e. if you double the width you should naively expect the image size to quadruple. Ditto for shrinking: cutting the height of the image in half (while maintaining the aspect ratio) should reduce the image size to ~1/4 of the original (naively, ignoring resampling / compression). Obviously the reality is different but that would put a lower bound on the change.
There was a problem hiding this comment.
It should, but the IIIF endpoint sends a quality=2 (i.e. 100%) JPEG, so it balloons it quite heavily even with smaller dimensions than the original. A shame we cannot tweak that further.
There was a problem hiding this comment.
The only way to do this without naive calculations such as this would be to download a full-size version from IIIF so that we actually know the maximal byte size. But we would be doing that just to throw it away, using a lot of bandwidth and time in the process.
Happy to consider other ways to do this and discuss it further, but not sure it's worth it at this stage. Up to you.
530c5da to
da53224
Compare
|
v5:
|
da53224 to
a2a0dc4
Compare
|
v6:
|
a2a0dc4 to
95cdb20
Compare
|
v7:
|
We can reuse this code in many different ways by making it a fully parameterised class instead of embedded in the DAG. This also gives us a lot of flexibility in how we use it in the future. Ref: AP-670
95cdb20 to
0df33df
Compare
jason-raitz
left a comment
There was a problem hiding this comment.
r+ I love how much simpler this makes the fetch_images DAG!
I'm going to have to rework some of #677 after this gets merged.
We can reuse this code in many different ways by making it a fully parameterised class instead of embedded in the DAG.
This also gives us a lot of flexibility in how we use it in the future.
Ref: AP-670
I still need to write tests for this, but I wanted to make sure the overall API I wrote was actually good and not just a diphenhydramine-induced fever dream.