From ec6e20b5ef230f287c19edf75c404a89ef0acf8e Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 15 Jan 2025 15:38:26 -0500 Subject: [PATCH 1/5] Remove extra debugging --- app/services/llm_service.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/services/llm_service.rb b/app/services/llm_service.rb index e6b5b7227..1f9f0458b 100644 --- a/app/services/llm_service.rb +++ b/app/services/llm_service.rb @@ -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] From 6d925889c90fbf9203543056cd8dd1705a6bb7ef Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 15 Jan 2025 16:56:52 -0500 Subject: [PATCH 2/5] Does this get us under 500mb limit --- lib/tasks/assets.rake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index d6860407a..ca520fdbc 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -17,10 +17,10 @@ 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}" + #puts "Unpacking Jupyterlite into #{destination}" + #system "tar -xzf #{notebooks_gz} --directory #{destination}" - File.delete(notebooks_gz) + #File.delete(notebooks_gz) end end From f2f1babbd887ff455090506bf6302551f1860ed8 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 15 Jan 2025 17:25:52 -0500 Subject: [PATCH 3/5] Unpack during startup on Heroku --- config/initializers/heroku.rb | 15 +++++++++++++++ lib/tasks/assets.rake | 11 ++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 config/initializers/heroku.rb diff --git a/config/initializers/heroku.rb b/config/initializers/heroku.rb new file mode 100644 index 000000000..486f28042 --- /dev/null +++ b/config/initializers/heroku.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +# Unpack Jupyterlite on Heroku as part of start up +# See assets.rake for some related code. +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) + puts "Unpacking Jupyterlite into #{destination}" + system "tar -xzf #{notebooks_gz} --directory #{destination}" + + File.delete(notebooks_gz) + end +end diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index ca520fdbc..654b86831 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -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 From 0150b2f80b363d2d4da0e886277b2f7f60cb0db1 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 15 Jan 2025 17:38:22 -0500 Subject: [PATCH 4/5] Update heroku.rb --- config/initializers/heroku.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/initializers/heroku.rb b/config/initializers/heroku.rb index 486f28042..37e15ba17 100644 --- a/config/initializers/heroku.rb +++ b/config/initializers/heroku.rb @@ -2,13 +2,15 @@ # 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) puts "Unpacking Jupyterlite into #{destination}" - system "tar -xzf #{notebooks_gz} --directory #{destination}" + #system "tar -xzf #{notebooks_gz} --directory #{destination}" + system "tar -xzf #{notebooks_gz} --directory ./eric" File.delete(notebooks_gz) end From d68a31763ef7febf09c4fdb1e516b35dcd1302fc Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 15 Jan 2025 17:40:34 -0500 Subject: [PATCH 5/5] Update heroku.rb --- config/initializers/heroku.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/initializers/heroku.rb b/config/initializers/heroku.rb index 37e15ba17..bb67ae33c 100644 --- a/config/initializers/heroku.rb +++ b/config/initializers/heroku.rb @@ -8,6 +8,12 @@ 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"