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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5794 download file redux #5987

Merged
merged 30 commits into from
Jun 12, 2023
Merged

5794 download file redux #5987

merged 30 commits into from
Jun 12, 2023

Conversation

orangewolf
Copy link
Member

Fixes #5794 ; Depends on merge of #5626

Adopts surfliner's DownloadsController and uses it when using valkyrie. Allows download of files stored in a valkyrie storage adapter.

file_metadata = find_file_metadata(file_set: file_set, use: use)
file = Hyrax.storage_adapter.find_by(id: file_metadata.file_identifier)
prepare_file_headers_valkyrie(metadata: file_metadata, file: file)
file.rewind
Copy link
Member Author

Choose a reason for hiding this comment

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

this does appear to load the file in to memory: https://share.getcloudapp.com/Blub19om
I used this code to evaluate before and after the rewind

    module MemInfo
      # This uses backticks to figure out the pagesize, but only once
      # when loading this module.
      # You might want to move this into some kind of initializer
      # that is loaded when your app starts and not when autoload
      # loads this module.
      KERNEL_PAGE_SIZE = `getconf PAGESIZE`.chomp.to_i rescue 4096
      STATM_PATH       = "/proc/#{Process.pid}/statm"
      STATM_FOUND      = File.exist?(STATM_PATH)

      def self.rss
        STATM_FOUND ? (File.read(STATM_PATH).split(' ')[1].to_i * KERNEL_PAGE_SIZE) / 1024 : 0
      end
    end

@orangewolf
Copy link
Member Author

orangewolf commented Mar 24, 2023

just a note. specs are working in pg now, but failing in dassie / non-valkerie. need to figure out how to have all three.

@no-reply
Copy link
Contributor

@orangewolf is this something it would be helpful for me to carry over the line today/tomorrow?

@orangewolf
Copy link
Member Author

@orangewolf is this something it would be helpful for me to carry over the line today/tomorrow?

@no-reply for sure - I'm sorry I missed your earlier comment. I'm out on vacation. I haven't had time to figure out why the specs are mad.

@no-reply
Copy link
Contributor

i think the remaining issue here is that the test setup on the valkyrie specs isn't valid for AF/Wings. an easy fix for this could be to simply not use this controller behavior when Wings is in use, and skip the tests under those conditions.

i think in that case we're missing test coverage for Valkyrie altogether, though, since use_valkyrie is only true in our test suite when Wings is in use.

@orangewolf
Copy link
Member Author

orangewolf commented May 20, 2023

@no-reply i agree with you. There isn’t really a Valkyrie pg test set up. Do you or @dlpierce have to circleci knowledge to easily create one? If so, I’m tempted to say we do so and then I can task a junior to mark the failures pending if and only if they are use_Valkyrie and not wings. That lets us get green and move in to the new Valkyrie work (which starts issue review and testing on Monday) with a functioning test suite we can add to.

@dlpierce
Copy link
Contributor

@orangewolf I'll propose getting Circle setup for this testing as a topic for this week's dev con that I'll lead.

…specifies Ruby version, we should not also specify in the Gemfile. Only listing it once makes it easier to update correctly and also means changing the Dockerfile ARG can actually build the app successfully.
@alishaevn
Copy link
Contributor

surfliner version of downloads_controller_spec.rb

@dlpierce
Copy link
Contributor

These remaining spec failures where describedby is nil seem to point to the AF::File/Hyrax::FileMetadata conversion being incomplete. The spec for persisting a file is a stub. I expect this is due to the special handling for some File metadata, as mention in the commit.

I suggest making sure the Hyrax::FileSet factory can correctly use its with_files trait to create valid Files.

@alishaevn alishaevn mentioned this pull request Jun 5, 2023
2 tasks
@orangewolf
Copy link
Member Author

These remaining spec failures where describedby is nil seem to point to the AF::File/Hyrax::FileMetadata conversion being incomplete. The spec for persisting a file is a stub. I expect this is due to the special handling for some File metadata, as mention in the commit.

I suggest making sure the Hyrax::FileSet factory can correctly use its with_files trait to create valid Files.

I spent a lot of time trying to get the specs to persist files properly. I got it almost working, but then realized that it slowed the specs way down. So instead we'll use the test adapters for this spec. That keeps it speedy and keeps it focused on testing the Valkyrie controller logic and not on testing the underlying library.

@orangewolf orangewolf marked this pull request as ready for review June 8, 2023 00:26
@orangewolf
Copy link
Member Author

@dlpierce this is down to just non-related flaky specs. are you ok with the proposed testing solution?

@orangewolf orangewolf requested a review from dlpierce June 8, 2023 00:50
alishaevn
alishaevn previously approved these changes Jun 8, 2023
orangewolf and others added 3 commits June 9, 2023 15:56
…cted them to be. this was due to Valkyrie using a different pairtree method than Hyrax
…o-find-than-wifes-headphones

thumbnails and other derivatives were not stored in the path we expected them to be
@dlpierce dlpierce merged commit ab19e4c into main Jun 12, 2023
@dlpierce dlpierce deleted the 5794-download_file-redux branch June 12, 2023 23:16
@dlpierce dlpierce added the notes-valkyrie Release Notes: Valkyrie specific label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notes-valkyrie Release Notes: Valkyrie specific
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Works view page - Items Actions - Download not working
5 participants