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

Deploy jupyterlite at startup #1178

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions app/services/llm_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ def initialize openai_key, _opts = {}
def make_judgement judge, query_doc_pair
user_prompt = make_user_prompt query_doc_pair
results = get_llm_response user_prompt, judge.system_prompt
puts 'Here are the results'
puts results
judgement = Judgement.new(query_doc_pair: query_doc_pair, user: judge)
judgement.rating = results[:judgment]
judgement.explanation = results[:explanation]
Expand Down
23 changes: 23 additions & 0 deletions config/initializers/heroku.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

# Unpack Jupyterlite on Heroku as part of start up
# See assets.rake for some related code.
puts "about to test out heroku."
if ENV['HEROKU_APP_NAME'].present?
notebooks_gz = Rails.root.join('notebooks.gz')
destination = Rails.public_path
notebooks_dir = Rails.public_path.join('notebooks')
unless File.exist?(notebooks_dir)

unless File.exist?(notebooks_gz)
puts 'Downloading latest Quepid Notebooks from https://github.com/o19s/quepid-jupyterlite'
system "wget --no-verbose -O #{notebooks_gz} https://github.com/o19s/quepid-jupyterlite/releases/latest/download/jupyter-lite-build.tgz"
end

puts "Unpacking Jupyterlite into #{destination}"
#system "tar -xzf #{notebooks_gz} --directory #{destination}"
system "tar -xzf #{notebooks_gz} --directory ./eric"

File.delete(notebooks_gz)
end
end
11 changes: 8 additions & 3 deletions lib/tasks/assets.rake
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ namespace :assets do
system "wget --no-verbose -O #{notebooks_gz} https://github.com/o19s/quepid-jupyterlite/releases/latest/download/jupyter-lite-build.tgz"
end

puts "Unpacking Jupyterlite into #{destination}"
system "tar -xzf #{notebooks_gz} --directory #{destination}"
# Heroku limits us to 500 MB slugs which we exceed, so
# only unpack the gzip file if we aren't in Heroku.
# On Heroku we unpack as part of start up. See heroku.rb.
if ENV['HEROKU_APP_NAME'].blank?
puts "Unpacking Jupyterlite into #{destination}"
system "tar -xzf #{notebooks_gz} --directory #{destination}"

File.delete(notebooks_gz)
File.delete(notebooks_gz)
end
end
end

Expand Down
Loading