samvera / hydra-works

A ruby gem implementation of the PCDM Works domain model based on the Samvera software stack
Other
24 stars 14 forks source link

Move Hydra::Derivatives.output_file_service to initializer/configuration #315

Closed jeremyf closed 2 years ago

jeremyf commented 7 years ago

The following line is creating a problem when attempting to move an upstream setting of Hydra::Derivatives.source_file_service to an initializer:

https://github.com/projecthydra/hydra-works/blob/d0e87d017c20ffbecbaeda8c09b376747b9cdebc/lib/hydra/works/models/concerns/file_set/derivatives.rb

Ideally, the override would occur as part of a configuration. I attempted this in Hyrax, and encountered the following error in Hyrax tests:

Failures:

  1) IngestFileJob with two existing versions from different users has two versions
     Failure/Error: yield ::File.open(file_name)

     KeyError:
       key not found: :object
     # ./app/services/hyrax/local_file_service.rb:7:in `call'
     # ./app/services/hyrax/file_set_derivatives_service.rb:60:in `create_image_derivatives'
     # ./app/services/hyrax/file_set_derivatives_service.rb:24:in `create_derivatives'
     # ./app/models/concerns/hyrax/file_set/derivatives.rb:11:in `create_derivatives'
     # ./app/jobs/create_derivatives_job.rb:11:in `perform'
     # ./app/jobs/characterize_job.rb:15:in `perform'
     # ./app/jobs/ingest_file_job.rb:35:in `perform'
     # ./spec/jobs/ingest_file_job_spec.rb:61:in `block (3 levels) in <top (required)>'

  2) CreateDerivativesJob with a pdf file searches the extracted content
     Failure/Error: yield ::File.open(file_name)

     KeyError:
       key not found: :object
     # ./app/services/hyrax/local_file_service.rb:7:in `call'
     # ./app/services/hyrax/file_set_derivatives_service.rb:31:in `create_pdf_derivatives'
     # ./app/services/hyrax/file_set_derivatives_service.rb:20:in `create_derivatives'
     # ./app/models/concerns/hyrax/file_set/derivatives.rb:11:in `create_derivatives'
     # ./app/jobs/create_derivatives_job.rb:11:in `perform'
     # ./spec/jobs/create_derivatives_job_spec.rb:88:in `block (3 levels) in <top (required)>'
     # ./spec/jobs/create_derivatives_job_spec.rb:7:in `block (2 levels) in <top (required)>'

What ended up happening is during the load sequence, the initializer first fired for Hyrax, then the include Hydra::Works::Derivatives fired.