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

R 3.1.3 #3467

Merged
merged 8 commits into from
Mar 29, 2024
Merged

R 3.1.3 #3467

Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/dashboard/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ gem 'mocha', '~> 2.1', group: :test
gem 'autoprefixer-rails', '~> 10.2.5'
gem 'dotiw'
gem 'local_time', '~> 1.0.3'
gem 'zip_tricks', '~> 5.5'
gem 'zip_kit', '~> 6.2'
gem 'rss', '~> 0.2'

gem 'jsbundling-rails', '~> 1.0'
Expand All @@ -57,7 +57,7 @@ gem 'cssbundling-rails', '~> 1.1'
# OOD specific gems
gem 'ood_support', '~> 0.0.2'
gem 'ood_appkit', '~> 2.1.0'
gem 'ood_core', '~> 0.24.1'
gem 'ood_core', '~> 0.25'
gem 'pbs', '~> 2.2.1'
gem 'rest-client', '~> 2.0'

Expand Down
10 changes: 5 additions & 5 deletions apps/dashboard/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ GEM
ood_core (~> 0.1)
rails (>= 6.0.0, < 7)
redcarpet (~> 3.2)
ood_core (0.24.2)
ood_core (0.25.0)
ffi (~> 1.9, >= 1.9.6)
ood_support (~> 0.0.2)
rexml (~> 3.2)
Expand Down Expand Up @@ -214,7 +214,7 @@ GEM
rake (>= 12.2)
thor (~> 1.0)
rake (13.1.0)
rdoc (6.6.2)
rdoc (6.6.3.1)
psych (>= 4.0.0)
redcarpet (3.6.0)
regexp_parser (2.9.0)
Expand Down Expand Up @@ -270,7 +270,7 @@ GEM
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.12)
zip_tricks (5.6.0)
zip_kit (6.2.2)

PLATFORMS
ruby
Expand All @@ -293,7 +293,7 @@ DEPENDENCIES
local_time (~> 1.0.3)
mocha (~> 2.1)
ood_appkit (~> 2.1.0)
ood_core (~> 0.24.1)
ood_core (~> 0.25)
ood_support (~> 0.0.2)
pbs (~> 2.2.1)
rails (= 6.1.7.6)
Expand All @@ -306,7 +306,7 @@ DEPENDENCIES
sinatra-contrib
timecop (~> 0.9)
webrick
zip_tricks (~> 5.5)
zip_kit (~> 6.2)

BUNDLED WITH
2.3.6
47 changes: 32 additions & 15 deletions apps/dashboard/app/controllers/files_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The controller for all the files pages /dashboard/files
class FilesController < ApplicationController
include ZipTricks::RailsStreaming
include ActionController::Live

before_action :strip_sendfile_headers, only: [:fs]

Expand Down Expand Up @@ -58,22 +58,25 @@ def fs
response.sending_file = true
response.cache_control[:public] ||= false

# FIXME: strategy 1: is below, use zip_tricks
# strategy 2: use actual zip command (likely much faster) and ActionController::Live
zip_tricks_stream do |zip|
@path.files_to_zip.each do |file|
begin
next unless File.readable?(file.realpath)

if File.file?(file.realpath)
zip.write_deflated_file(file.relative_path.to_s) do |zip_file|
IO.copy_stream(file.realpath, zip_file)
zip_headers = ZipKit::OutputEnumerator.new.streaming_http_headers
response.headers.merge!(zip_headers)

send_stream(filename: zipname) do |stream|
HazelGrant marked this conversation as resolved.
Show resolved Hide resolved
ZipKit::Streamer.open(stream) do |zip|
@path.files_to_zip.each do |file|
begin
next unless File.readable?(file.realpath)

if File.file?(file.realpath)
zip.write_deflated_file(file.relative_path.to_s) do |zip_file|
IO.copy_stream(file.realpath, zip_file)
end
else
zip.add_empty_directory(dirname: file.relative_path.to_s)
end
else
zip.add_empty_directory(dirname: file.relative_path.to_s)
rescue => e
logger.warn("error writing file #{file.path} to zip: #{e.message}")
end
rescue => e
logger.warn("error writing file #{file.path} to zip: #{e.message}")
end
end
end
Expand Down Expand Up @@ -178,6 +181,20 @@ def edit

private

def send_stream(filename:, disposition: "attachment", type: nil)
response.headers["Content-Type"] =
(type.is_a?(Symbol) ? Mime[type].to_s : type) ||
Mime::Type.lookup_by_extension(File.extname(filename).downcase.delete("."))&.to_s ||
"application/octet-stream"

response.headers["Content-Disposition"] =
ActionDispatch::Http::ContentDisposition.format(disposition: disposition, filename: filename)

yield response.stream
ensure
response.stream.close
end

# set these headers to nil so that we (Rails) will read files
# off of disk instead of nginx.
def strip_sendfile_headers
Expand Down
7 changes: 6 additions & 1 deletion apps/dashboard/app/models/batch_connect/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def get_binding
# @return [Integer] created at
attr_accessor :created_at

# When this session finished, as a unix timestamp
# @return [Integer] completed at
attr_accessor :completed_at

# Token describing app and sub app
# @return [String] app token
attr_accessor :token
Expand Down Expand Up @@ -87,7 +91,7 @@ def app
# Attributes used for serialization
# @return [Hash] attributes to be serialized
def attributes
%w(id cluster_id job_id created_at token title script_type cache_completed).map do |attribute|
%w(id cluster_id job_id created_at token title script_type cache_completed completed_at).map do |attribute|
[ attribute, nil ]
end.to_h
end
Expand Down Expand Up @@ -421,6 +425,7 @@ def update_info
def update_cache_completed!
if (! cache_completed) && completed?
self.cache_completed = true
self.completed_at = Time.now.to_i
db_file.write(to_json)
end
end
Expand Down
3 changes: 2 additions & 1 deletion apps/dashboard/test/models/batch_connect/session_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,8 @@ def completed?
'token' => 'bc_jupyter',
'title' => 'Jupyter Notebook',
'script_type' => 'basic',
'cache_completed' => nil
'cache_completed' => nil,
'completed_at' => nil
}
Timecop.freeze(now) do
assert session.save(app: bc_jupyter_app, context: ctx), session.errors.each(&:to_s).to_s
Expand Down
2 changes: 1 addition & 1 deletion apps/myjobs/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ gem 'ood_appkit', '~> 2.0'

# we have to lock rdoc because 6.4 depends on psych 4.0 which breaks with
# Psych::BadAlias: Cannot load database configuration: Unknown alias: default
gem 'rdoc', '6.3.3'
gem 'rdoc', '6.3.4.1'
4 changes: 2 additions & 2 deletions apps/myjobs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdoc (6.3.3)
rdoc (6.3.4.1)
redcarpet (3.6.0)
request_store (1.5.1)
rack (>= 1.4)
Expand Down Expand Up @@ -270,7 +270,7 @@ DEPENDENCIES
pbs (~> 2.2.1)
rails (= 6.1.7.6)
rails-controller-testing
rdoc (= 6.3.3)
rdoc (= 6.3.4.1)
sass-rails (~> 5.0)
sdoc
sqlite3 (= 1.4.2)
Expand Down
Loading