Skip to content

Commit 77bea64

Browse files
committed
[MISC] Split images (#7)
1 parent f7d7006 commit 77bea64

11 files changed

Lines changed: 149 additions & 83 deletions

.github/workflows/ci.yaml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,37 @@ on:
1010

1111
jobs:
1212
build:
13+
strategy:
14+
fail-fast: false
15+
max-parallel: 5
16+
matrix:
17+
chapter:
18+
- name: chap1
19+
folder: Chapter01
20+
- name: chap2
21+
folder: Chapter02
22+
- name: chap3
23+
folder: Chapter03
24+
- name: chap6
25+
folder: Chapter06
1326
runs-on: ubuntu-latest
27+
name: Image ${{ matrix.chapter.name }}
1428
steps:
1529
- name: Checkout repository
1630
uses: actions/checkout@v3
1731

32+
- name: Extract branch name
33+
shell: bash
34+
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
35+
id: extract_branch
36+
1837
- name: Build Image
1938
id: build
2039
run: |
2140
cd docker
22-
docker build . -t graph-machine-learning:latest --no-cache
41+
docker build . --target ${{ matrix.chapter.name }} \
42+
--build-arg branch=${{ steps.extract_branch.outputs.branch }} \
43+
-t graph-machine-learning:latest --no-cache
2344
2445
- name: Test Image
2546
id: tests
@@ -32,10 +53,7 @@ jobs:
3253
--name graph-machine-learning-box \
3354
graph-machine-learning:latest
3455
35-
# Run the tests only for chapters managed by poetry
36-
CHAPTERS=$(find Ch* -name poetry.lock -print0 | sed -e 's/\/poetry.lock//g' | xargs -0)
37-
3856
# Run tests
3957
cd docker
4058
41-
./tests.sh $CHAPTERS
59+
./tests.sh ${{ matrix.chapter.folder }}

Chapter01/01_Introduction_Networkx.ipynb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
"%matplotlib inline\n",
2020
"import matplotlib.pyplot as plt\n",
2121
"\n",
22+
"import os\n",
23+
"import sys\n",
24+
"\n",
25+
"sys.path.append(f\"{os.getcwd()}/..\")\n",
26+
"\n",
2227
"from utils import draw_graph"
2328
]
2429
},

Chapter01/02_Graph_metrics.ipynb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
"%matplotlib inline\n",
2424
"import matplotlib.pyplot as plt\n",
2525
"\n",
26+
"import os\n",
27+
"import sys\n",
28+
"\n",
29+
"sys.path.append(f\"{os.getcwd()}/..\")\n",
30+
"\n",
2631
"from utils import draw_graph, draw_enhanced_path"
2732
]
2833
},

Chapter01/03_Graphs_Benchmarks.ipynb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
"%matplotlib inline\n",
2020
"import matplotlib.pyplot as plt\n",
2121
"\n",
22+
"import os\n",
23+
"import sys\n",
24+
"\n",
25+
"sys.path.append(f\"{os.getcwd()}/..\")\n",
26+
"\n",
2227
"from utils import draw_graph, FIGURES_DIR, DATA_DIR"
2328
]
2429
},

Chapter02/01_embedding_examples.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"\n",
1919
"sys.path.append(f\"{os.getcwd()}/..\")\n",
2020
"\n",
21-
"from Chapter01.utils import draw_graph"
21+
"from utils import draw_graph"
2222
]
2323
},
2424
{

Chapter03/01_Shallow_Embeddings.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"\n",
1919
"sys.path.append(f\"{os.getcwd()}/..\")\n",
2020
"\n",
21-
"from Chapter01.utils import draw_graph"
21+
"from utils import draw_graph"
2222
]
2323
},
2424
{

Chapter03/03_Structural_deep_neural_embeddings.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"\n",
1919
"sys.path.append(f\"{os.getcwd()}/..\")\n",
2020
"\n",
21-
"from Chapter01.utils import DATA_DIR"
21+
"from utils import DATA_DIR"
2222
]
2323
},
2424
{

Chapter03/04_Graph_Neural_Network.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"\n",
3232
"sys.path.append(f\"{os.getcwd()}/..\")\n",
3333
"\n",
34-
"from Chapter01.utils import draw_graph, FIGURES_DIR\n",
34+
"from utils import draw_graph, FIGURES_DIR\n",
3535
"\n",
3636
"%matplotlib inline\n",
3737
"import matplotlib.pyplot as plt"

Chapter05/02_community_detection_algorithms.ipynb

Lines changed: 94 additions & 67 deletions
Large diffs are not rendered by default.

docker/Dockerfile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
FROM jupyter/scipy-notebook
1+
FROM jupyter/scipy-notebook as base
22

33
ARG user=euler
4+
ARG branch=chap6
45

56
USER root
67

@@ -16,29 +17,34 @@ ENV NB_USER=${user}
1617
ENV XDG_CACHE_HOME=/home/${user}/.cache/
1718

1819
RUN git clone https://github.com/deusebio/Graph-Machine-Learning.git /home/${user}/Graph-Machine-Learning
19-
2020
WORKDIR /home/${user}/Graph-Machine-Learning
21+
RUN git checkout ${branch}
2122

2223
RUN ln -s /data data
24+
EXPOSE 8888
2325

24-
RUN git checkout chap6
26+
ENTRYPOINT jupyter notebook --no-browser --port 8888 --NotebookApp.token='' --NotebookApp.password=''
2527

28+
FROM base as chap1
29+
RUN ls -d -1 */ | grep -v -e Chapter01 | xargs rm -rf
2630
RUN conda create -n chap1 python=3.9
2731
RUN conda run -n chap1 pip install -r Chapter01/requirements.txt
2832
RUN conda run -n chap1 python -m ipykernel install --name chap1 --user
2933

34+
FROM base as chap2
35+
RUN ls -d -1 */ | grep -v -e Chapter02 | xargs rm -rf
3036
RUN conda create -n chap2 python=3.11
3137
RUN conda run -n chap2 pip install -r Chapter02/requirements.txt
3238
RUN conda run -n chap2 python -m ipykernel install --name chap2 --user
3339

40+
FROM base as chap3
41+
RUN ls -d -1 */ | grep -v -e Chapter03 | xargs rm -rf
3442
RUN conda create -n chap3 python=3.8
3543
RUN conda run -n chap3 pip install -r Chapter03/requirements.txt
3644
RUN conda run -n chap3 python -m ipykernel install --name chap3 --user
3745

46+
FROM base as chap6
47+
RUN ls -d -1 */ | grep -v -e Chapter06 | xargs rm -rf
3848
RUN conda create -n chap6 python=3.8
3949
RUN conda run -n chap6 pip install -r Chapter06/requirements.txt
4050
RUN conda run -n chap6 python -m ipykernel install --name chap6 --user
41-
42-
EXPOSE 8888
43-
44-
ENTRYPOINT jupyter notebook --no-browser --port 8888 --NotebookApp.token='' --NotebookApp.password=''

0 commit comments

Comments
 (0)