OregonDigital / hyrax-migrator

A Rails engine to facilitate migrating works into a Hyrax based application
MIT License
0 stars 0 forks source link

update work service/actor #171

Closed lsat12357 closed 3 years ago

lsat12357 commented 4 years ago

thinking ahead to dealing with assets that are edited after they've been migrated; possibly an actor/service that calls the hyrax actor stack with update instead of create; use a modified version of the default migrator stack that includes the new actor/service.

lsat12357 commented 3 years ago

possible workflow for metadata changes: on od1 rerun metadata profiler on od2 run short version of the stack--instead of 'default' called 'update,' eg does not include file_upload uses new persist migrator actor/service similar to the add_relationships, i.e. calls HyraxCore::ActorStack with :update

lsat12357 commented 3 years ago

other classes that would need tweaks or adding: it is already possible to add a custom stack in the options arg in BagIngestService, this gets passed along until MigrateWorkService uses it but BagIngestService skips works that have status == 'success' so one option would be to run a task that changes the status to 'update' ? before launching the ingest service it might still be nice to just rerun a batch without having to cherry pick the ones that actually have changes so for the crosswalk actor/service, same service but an updater actor, which compares the new crosswalk with the old one in the env, and flags if there is a change as it updates the env the new persist actor would only submit assets that have the flag.

lsat12357 commented 3 years ago

QA: to prepare: select an asset that has already been migrated, find its bag, make some changes to the nt and update the bag require 'bagit' bag = BagIt::Bag.new(path_to_bag) info = bag.bag_info info['Bagging-Date'] = Date.today.strftime("%Y-%m-%d") bag.write_bag_info info bag.tagmanifest! bag.manifest!

make a note of the batch the bag belongs to to run update: middleware = {actor_stack: ['Hyrax::Migrator::Actors::CrosswalkMetadataActor', 'Hyrax::Migrator::Actors::UpdateWorkActor']} b = Hyrax::Migrator::Services::BatchUpdateService.new(batchname, {middleware_config: middleware }) b.update

lsat12357 commented 3 years ago

QA fail, bug introduced when handling deleted metadata

wickr commented 3 years ago

QA pass. Updated date in bag's metadata of https://staging.oregondigital.org/concern/images/df7135516?locale=en and work was updated.

irb(main):001:0> require 'bagit'
=> false
irb(main):002:0> bag = BagIt::Bag.new('/od2_migration/textile-and-apparel/df7135516/')
=> #<BagIt::Bag:0x0000560b7289cd48 @bag_dir="/od2_migration/textile-and-apparel/df7135516/">
irb(main):003:0> info = bag.bag_info
=> {"Bag-Software-Agent"=>"BagIt Ruby Gem (http://bagit.rubyforge.org)", "Bagging-Date"=>"2020-10-12", "Payload-Oxum"=>"8945146.8"}
irb(main):004:0> info['Bagging-Date'] = Date.today.strftime("%Y-%m-%d")
=> "2021-10-27"
irb(main):005:0> bag.write_bag_info info
=> {"Bag-Software-Agent"=>"BagIt Ruby Gem (http://bagit.rubyforge.org)", "Bagging-Date"=>"2021-10-27", "Payload-Oxum"=>"8945146.8"}
irb(main):006:0> bag.tagmanifest!
=> ["/od2_migration/textile-and-apparel/df7135516/bag-info.txt", "/od2_migration/textile-and-apparel/df7135516/bagit.txt", "/od2_migration/textile-and-apparel/df7135516/manifest-sha1.txt", "/od2_migration/textile-and-apparel/df7135516/manifest-md5.txt"]
irb(main):007:0> bag.manifest!
=> ["/od2_migration/textile-and-apparel/df7135516/bag-info.txt", "/od2_migration/textile-and-apparel/df7135516/bagit.txt", "/od2_migration/textile-and-apparel/df7135516/manifest-sha1.txt", "/od2_migration/textile-and-apparel/df7135516/manifest-md5.txt"]

od2:

irb(main):001:0> middleware = {actor_stack: ['Hyrax::Migrator::Actors::CrosswalkMetadataActor', 'Hyrax::Migrator::Actors::UpdateWorkActor']}
=> {:actor_stack=>["Hyrax::Migrator::Actors::CrosswalkMetadataActor", "Hyrax::Migrator::Actors::UpdateWorkActor"]}
irb(main):002:0> b = Hyrax::Migrator::Services::BatchUpdateService.new('textile-and-apparel', {middleware_config: middleware })
=> #<Hyrax::Migrator::Services::BatchUpdateService:0x000055adff366458 @options={:middleware_config=>{:actor_stack=>["Hyrax::Migrator::Actors::CrosswalkMetadataActor", "Hyrax::Migrator::Ac...
irb(main):003:0> b.update
...
D, [2021-10-27T22:15:45.583209 #7424] DEBUG -- :   Hyrax::Migrator::Work Update (2.1ms)  UPDATE "hyrax_migrator_works" SET "updated_at" = $1, "aasm_state" = $2, "status" = $3 WHERE "hyrax_migrator_works"."id" = $4  [["updated_at", "2021-10-28 05:15:45.580430"], ["aasm_state", "crosswalk_metadata_initial"], ["status", "update"], ["id", 336]]
D, [2021-10-27T22:15:45.588077 #7424] DEBUG -- :    (2.4ms)  COMMIT
I, [2021-10-27T22:15:45.594184 #7424]  INFO -- : [ActiveJob] Enqueued Hyrax::Migrator::Jobs::MigrateWorkJob (Job ID: 78da3ec1-dd6a-426e-a52c-4407c5ed351b) to Sidekiq(hyrax_migrator) with arguments: {:pid=>"df7135516", :file_path=>"/od2_migration/textile-and-apparel/df7135516", :update=>true, :middleware_config=>{:actor_stack=>["Hyrax::Migrator::Actors::CrosswalkMetadataActor", "Hyrax::Migrator::Actors::UpdateWorkActor"]}}
=> {"textile-and-apparel"=>["/od2_migration/textile-and-apparel/df713543h", "/od2_migration/textile-and-apparel/df713460z", "/od2_migration/textile-and-apparel/df7135495", "/od2_migration/textile-and-apparel/df713538n", "/od2_migration/textile-and-apparel/df713450q", "/od2_migration/textile-and-apparel/df713553r", "/od2_migration/textile-and-apparel/df713548w", "/od2_migration/textile-and-apparel/df713552g", "/od2_migration/textile-and-apparel/df713463s", "/od2_migration/textile-and-apparel/df713540p", "/od2_migration/textile-and-apparel/df713531q", "/od2_migration/textile-and-apparel/df713529p", "/od2_migration/textile-and-apparel/df713526v", "/od2_migration/textile-and-apparel/df7134642", "/od2_migration/textile-and-apparel/df713534j", "/od2_migration/textile-and-apparel/df713454t", "/od2_migration/textile-and-apparel/df713535t", "/od2_migration/textile-and-apparel/df7135363", "/od2_migration/textile-and-apparel/df7135452", "/od2_migration/textile-and-apparel/df7135516"]}