Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD] only shelve WAS files via ShelveJob #5076

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

lwrubel
Copy link
Contributor

@lwrubel lwrubel commented Jun 7, 2024

Why was this change made? 馃

Resolves #5072 for shelving web archiving files only. HOLD because we must be using purl-fetcher for shelving all other files in production before merging.

How was this change tested? 馃え

Unit and integration tests on stage.

@@ -67,6 +68,7 @@ RSpec/Be:
RSpec/BeforeAfterAll:
Exclude:
- 'spec/services/digital_stacks_service_spec.rb'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there are TODOs for files that you deleted.

Is it possible to not add any new TODOs? Either disable the rules if will never enforce or add inline disables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching those deleted files. Disabled rules.

end

def initialize(cocina_object)
raise ConfigurationError, 'Missing configuration Settings.stacks.local_workspace_root' if Settings.stacks.local_workspace_root.nil?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just raise StandardError here; no reason to create a special error class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


def initialize(cocina_object)
raise ConfigurationError, 'Missing configuration Settings.stacks.local_workspace_root' if Settings.stacks.local_workspace_root.nil?
raise WasShelvingService::WasShelvingError, 'Missing structural' if cocina_object.structural.nil?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would this happen? (Also, I would put this in the shelve method instead of the initializer.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a possible situation that was being handled when shelving other files, but since there is really only one pathway for web archive files to get accessioned, seems extremely unlikely. I've taken it out.


def initialize(cocina_object)
raise ConfigurationError, 'Missing configuration Settings.stacks.local_workspace_root' if Settings.stacks.local_workspace_root.nil?
raise WasShelvingService::WasShelvingError, 'Missing structural' if cocina_object.structural.nil?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would this happen? (Also, I would put this in the shelve method instead of the initializer.)

attr_reader :cocina_object, :druid

def shelve
# determine destination web archiving stacks location
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest moving these into methods to make this method clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that is an improvement. Moved the methods.

"/web-archiving-stacks/data/collections/#{collection_druid.delete_prefix('druid:')}"
end

def files_for(cocina_object)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cocina_object is an instance variable so no need to pass in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duh, thanks.


raise WasShelvingService::WasShelvingError, 'Web archive object missing collection' unless collection_druid

"/web-archiving-stacks/data/collections/#{collection_druid.delete_prefix('druid:')}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should /web-archiving-stacks be hardcoded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a setting for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also updated tests.

Rails.logger.debug("[Was Shelve] Copying #{workspace_pathname} to #{stacks_pathname}")
FileUtils.cp workspace_pathname.to_s, stacks_pathname.to_s
# Change permissions
FileUtils.chmod 'u=rw,go=r', stacks_pathname.to_s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we do this? (Can you add reason to L62?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some more testing, and I think that may not be a concern with web archiving stacks. Seems like the permissions were already as needed. I'll check again when testing on stage just to be sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked on stage and permissions are being set to 644. No need to change them.

@lwrubel lwrubel marked this pull request as ready for review June 10, 2024 19:51
Copy link
Contributor

@justinlittman justinlittman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve pending consideration of comments.

end

def initialize(cocina_object)
raise StandardError, 'Missing configuration Settings.stacks.local_workspace_root' if Settings.stacks.local_workspace_root.nil?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a default value in the settings. Would this ever happen?

Pathname(workspace_druid.content_dir(true))
end

def files_for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just call this filenames or similar. Usually it is x_for(some_parameter).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Thanks for the suggestion.

end

def was_stacks_dir
# determine destination web archiving stacks directory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be memoized since it is used multiple times.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

end

def workspace_content_dir
# determine current workspace location of object's content file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@lwrubel
Copy link
Contributor Author

lwrubel commented Jun 11, 2024

Be sure to squash when merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace existing shelving service with WARC-specific shelving service
2 participants