This repository has been archived by the owner on Oct 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
🎁 Only run thumbnail derivatives on thumbnails #684
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jeremyf
reviewed
Nov 29, 2023
jeremyf
suggested changes
Nov 29, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a concern about values being deleted and having an impact.
jeremyf
reviewed
Nov 29, 2023
Ah understood, I thought each run was pretty well scoped to the file at play so it seemed like it shouldn't have side effects for the next file that comes through. I'd like to hear your thoughts. in a different iteration i had def create_derivatives(filename)
named_derivatives_and_generators.flat_map do |named_derivative, generator_name|
return if named_derivative == :json && filename.downcase.ends_with?(Hyku::THUMBNAIL_FILE_SUFFIX)
lasso_up_some_derivatives(
named_derivative: named_derivative,
generator_name: generator_name,
filename: filename
)
end
end |
jeremyf
added a commit
to notch8/iiif_print
that referenced
this pull request
Nov 29, 2023
Prior to this commit, IIIF Print assumed that every file of a given mime-type would use all of the same generators. However, that is not necessarily the case. With this commit: - Updated documentation based on a read of the generated Yardoc - Added `DerivativeRodeoService.named_derivatives_and_generators_filter` - Added a `clone` of attributes The clone is in place to help ensure that as we apply the filter we don't accidentally delete the application's configuration for mime category and expected derivatives. For example, let's say I have the following nested hash: ```ruby nested_hash = { pdf: { thumbnail: "DerivativeRodeo::Generators::ThumbnailGenerator" }, image: { thumbnail: "DerivativeRodeo::Generators::ThumbnailGenerator", json: "DerivativeRodeo::Generators::WordCoordinatesGenerator", xml: "DerivativeRodeo::Generators::AltoGenerator", txt: "DerivativeRodeo::Generators::PlainTextGenerator" } } ``` If I then call the following: ```ruby nested_hash.fetch(:pdf).delete_if { |key, value| key == :thumbnail } ``` Then look at `nested_hash`, I will see the following: ```ruby pp nested_hash {:pdf=>{}, :image=> {:thumbnail=>"DerivativeRodeo::Generators::ThumbnailGenerator", :json=>"DerivativeRodeo::Generators::WordCoordinatesGenerator", :xml=>"DerivativeRodeo::Generators::AltoGenerator", :txt=>"DerivativeRodeo::Generators::PlainTextGenerator"}} ``` Why? Because we haven't changed objects. It's possible that Rails's class_attribute will do deep clones of hashes, but with this clone behavior we remove that possibility of a problem. Related to: - notch8/adventist-dl#684 - https://github.com/scientist-softserv/adventist-dl/issues/676
In that updated iteration, instead of Note, I've added notch8/iiif_print#306 which provides a configurable point instead of a decorator point. |
jeremyf
added a commit
to notch8/iiif_print
that referenced
this pull request
Nov 29, 2023
Prior to this commit, IIIF Print assumed that every file of a given mime-type would use all of the same generators. However, that is not necessarily the case. With this commit: - Updated documentation based on a read of the generated Yardoc - Added `DerivativeRodeoService.named_derivatives_and_generators_filter` - Added a `clone` of attributes The clone is in place to help ensure that as we apply the filter we don't accidentally delete the application's configuration for mime category and expected derivatives. For example, let's say I have the following nested hash: ```ruby nested_hash = { pdf: { thumbnail: "DerivativeRodeo::Generators::ThumbnailGenerator" }, image: { thumbnail: "DerivativeRodeo::Generators::ThumbnailGenerator", json: "DerivativeRodeo::Generators::WordCoordinatesGenerator", xml: "DerivativeRodeo::Generators::AltoGenerator", txt: "DerivativeRodeo::Generators::PlainTextGenerator" } } ``` If I then call the following: ```ruby nested_hash.fetch(:pdf).delete_if { |key, value| key == :thumbnail } ``` Then look at `nested_hash`, I will see the following: ```ruby pp nested_hash {:pdf=>{}, :image=> {:thumbnail=>"DerivativeRodeo::Generators::ThumbnailGenerator", :json=>"DerivativeRodeo::Generators::WordCoordinatesGenerator", :xml=>"DerivativeRodeo::Generators::AltoGenerator", :txt=>"DerivativeRodeo::Generators::PlainTextGenerator"}} ``` Why? Because we haven't changed objects. It's possible that Rails's class_attribute will do deep clones of hashes, but with this clone behavior we remove that possibility of a problem. Related to: - notch8/adventist-dl#684 - https://github.com/scientist-softserv/adventist-dl/issues/676
jeremyf
added a commit
to notch8/iiif_print
that referenced
this pull request
Nov 29, 2023
Prior to this commit, IIIF Print assumed that every file of a given mime-type would use all of the same generators. However, that is not necessarily the case. With this commit: - Updated documentation based on a read of the generated Yardoc - Added `DerivativeRodeoService.named_derivatives_and_generators_filter` - Added a `clone` of attributes The clone is in place to help ensure that as we apply the filter we don't accidentally delete the application's configuration for mime category and expected derivatives. For example, let's say I have the following nested hash: ```ruby nested_hash = { pdf: { thumbnail: "DerivativeRodeo::Generators::ThumbnailGenerator" }, image: { thumbnail: "DerivativeRodeo::Generators::ThumbnailGenerator", json: "DerivativeRodeo::Generators::WordCoordinatesGenerator", xml: "DerivativeRodeo::Generators::AltoGenerator", txt: "DerivativeRodeo::Generators::PlainTextGenerator" } } ``` If I then call the following: ```ruby nested_hash.fetch(:pdf).delete_if { |key, value| key == :thumbnail } ``` Then look at `nested_hash`, I will see the following: ```ruby pp nested_hash {:pdf=>{}, :image=> {:thumbnail=>"DerivativeRodeo::Generators::ThumbnailGenerator", :json=>"DerivativeRodeo::Generators::WordCoordinatesGenerator", :xml=>"DerivativeRodeo::Generators::AltoGenerator", :txt=>"DerivativeRodeo::Generators::PlainTextGenerator"}} ``` Why? Because we haven't changed objects. It's possible that Rails's class_attribute will do deep clones of hashes, but with this clone behavior we remove that possibility of a problem. Related to: - notch8/adventist-dl#684 - https://github.com/scientist-softserv/adventist-dl/issues/676
kirkkwang
force-pushed
the
i676-only-run-thumbnail-on-thumbnails
branch
from
November 29, 2023 18:02
94914f7
to
358d694
Compare
We were seeing that our thumbnail files were getting word coordinates derivatives, which is a waste of processing time. The jobs would eventually fail but ideally we don't want them to run at all for thumbnails. This commit will upgrade to the latest version of IIIF Print where a new configurable class attribute has been added to enable a more granular control over which derivatives are run on what files. Also in this commit, we were seeing a nilClass error for a logger in development, so that has also been fixed. Ref: - https://github.com/scientist-softserv/adventist-dl/issues/676 - notch8/iiif_print#306
kirkkwang
force-pushed
the
i676-only-run-thumbnail-on-thumbnails
branch
from
November 29, 2023 18:09
358d694
to
aab7d39
Compare
jeremyf
approved these changes
Nov 29, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We were seeing that our thumbnail files were getting word coordinates derivatives, which is a waste of processing time. The jobs would eventually fail but ideally we don't want them to run at all for thumbnails.
This commit will override the
DerivativeRodeoService
and remove all other derivatives except for thumbnails if our file is a thumbnail file.Also in this commit, we were seeing a nilClass error for a logger in development, so that has also been fixed.
Ref: