Skip to content

Commit 7868e45

Browse files
authored
Setup initial github action (#1)
Setup an initial github action for building and pushing the docker image. The test_notebooks are used for test, with the exception of the cadquery one that seems to need more changes. Another one importing all the packages was added. No output validation is done, but an exception will lead to a test failure. Remove the tag from the repo, replace it with docker/metadata-actio from the github context. To make the build and test work, multiple changes are done: - Explicitly add pip in the dependencies, conda was complaining about it in loop during docker build. - The pyvista wheel that was included was triggering import failures (missing pyvista.jupyter). Replace it with the latest version - Minor update to the test example to allow running with an X server - Replace ipyvtk_simple with ipyvtklink, that was throwing a deprecated error
1 parent e6234f5 commit 7868e45

File tree

11 files changed

+141
-27
lines changed

11 files changed

+141
-27
lines changed

.github/workflows/ci.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
pull_request:
8+
9+
env:
10+
TEST_TAG: user/myapp:test
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-20.04
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
- name: Read IMAGE_NAME
20+
id: image_name
21+
uses: falti/[email protected]
22+
with:
23+
path: IMAGE_NAME
24+
- name: Login to ${{ steps.image_name.outputs.registry }}
25+
uses: docker/login-action@v1
26+
with:
27+
registry: ${{ steps.image_name.outputs.registry }}
28+
username: ${{ secrets.REGISTRY_USER }}
29+
password: ${{ secrets.REGISTRY_PASSWORD }}
30+
- name: Docker meta
31+
id: meta
32+
uses: docker/metadata-action@v3
33+
with:
34+
images: ${{ steps.image_name.outputs.registry }}/${{ steps.image_name.outputs.repository }}
35+
github-token: ${{ github.token }}
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v1
38+
- name: Build and export to Docker
39+
uses: docker/build-push-action@v2
40+
with:
41+
context: .
42+
load: true
43+
tags: ${{ env.TEST_TAG }}
44+
cache-from: type=gha
45+
cache-to: type=gha,mode=max
46+
- name: Test
47+
run: >-
48+
docker run --rm
49+
-v `pwd`/test_notebooks:/test_notebooks
50+
--user $(id -u):$(id -g) -e HOME=/tmp
51+
${{ env.TEST_TAG }}
52+
jupyter nbconvert --to html --execute $NOTEBOOKS --output-dir=/test_notebooks/out
53+
env:
54+
# Need fix: cadquery.ipynb
55+
NOTEBOOKS: >-
56+
/test_notebooks/import-all.ipynb
57+
/test_notebooks/ipygany.ipynb
58+
/test_notebooks/ipyvtk-simple.ipynb
59+
/test_notebooks/panel.ipynb
60+
- name: Save notebook HTML out
61+
uses: actions/upload-artifact@v2
62+
with:
63+
name: test-notebooks-html-out
64+
path: test_notebooks/out/*.html
65+
- name: Push the image
66+
uses: docker/build-push-action@v2
67+
with:
68+
context: .
69+
push: ${{ github.event_name == 'push' && contains(github.ref, '/tags/v') }}
70+
tags: ${{ steps.meta.outputs.tags }}
71+
labels: ${{ steps.meta.outputs.labels }}
72+
cache-from: type=gha
73+
cache-to: type=gha,mode=max

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
NVIDIA-Linux*
22
*.whl
33
*~
4-
ipynb_checkpoints/
4+
ipynb_checkpoints/
5+
test_notebooks/out
6+
7+
# Secrets when running github actions locally with nektos/act
8+
.secrets

Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ COPY environment.yml labextensions.txt /tmp/
3030
RUN mamba env update -n base --file /tmp/environment.yml
3131
RUN conda run jupyter labextension install $(cat /tmp/labextensions.txt)
3232

33-
COPY pyvista-0.29.1-py3-none-any.whl pyvista-0.29.1-py3-none-any.whl
34-
RUN pip install pyvista-0.29.1-py3-none-any.whl \
35-
&& rm pyvista-0.29.1-py3-none-any.whl
36-
3733
# make jovyan sudo
3834
USER root
3935
RUN echo 'export PATH="/opt/conda/bin:$PATH"' >> /etc/profile

IMAGE_NAME

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

33
# contains base image name version
4-
VERSION=v0.6.1
5-
IMAGE=mapdlhelm.azurecr.io/jupyterlab_base:$VERSION
4+
REGISTRY=mapdlhelm.azurecr.io
5+
REPOSITORY=jupyterlab_base
6+
IMAGE=$REGISTRY/$REPOSITORY:dev

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
This repository contains a `Dockerfile` to generate the base image
44
required for upstream images for pyansys.com. Images are generated by
5-
running the scripts in the following order:
6-
7-
- build.sh
8-
- push.sh
5+
pushing a git tag starting with `v`.
96

107
Image is named and is built to be deployed at the MBU container
118
repository, but this will be changed to be deployed via dockerhub or
@@ -18,10 +15,12 @@ mapdlhelm.azurecr.io/jupyterlab_base:$VERSION
1815
Obtain docker login credentials by following the steps at:
1916
https://portal.azure.com/#@ansys.com/resource/subscriptions/2870ae10-53f8-46b1-8971-93761377c38b/resourceGroups/PyANSYS/providers/Microsoft.ContainerRegistry/registries/mapdlhelm
2017

18+
It can be run locally by running the scripts in the following order:
19+
20+
- build_image.sh
21+
- run_image.sh
2122

2223
#### Notes
23-
- We're currently using a custom image of pyvista at the moment, and
24-
this needs to be upgraded to the latest pyvista release.
2524
- GPU image on dev.pyansys.com contains additional GPU remote
2625
rendering features not included in this image. Ping @akaszynski to
2726
create that branch.

environment.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88
- ipywidgets=7.6.3
99
- pandas=1.2.3
1010
- ipygany=0.5.0
11-
- pyvista=0.29.0
11+
- pyvista=0.32.1
1212
- panel=0.11.0
1313
- plotly=4.14.3
1414
- cadquery=master
@@ -20,8 +20,9 @@ dependencies:
2020
- ipyevents=0.8.2
2121
- ipycanvas=0.8.2
2222
- dash-bootstrap-components=0.11.3
23+
- ipyvtklink==0.2.1
24+
- pip=21.2.4
2325
- pip:
24-
- ipyvtk_simple==0.1.4
2526
- jupyter-cadquery==2.0.0
2627
- dash-vtk==0.0.6
2728
- dash-treeview-antd==0.0.1

push_image.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

pyvista-0.29.1-py3-none-any.whl

-1.16 MB
Binary file not shown.

test_notebooks/import-all.ipynb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"source": [
7+
"# Import all the packages from environment.yml\n",
8+
"import jupyterlab\n",
9+
"import ipywidgets\n",
10+
"import pandas\n",
11+
"import ipygany\n",
12+
"import pyvista\n",
13+
"import panel\n",
14+
"import plotly\n",
15+
"import cadquery\n",
16+
"import networkx\n",
17+
"import colour\n",
18+
"import ipympl\n",
19+
"import ipyevents\n",
20+
"import ipycanvas\n",
21+
"import dash\n",
22+
"import dash_bootstrap_components\n",
23+
"import pip\n",
24+
"import ipyvtklink\n",
25+
"import jupyter_cadquery\n",
26+
"import dash_vtk\n",
27+
"import dash_treeview_antd\n",
28+
"\n",
29+
"# Uncovered: jupyter-dash, cairo"
30+
],
31+
"outputs": [],
32+
"metadata": {}
33+
}
34+
],
35+
"metadata": {
36+
"orig_nbformat": 4,
37+
"language_info": {
38+
"name": "python"
39+
}
40+
},
41+
"nbformat": 4,
42+
"nbformat_minor": 2
43+
}

test_notebooks/ipyvtk-simple.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"metadata": {},
88
"outputs": [],
99
"source": [
10-
"import pyvista as pv"
10+
"import pyvista as pv\n",
11+
"import os"
1112
]
1213
},
1314
{
@@ -17,8 +18,9 @@
1718
"metadata": {},
1819
"outputs": [],
1920
"source": [
20-
"pv.set_jupyter_backend('ipyvtk_simple')\n",
21-
"# pv.start_xvfb()"
21+
"pv.set_jupyter_backend('ipyvtklink')\n",
22+
"if 'DISPLAY' not in os.environ:\n",
23+
" pv.start_xvfb()"
2224
]
2325
},
2426
{

0 commit comments

Comments
 (0)