-
Notifications
You must be signed in to change notification settings - Fork 158
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
initial changes to implement fog cloud storage library #822
base: main
Are you sure you want to change the base?
Conversation
@@ -53,6 +53,8 @@ gem 'tzinfo', '~> 1.2' | |||
gem 'open_id_authentication' | |||
gem 'protected_attributes_continued', '~> 1.8.2' | |||
gem 'ruby-openid' | |||
gem 'fog-google' |
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.
We could do this due to fog/fog-google#535
gem 'fog-google' | |
gem 'fog-google', '1.13.0' # Limited to `v1.13.0` due to https://github.com/fog/fog-google/issues/535 |
@@ -4,6 +4,17 @@ | |||
# Paperclip.options[:command_path] = "/usr/bin/identify" | |||
# Paperclip.options[:command_path] = "/usr/local/bin" | |||
|
|||
Paperclip::Attachment.default_options[:storage] = :fog | |||
Paperclip::Attachment.default_options[:fog_directory] = ENV["GOOGLE_STORAGE_BUCKET_NAME"] || '' | |||
Paperclip::Attachment.default_options[:path] = ":rails_root/public/system/public/system/:class/:attachment/:id_partition/:style/:filename" |
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.
Sourcing from /app/models/spectrum.rb
, this should be:
Paperclip::Attachment.default_options[:path] = ":rails_root/public/system/public/system/:class/:attachment/:id_partition/:style/:filename" | |
Paperclip::Attachment.default_options[:path] = ":rails_root/public/system/:attachment/:id/:style/:filename" |
Or it may be id_partition
instead of id
. Let's try id
first.
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.
And we may need to again duplicate public/system
to public/system/public/system
so let's see there once this runs.
OK @icarito we need to test this out. There are two changes which may be necessary.
|
@@ -4,6 +4,17 @@ | |||
# Paperclip.options[:command_path] = "/usr/bin/identify" | |||
# Paperclip.options[:command_path] = "/usr/local/bin" | |||
|
|||
Paperclip::Attachment.default_options[:storage] = :fog | |||
Paperclip::Attachment.default_options[:fog_directory] = ENV["GOOGLE_STORAGE_BUCKET_NAME"] || '' | |||
Paperclip::Attachment.default_options[:path] = ":rails_root/public/system/:attachment/:id/:style/:filename" |
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.
Paperclip::Attachment.default_options[:path] = ":rails_root/public/system/:attachment/:id/:style/:filename" | |
Paperclip::Attachment.default_options[:path] = ":rails_root/public/system/public/system/:attachment/:id/:style/:filename" |
Confirming it works in GitPod. Now needs testing of in unstable of:
I'd like to pre-generate an "old" spectrum on unstable BEFORE rolling out this new code, so we can check the way old images are routed after this code is deployed. Currently https://unstable.spectralworkbench.org/ doesn't have any saved images, but i get an error when trying to save an image from https://unstable.spectralworkbench.org/capture |
Okay I've created a bucket, called "spectralworkbench-bucket" |
Will now add the GOOGLE_STORAGE_BUCKET_NAME var to unstable and push to unstable |
I did implement the env vars in unstable and got:
when trying to upload! |
Perhaps it's an authentication issue... |
Is there any more trace, deeper into the stack? The line number cited is just for
|
Yes it would seem it was an authentication issue. I've added a serviceaccount and now I'm seeing permissions errors. |
I'm granting permission to the service account and will try again. |
The error says:
Perhaps I've misconfigured the service account, I'll check it! |
After granting the appropriate permissions to the service account, I've confirmed unstable is capable of uploading files to a cloud bucket. 🎆 So we should merge this! |
Actually there's a new error now!
I wonder if this is a more complex issue, such as wanting to be processing the image in the bucket. |
We're getting closer, I think, now there's a different error:
|
4bbf70f
to
16d595c
Compare
@@ -114,7 +114,8 @@ def self.weekly_tallies | |||
|
|||
# finds the brightest row of the image and uses that as its sample row | |||
def find_brightest_row | |||
image = Magick::ImageList.new('public' + (photo.url.split('?')[0]).gsub('%20', ' ')) | |||
photo.copy_to_local_file(:original,local_photo_path) |
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.
OK:
um, how are we doing it wrong? |
Now seeing:
|
Tried with a JPEG:
|
8bf0286
to
b2fe161
Compare
b2fe161
to
8bf0286
Compare
To deploy this to production and enable it, we'd:
|
Added a patch that fixes #891 to continue with our checklist |
There is one big difference, with |
Just noting that we seem to be OK here, just waiting to be tested, (excepting the conflicts). 👍 |
Fixes #821
This is an initial naive implementation modeled after publiclab/plots2#9807
rake test
Please be sure you've reviewed our contribution guidelines at https://publiclab.org/wiki/contributing-to-public-lab-software
Thanks!