-
Notifications
You must be signed in to change notification settings - Fork 3
Add datascience notebook and github actions #1
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
Open
AnchorArray
wants to merge
61
commits into
main
Choose a base branch
from
add-ds-notebook
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
e8fa194
Add datascience notebook and github actions
AnchorArray 4d1b838
add action on PR
AnchorArray f4796aa
add action on PR
AnchorArray 38cc6b7
Update .github/workflows/main.yaml
AnchorArray 1d8427b
Update .github/workflows/main.yaml
AnchorArray 4486d82
Update .github/workflows/main.yaml
AnchorArray ba915e7
Update .github/workflows/main.yaml
AnchorArray db1e20d
Update .github/workflows/main.yaml
AnchorArray 1ed41a9
address comments (and test without qemu)
AnchorArray b0dc6d9
Update .github/workflows/main.yaml
AnchorArray 05d6114
address comment suggestion
AnchorArray 2dc8941
debug
AnchorArray 5586d3d
remove pinned version from buildx for testing
AnchorArray 5e7c361
self-hosted runner
AnchorArray 334d653
Update .github/workflows/main.yaml
AnchorArray 8a6fc03
Update .github/workflows/main.yaml
AnchorArray d1a0b61
Update .github/workflows/main.yaml
AnchorArray 5e8fcf2
Update kernels/datascience-notebook/Dockerfile
AnchorArray 16e87f3
Update kernels/datascience-notebook/Dockerfile
AnchorArray 5ee2de1
Empty-Commit
AnchorArray aa23a2a
Merge branch 'add-ds-notebook' of https://github.com/noteable-io/kern…
AnchorArray 7b636c2
update
AnchorArray 37b0044
revert to v2, there is no v3
AnchorArray 0806f95
triggering build for refresh
AnchorArray cc011de
Revert "add action on PR"
AnchorArray e83ae07
revert to working
AnchorArray 4978b8c
change cache
AnchorArray 054c258
update versions
AnchorArray 8322242
Update to latest version of notebook image with new features
AnchorArray 929c8e6
rename file
AnchorArray edef0f3
adding missing envs
AnchorArray 4b6ed79
debug
AnchorArray 958ba3d
revert
AnchorArray 963bdcf
Merge branch 'main' into add-ds-notebook
AnchorArray 3d5f98f
Merge branch 'main' of https://github.com/noteable-io/kernels into ad…
AnchorArray 953c2b0
add 3.7
AnchorArray e05070e
Merge branch 'add-ds-notebook' of https://github.com/noteable-io/kern…
AnchorArray c185dab
change to amd...
AnchorArray 0ce6239
update packages
AnchorArray ff22605
Add environment specific requirements
AnchorArray 8e651a2
missing change
AnchorArray acd10bc
remove reusable workflow for now
AnchorArray 47860e4
dockerfile updates
AnchorArray 2230b39
build arg not propagating
AnchorArray 6f1b36f
bump versions
AnchorArray dcd48ed
debug
AnchorArray c1d5129
debug
AnchorArray 577ee69
debug
AnchorArray af43735
debug
AnchorArray 930f5a6
debug
AnchorArray 2744114
debug
AnchorArray f4bce28
debug
AnchorArray 0035088
debug
AnchorArray 1684f0c
debug
AnchorArray f69da75
debug
AnchorArray 6a653ed
debug
AnchorArray 8117176
debug
AnchorArray 4cff673
debug
AnchorArray 22d87d3
debug
AnchorArray b565344
debug
AnchorArray caaa4e2
add 3.10.9
AnchorArray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
name: Build kernel images | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
|
||
build-python-images: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# version: ["3.8.8", "3.9.13", "3.10.5"] 3.10.5 fails with dependency conflicts | ||
# We may need to have separate requirements.txt for each version, or replace | ||
# dependencies on the fly | ||
version: ["3.7.12", "3.8.13", "3.9.13", "3.10.9"] | ||
directory: ["datascience-notebook"] | ||
# The datascience-notebook base image does not support ARM | ||
# We would need to build and maintain our own base image | ||
# architecture: ["arm", "amd"] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# TODO: Log into DockerHub to prevent rate limiting | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up QEMU | ||
Chili-Man marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Create context | ||
run: | | ||
docker context create github-action | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
endpoint: github-action | ||
version: v0.10.4 | ||
env: | ||
DOCKER_CONTEXT: github-action | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v3 | ||
id: docker-cache | ||
with: | ||
path: "/tmp/buildx-cache" | ||
key: "${{ runner.os }}-buildx-${{ matrix.directory }}-${{ matrix.version }}" | ||
AnchorArray marked this conversation as resolved.
Show resolved
Hide resolved
|
||
restore-keys: "${{ runner.os }}-buildx-" | ||
AnchorArray marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Build arguments | ||
id: build-args | ||
run: | | ||
# Image Name | ||
container_registry=ghcr.io/${{ github.repository_owner }} | ||
image_name=kernel-${{ matrix.directory }} | ||
full_image_name="${container_registry}/${image_name}" | ||
|
||
# Image Tags | ||
image_sha_tag="${GITHUB_SHA:0:12}" # first 12 numbers of the SHA | ||
image_version_tag="python-$(version=${{ matrix.version }} && echo ${version%.*} )" # removes patch version | ||
|
||
full_image_name_tagged='' | ||
|
||
if [ "${GITHUB_EVENT_NAME}" = 'push' ]; then | ||
full_image_name_tagged="${full_image_name}:${image_version_tag}" | ||
elif [ "${GITHUB_EVENT_NAME}" = 'pull_request' ]; then | ||
full_image_name_tagged="${full_image_name}:${image_version_tag}-${image_sha_tag}" | ||
fi | ||
|
||
echo "::set-output name=FULL_IMAGE_NAME::${full_image_name}" | ||
echo "::set-output name=FULL_IMAGE_NAME_TAGGED::${full_image_name_tagged}" | ||
|
||
echo "::set-output name=BUILD_URL::https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | ||
echo "::set-output name=BUILD_TIMESTAMP::$(date --utc --iso-8601=seconds)" | ||
|
||
echo "full_image_name: $full_image_name" | ||
echo "image_version_tag: $image_version_tag" | ||
echo "image_sha_tag: $image_sha_tag" | ||
echo "full_image_name_tagged: $full_image_name_tagged" | ||
|
||
- name: Build image | ||
env: | ||
DOCKER_CONTEXT: github-action | ||
run: | | ||
( | ||
cd ${GITHUB_WORKSPACE}/kernels/${{ matrix.directory }} | ||
|
||
docker buildx build \ | ||
--pull \ | ||
--push \ | ||
--platform=linux/amd64 \ | ||
--progress plain \ | ||
--cache-from 'type=local,src=/tmp/buildx-cache' \ | ||
--cache-to 'type=local,dest=/tmp/buildx-cache' \ | ||
--tag '${{ steps.build-args.outputs.FULL_IMAGE_NAME_TAGGED }}' \ | ||
--build-arg PYTHON_VERSION=${{ matrix.version }} \ | ||
--build-arg 'NBL_ARG_BUILD_TIMESTAMP=${{ steps.build-args.outputs.BUILD_TIMESTAMP }}' \ | ||
--build-arg 'NBL_ARG_BUILD_URL=${{ steps.build-args.outputs.BUILD_URL }}' \ | ||
--build-arg 'NBL_ARG_REVISION=${{ github.sha }}' \ | ||
--build-arg 'NBL_ARG_VERSION=${{ github.ref }}' \ | ||
. | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import pandas as pd | ||
|
||
import dx | ||
|
||
dx.set_option("DISPLAY_MAX_ROWS", 50_000) | ||
dx.set_option("DISPLAY_MAX_COLUMNS", 100) | ||
dx.set_option("ENABLE_DATALINK", True) | ||
dx.set_option("ENABLE_ASSIGNMENT", False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# syntax = docker/dockerfile:1.4.3 | ||
ARG BASE_IMAGE=jupyter/datascience-notebook | ||
ARG PYTHON_VERSION=3.9.13 | ||
AnchorArray marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# hadolint ignore=DL3006 | ||
FROM ${BASE_IMAGE}:python-${PYTHON_VERSION} | ||
|
||
USER root | ||
|
||
# datascience-notebook:python-3.9.13 includes psutil 5.9.2 with cooked C lib, but | ||
# later pip installs end up installing 5.9.4, but for some | ||
# reason 'import psutil' will end up getting the python 5.9.4 but the | ||
# C lib from 5.9.2, and, unlike Smeagol, it hateses the precious. | ||
RUN pip uninstall -y psutil | ||
|
||
# Set up log file for magics | ||
RUN touch /var/log/noteable_magics.log && \ | ||
chown 4004:4004 /var/log/noteable_magics.log | ||
|
||
# When image is run, run the code with the environment | ||
# activated: | ||
SHELL ["/bin/bash", "-c"] | ||
|
||
WORKDIR /tmp | ||
|
||
# hadolint ignore=DL3008,DL3015 | ||
RUN apt-get update && \ | ||
apt-get install -y jq procps git unixodbc-dev g++ \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV NB_USER="noteable" \ | ||
NB_UID=4004 \ | ||
NB_GID=4004 | ||
|
||
# Create the default unprivileged user | ||
RUN groupadd --gid 4004 noteable && \ | ||
useradd --uid 4004 --shell /bin/false --create-home --no-log-init --gid noteable noteable && \ | ||
chown --recursive noteable:noteable /home/noteable | ||
|
||
RUN mkdir /etc/ipython && chown noteable:noteable /etc/ipython | ||
RUN mkdir -p /etc/noteable && chown noteable:noteable /etc/noteable | ||
|
||
RUN chown noteable:noteable "${CONDA_DIR}" && \ | ||
fix-permissions "${CONDA_DIR}" | ||
|
||
# `rust` is required for install of some packages under arm (and future x86 packages) | ||
# hadolint ignore=SC1091 | ||
RUN wget -O rustup.sh -q https://sh.rustup.rs && \ | ||
sh rustup.sh -y && \ | ||
rm rustup.sh && \ | ||
source "$HOME/.cargo/env" | ||
|
||
# Run non-privileged user | ||
USER noteable | ||
|
||
ENV PATH="/home/noteable/.local/bin:${PATH}" \ | ||
HOME="/home/noteable" \ | ||
XDG_CACHE_HOME="/home/noteable/.cache/" \ | ||
GOOGLE_APPLICATION_CREDENTIALS="/vault/secrets/gcp-credentials" | ||
|
||
ARG PYTHON_VERSION | ||
|
||
# hadolint ignore=DL3045 | ||
COPY environment-${PYTHON_VERSION}.txt ./environment.txt | ||
|
||
# hadolint ignore=SC2034 | ||
RUN mamba install --file environment.txt | ||
|
||
# hadolint ignore=DL3045 | ||
COPY requirements-${PYTHON_VERSION}.txt ./requirements.txt | ||
|
||
# hadolint ignore=SC1008,SC2155,DL3042,SC2102 | ||
RUN pip install -I --no-cache-dir -r requirements.txt | ||
|
||
# Copy over any python commands that need to run on startup | ||
# that aren't covered by IPython extensions | ||
COPY .pythonrc /home/noteable/.pythonrc | ||
|
||
# Enable the widgets nbextension | ||
# hadolint ignore=SC1008 | ||
RUN jupyter nbextension enable --py --sys-prefix widgetsnbextension | ||
|
||
# Smoke test to ensure packages were installed properly | ||
# hadolint ignore=SC1008 | ||
RUN if [ "$PYTHON_VERSION" != "3.7.12" ]; then python -c "import noteable_magics"; fi | ||
|
||
RUN git config --global user.name "Noteable Kernel" && \ | ||
git config --global user.email "engineering@noteable.io" && \ | ||
git config --global safe.directory /etc/noteable/project && \ | ||
git config --global credential.helper /git_credential_helper.py && \ | ||
git config --global credential.useHttpPath true | ||
|
||
# https://ipython.readthedocs.io/en/stable/config/intro.html#systemwide-configuration | ||
COPY ipython_config.py /etc/ipython | ||
|
||
# Set standard working directory for noteable project | ||
WORKDIR /etc/noteable/project | ||
|
||
# Add the entrypoint script to the $PATH | ||
COPY run.sh /usr/local/bin | ||
COPY secrets_helper.py /tmp/secrets_helper.py | ||
COPY git_credential_helper.py /git_credential_helper.py | ||
COPY git-wrapper.sh /usr/local/bin/git | ||
|
||
EXPOSE 50001-50005 | ||
|
||
# Use tini to manage passing signals to the child kernel process | ||
# -g will ensure signals are passed to the entire child process *group*, | ||
# not just the immediate child process (bash) | ||
# https://github.com/krallin/tini#process-group-killing | ||
ENTRYPOINT ["tini", "-g", "--"] | ||
CMD ["run.sh"] | ||
|
||
# Labels | ||
ARG NBL_ARG_BUILD_TIMESTAMP="undefined" | ||
ARG NBL_ARG_REVISION="undefined" | ||
ARG NBL_ARG_PYTHON_VERSION="3.9.6" | ||
Chili-Man marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ARG NBL_ARG_BUILD_URL="undefined" | ||
ARG NBL_ARG_VERSION="undefined" | ||
LABEL org.opencontainers.image.created="${NBL_ARG_BUILD_TIMESTAMP}" \ | ||
org.opencontainers.image.revision="${NBL_ARG_REVISION}" \ | ||
org.opencontainers.image.source="https://github.com/noteable-io/polymorph" \ | ||
org.opencontainers.image.title="noteable-python-${NBL_ARG_PYTHON_VERSION}" \ | ||
org.opencontainers.image.url="${NBL_ARG_BUILD_URL}" \ | ||
org.opencontainers.image.vendor="Noteable" \ | ||
org.opencontainers.image.version="${NBL_ARG_VERSION}" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.