Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdjscott committed Feb 19, 2024
0 parents commit fc3a05d
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build_container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
name: Create and publish a Docker image

on:
push:
workflow_dispatch:

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: docker
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Ohio Supercomputer Center

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# NeSI training environment ML102 Jupyter app

JupyterLab app for running the ML102 workshop on the NeSI training environment.
47 changes: 47 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM ubuntu:22.04

# install system dependencies
# TODO: move ldap-utils, libnss-ldapd, libpam-ldapd, nscd, nslcd to base image??
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl \
git \
ldap-utils \
libnss-ldapd \
libpam-ldapd \
less \
nano \
nodejs \
nscd \
nslcd \
python-is-python3 \
python3 \
python3-pip \
rsync \
unzip \
vim \
wget \
zip \
&& rm -rf /var/lib/apt/lists/*

# download the required image files into the container image
RUN wget -nv https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz \
-O /var/lib/flower_photos.tgz \
&& tar -xzf /var/lib/flower_photos.tgz -C /var/lib \
&& rm -f /var/lib/flower_photos.tgz \
&& chown -R root:root /var/lib/flower_photos \
&& chmod -R o+rX /var/lib/flower_photos \
&& wget -nv https://storage.googleapis.com/mledu-datasets/cats_and_dogs_filtered.zip \
-O /var/lib/cats_and_dogs_filtered.zip \
&& unzip -q -d /var/lib /var/lib/cats_and_dogs_filtered.zip \
&& rm -f /var/lib/cats_and_dogs_filtered.zip \
&& chown -R root:root /var/lib/cats_and_dogs_filtered \
&& chmod -R o+rX /var/lib/cats_and_dogs_filtered

# copy the repo source (e.g. notebooks) to the container image and install dependencies
ARG ML102_HASH="49d642bde806e73f9666fda8747a5dacf81bd117"
RUN git clone https://github.com/nesi/ml102_workshop.git /opt/ml102_workshop \
&& cd /opt/ml102_workshop \
&& git checkout $ML102_HASH \
&& pip3 --no-cache-dir install -r requirements.txt \
&& pip3 --no-cache-dir install jupyterlab \
&& rm -rf /opt/ml102_workshop/.git
17 changes: 17 additions & 0 deletions form.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
cluster: "my-k8s-cluster"

form:
- cpu
- memory
- wall_time

attributes:
cpu: 2
memory: 4
wall_time:
widget: number_field
label: "Hours"
min: 4
max: 12
value: 8
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: ML102
category: Interactive Apps
subcategory: Servers
role: batch_connect
description: |
This app will launch a Jupyter Lab server for the ML102 workshop
79 changes: 79 additions & 0 deletions submit.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<%
pwd_cfg = "c.ServerApp.password=u\'sha1:${SALT}:${PASSWORD_SHA1}\'"
host_port_cfg = "c.ServerApp.base_url=\'/node/${HOST_CFG}/${PORT_CFG}/\'"

configmap_filename = "ondemand_config.py"
configmap_data = "c.NotebookApp.port = 8080"
utility_img = "ghcr.io/nesi/training-environment-k8s-utils:v0.1.0"

user = OodSupport::User.new

services_node = Resolv.getaddress("servicesnode")
%>
---
script:
accounting_id: "<%= account %>"
wall_time: "<%= wall_time.to_i * 3600 %>"
native:
container:
name: "ml102"
image: "ghcr.io/nesi/training-environment-jupyter-ml102-app:v0.1.0"
command: ["/bin/bash","-l","<%= staged_root %>/job_script_content.sh"]
working_dir: "<%= Etc.getpwnam(ENV['USER']).dir %>"
restart_policy: 'OnFailure'
env:
NB_UID: "<%= user.uid %>"
NB_USER: "<%= user.name %>"
NB_GID: "<%= user.group.id %>"
HOME: "<%= user.home %>"
LOG_DIR: "<%= staged_root %>"
SHELL: "/bin/bash"
port: "8080"
cpu: "<%= cpu %>"
memory: "<%= memory %>Gi"
mounts:
- type: nfs
name: home
host: <%= services_node %>
path: /srv/homes
destination_path: /home/shared
- type: host
name: nslcd-socket
host_type: Socket
path: /var/run/nslcd/socket
destination_path: /var/run/nslcd/socket
- type: host
name: nsswitch-conf
host_type: File
path: /etc/nsswitch.conf
destination_path: /etc/nsswitch.conf
configmap:
files:
- filename: "<%= configmap_filename %>"
data: |
c.ServerApp.ip = '0.0.0.0'
c.ServerApp.port = 8080
c.ServerApp.port_retries = 0
c.ServerApp.open_browser = False
c.ServerApp.allow_origin = '*'
c.ServerApp.root_dir = '<%= user.home %>/ml102_workshop'
c.ServerApp.disable_check_xsrf = True
mount_path: '/ood'
init_containers:
- name: "init-secret"
image: "<%= utility_img %>"
command:
- "/bin/save_passwd_as_secret"
- "user-<%= user.name %>"
- name: "add-passwd-to-cfg"
image: "<%= utility_img %>"
command:
- "/bin/bash"
- "-c"
- "source /bin/passwd_from_secret; source /bin/create_salt_and_sha1; /bin/add_line_to_configmap \\\"<%= pwd_cfg %>\\\" <%= configmap_filename %>"
- name: "add-hostport-to-cfg"
image: "<%= utility_img %>"
command:
- "/bin/bash"
- "-c"
- "source /bin/find_host_port; /bin/add_line_to_configmap \\\"<%= host_port_cfg %>\\\" <%= configmap_filename %>"
Empty file added template/.keep
Empty file.
23 changes: 23 additions & 0 deletions template/script.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

exec &> >(tee -a "${LOG_DIR}/pod.log")

# Benchmark info
echo "TIMING - Starting main script at: $(date)"

cp /ood/ondemand_config.py ./

# Set working directory to home directory
cd "${HOME}"

#
# Start Jupyter Notebook Server
#

# Benchmark info
echo "TIMING - Starting jupyter at: $(date)"

# Launch the Jupyter Notebook Server
set -x
rsync --ignore-existing -avz /opt/ml102_workshop/ ~/ml102_workshop/
jupyter lab --config="/ood/ondemand_config.py"
7 changes: 7 additions & 0 deletions view.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<form action="/node/<%= host %>/<%= port %>/login" method="post" target="_blank">
<input type="hidden" name="password" value="<%= password %>">
<button class="btn btn-primary" type="submit">
<i class="fa fa-registered"></i> Connect to ML102 JupyterLab
</button>
</form>

0 comments on commit fc3a05d

Please sign in to comment.