-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🎁 Introduce .named_derivatives_and_generators_filter #306
Merged
kirkkwang
merged 1 commit into
main
from
introduce-predicate-configuration-for-iiif-print
Nov 29, 2023
Merged
🎁 Introduce .named_derivatives_and_generators_filter #306
kirkkwang
merged 1 commit into
main
from
introduce-predicate-configuration-for-iiif-print
Nov 29, 2023
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
3fc7a2e
to
b2c0220
Compare
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
b2c0220
to
0183b78
Compare
kirkkwang
approved these 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.
Worked for me!
kirkkwang
added a commit
to notch8/adventist-dl
that referenced
this pull request
Nov 29, 2023
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
added a commit
to notch8/adventist-dl
that referenced
this pull request
Nov 29, 2023
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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:
DerivativeRodeoService.named_derivatives_and_generators_filter
clone
of attributesThe 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:
If I then call the following:
Then look at
nested_hash
, I will see the following: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: