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

Externalizing the jupyterlite build #728

Merged
merged 21 commits into from
May 18, 2023
Merged
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
11 changes: 0 additions & 11 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# First build the jupyter-lite web artifact
FROM python:3.11 as builder
COPY jupyterlite/ /build/
WORKDIR /build
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt && rm -f requirements.txt \
&& jupyter lite build --output-dir notebooks && tar -czf ./jupyter-lite-build.tgz notebooks

FROM ruby:3.2.2-bullseye

LABEL maintainer="[email protected]"
Expand Down Expand Up @@ -38,8 +30,5 @@ RUN wget --no-check-certificate -qO - https://dl.yarnpkg.com/debian/pubkey.gpg |
&& apt-get update -qq && apt-get install -y --no-install-recommends nodejs yarn netcat \
&& rm -rf /var/lib/apt/lists/*

# Jupyterlite, see bin/setup_jupyterlite on how this is woven into the /public webroot
COPY --from=builder /build/jupyter-lite-build.tgz /tmp/

# Clean environment
RUN apt-get clean all
4 changes: 3 additions & 1 deletion Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ COPY ./Rakefile ./Rakefile
COPY ./README.md ./README.md
COPY ./vendor ./vendor
COPY ./yarn.lock ./yarn.lock
COPY ./jupyterlite/notebooks.gz ./jupyterlite/notebooks.gz

ADD https://github.com/o19s/quepid-jupyterlite/releases/latest/download/jupyter-lite-build.tgz ./notebooks.gz

RUN mkdir -p tmp/pids

# Also unpacks the ./notebooks.gz file
RUN RAILS_ENV=production SECRET_KEY_BASE=fake_out_devise bundle exec rake assets:precompile

# Remove some files not needed in resulting image
Expand Down
30 changes: 0 additions & 30 deletions UPGRADE_RAILS_SIX.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ angular.module('QuepidApp')
// Snapshot Name Snapshot Time Case ID Query Text Doc ID Doc Position

querySnapshotSvc.get(snapshotId).then(function() {

var snapshot = querySnapshotSvc.snapshots[snapshotId];
csv = caseCSVSvc.stringifySnapshot(
ctrl.theCase,
Expand All @@ -91,13 +90,12 @@ angular.module('QuepidApp')
blob = new Blob([csv], {
type: 'text/csv'
});

/*global saveAs */
saveAs(blob, caseCSVSvc.formatDownloadFileName(ctrl.theCase.caseName + '_snapshot.csv'));

}, function (response) {
$log.debug('error fetching snapshot:');
$log.debug(response);
$log.info('error fetching snapshot:');
$log.info(response);
});

}
Expand Down
7 changes: 3 additions & 4 deletions app/assets/javascripts/services/caseCSVSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@
infoArray.push(stringifyField(aCase.caseName));
infoArray.push(stringifyField(aCase.lastScore.case_id));
infoArray.push(stringifyField(query.queryText));

dataString = infoArray.join(',');
csvContent += dataString + EOL;
}
Expand All @@ -333,7 +334,6 @@
angular.forEach(fields, function (field) {
infoArray.push(stringifyField(doc.doc[field]));
});

dataString = infoArray.join(',');
csvContent += dataString + EOL;
});
Expand Down Expand Up @@ -385,17 +385,16 @@
if (withHeader) {
csvContent += self.snapshotHeaderToCSV();
}

angular.forEach(snapshot.docs, function (docs, queryId) {
const queryIdToMatch = parseInt(queryId, 10);
const matchingQuery = snapshot.queries.filter(function(query) {
return query.queryId === queryIdToMatch;
});
if (matchingQuery[0]) {
const matchingQueryText = matchingQuery[0].query_text;
const matchingQueryText = matchingQuery[0].queryText;
if (matchingQueryText) {
angular.forEach(docs, function (doc, idx) {
const infoArray = [];
let infoArray = [];
infoArray.push(stringifyField(snapshotName));
infoArray.push(stringifyField(snapshotTime));
infoArray.push(stringifyField(caseNumber));
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/services/snapshotFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
angular.forEach(self.queries, function(query) {
query.queryId = query.query_id;
delete query.query_id;
query.queryText = query.query_text;
delete query.query_text;
});

angular.forEach(self.docs, function(docs, queryId) {
Expand Down
9 changes: 3 additions & 6 deletions bin/setup_jupyterlite
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
require 'pathname'

# Update our Jupyterlite setup from the latest.
JUPYTER_BUILD_DOWNLOAD_URL = "https://github.com/o19s/quepid-jupyterlite/releases/latest/download/jupyter-lite-build.tgz"

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)

Dir.chdir APP_ROOT do
puts "\n== Copying Jupyter Lite Build =="
# todo: this indirection is only because we copy it from this location in the Dockerfile.prod, we could just use the builder there too
system "bin/docker r cp /tmp/jupyter-lite-build.tgz /srv/app/jupyterlite/notebooks.gz"

puts "\n== Extracting Jupyter Lite Build =="
system "bin/docker r tar -xzf /srv/app/jupyterlite/notebooks.gz --directory /srv/app/public"
puts "\n== Downloading and extracting Jupyter Lite Build =="
system "bin/docker r bash -c 'rm -rf /srv/app/public/notebooks && wget -qO- #{JUPYTER_BUILD_DOWNLOAD_URL} | tar -C /srv/app/public -zxf -'"
end
13 changes: 13 additions & 0 deletions docs/jupyterlite.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Jupyterlite

We package up Jupyterlite notebooks to work with Quepid via the https://github.com/o19s/quepid-jupyterlite repository.

For development we have a `bin/setup_jupyterlite` script that grabs the release and dumps it locally.

For prod, we bake the files in as part of building the image.

On Heroku, we grab the version and deploy it. The version is specified in `app.json`.



### Old Stuff
https://github.com/innovationOUtside/ouseful_jupyterlite_utils

From https://jupyterlite.readthedocs.io/en/latest/user-guide.html#how-can-i-read-content-from-python
Expand Down
6 changes: 5 additions & 1 deletion docs/operating_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This document explains how Quepid can be operated and configured.
- [User Tracking](#user-tracking)
- [Heathcheck Endpoint](#healthcheck)
- [Database Management](#database-management)

- [Jupyterlite Notebooks](#jupyterlite-notebooks)
## Running behind a load balancer

> ⚠️ _Quepid will run in TLS (`https`) or plain `http` mode depending on the
Expand Down Expand Up @@ -175,3 +175,7 @@ Want to monitor if Quepid is behaving? Just monitor `/healthcheck`, and you wil
## Database Management

See the details in [](./database.md).

## Jupuyterlite Notebooks

See the details in [](./jupyterlite.md).
5 changes: 0 additions & 5 deletions jupyterlite/files/README.md

This file was deleted.

Loading