Skip to content

Commit 5490ad5

Browse files
samaidnpolina4
andauthored
Added Game-Of-Life demo (#44)
* Update environment.yml * Added Game-Of-Life demo * Fixed isort * Removed images dir to avoid flat directories for conda-build * Fixed pytest unrecognized argument * Update environment.yml * fix test run job * fixed no stop frames_count --------- Co-authored-by: Natalia Polina <[email protected]>
1 parent 7112f56 commit 5490ad5

24 files changed

+1261
-13
lines changed

Diff for: .github/workflows/gol_build_test_upload.yml

+339
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,339 @@
1+
name: gol package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
env:
10+
PACKAGE_NAME: game-of-life-demo
11+
MODULE_NAME: game_of_life_demo
12+
13+
jobs:
14+
build_linux:
15+
runs-on: ubuntu-20.04
16+
17+
strategy:
18+
matrix:
19+
python: ['3.8', '3.9', '3.10']
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Set pkgs_dirs
26+
run: |
27+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
28+
- name: Cache conda packages
29+
uses: actions/cache@v3
30+
env:
31+
CACHE_NUMBER: 4 # Increase to reset cache
32+
with:
33+
path: ~/.conda/pkgs
34+
key:
35+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
36+
restore-keys: |
37+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
38+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
39+
- name: Add conda to system path
40+
run: echo $CONDA/bin >> $GITHUB_PATH
41+
- name: Install conda-build
42+
run: conda install conda-build
43+
- name: Build conda package
44+
run: |
45+
CHANNELS="-c dppy/label/dev -c intel -c conda-forge --override-channels"
46+
VERSIONS="--python ${{ matrix.python }}"
47+
TEST="--no-test"
48+
cd ./demos/game-of-life
49+
conda build \
50+
$TEST \
51+
$VERSIONS \
52+
$CHANNELS \
53+
conda-recipe
54+
- name: Upload artifact
55+
uses: actions/upload-artifact@v3
56+
with:
57+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
58+
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.tar.bz2
59+
60+
build_windows:
61+
runs-on: windows-latest
62+
63+
strategy:
64+
matrix:
65+
python: ['3.8', '3.9', '3.10']
66+
env:
67+
conda-bld: C:\Miniconda\conda-bld\win-64\
68+
steps:
69+
- uses: actions/checkout@v3
70+
with:
71+
fetch-depth: 0
72+
- uses: conda-incubator/setup-miniconda@v2
73+
with:
74+
use-only-tar-bz2: false
75+
auto-activate-base: true
76+
conda-build-version: "*"
77+
activate-environment: true
78+
python-version: ${{ matrix.python }}
79+
80+
- name: Cache conda packages
81+
uses: actions/cache@v3
82+
env:
83+
CACHE_NUMBER: 4 # Increase to reset cache
84+
with:
85+
path: /home/runner/conda_pkgs_dir
86+
key:
87+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
88+
restore-keys: |
89+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
90+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
91+
- name: Build conda package
92+
run: |
93+
cd ./demos/game-of-life
94+
conda build --keep-old-work --dirty --no-test --python ${{ matrix.python }} -c dppy/label/dev -c intel -c conda-forge --override-channels conda-recipe
95+
- name: Upload artifact
96+
uses: actions/upload-artifact@v3
97+
with:
98+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
99+
path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.tar.bz2
100+
101+
test_linux:
102+
needs: build_linux
103+
runs-on: ${{ matrix.runner }}
104+
105+
strategy:
106+
matrix:
107+
python: ['3.8', '3.9', '3.10']
108+
experimental: [false]
109+
runner: [ubuntu-20.04]
110+
continue-on-error: ${{ matrix.experimental }}
111+
env:
112+
CHANNELS: -c dppy/label/dev -c intel -c conda-forge --override-channels
113+
114+
steps:
115+
- uses: actions/checkout@v3
116+
with:
117+
fetch-depth: 0
118+
- name: Download artifact
119+
uses: actions/download-artifact@v3
120+
with:
121+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
122+
- name: Add conda to system path
123+
run: echo $CONDA/bin >> $GITHUB_PATH
124+
- name: Install conda-build
125+
# Needed to be able to run conda index
126+
run: conda install conda-build
127+
- name: Create conda channel
128+
run: |
129+
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
130+
conda index $GITHUB_WORKSPACE/channel || exit 1
131+
mv ${PACKAGE_NAME}-*.tar.bz2 $GITHUB_WORKSPACE/channel/linux-64 || exit 1
132+
conda index $GITHUB_WORKSPACE/channel || exit 1
133+
# Test channel
134+
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json
135+
cat ver.json
136+
- name: Collect dependencies
137+
run: |
138+
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
139+
conda create -n test-env $PACKAGE_NAME python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile
140+
cat lockfile
141+
- name: Set pkgs_dirs
142+
run: |
143+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
144+
- name: Cache conda packages
145+
uses: actions/cache@v3
146+
env:
147+
CACHE_NUMBER: 4 # Increase to reset cache
148+
with:
149+
path: ~/.conda/pkgs
150+
key:
151+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
152+
restore-keys: |
153+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
154+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
155+
- name: Install package
156+
run: |
157+
export CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
158+
conda create -n test-env $PACKAGE_NAME ${TEST_DEPENDENCIES} python=${{ matrix.python }} ${CHANNELS}
159+
. $CONDA/etc/profile.d/conda.sh
160+
conda activate test-env
161+
pip install pytest-mock
162+
# Test installed packages
163+
conda list -n test-env
164+
- name: Run tests (numpy)
165+
run: |
166+
. $CONDA/etc/profile.d/conda.sh
167+
conda activate test-env
168+
export OCL_ICD_FILENAMES=libintelocl.so
169+
pytest ./demos/game-of-life/game_of_life_demo --variant numpy
170+
- name: Run tests (dpnp)
171+
run: |
172+
. $CONDA/etc/profile.d/conda.sh
173+
conda activate test-env
174+
export OCL_ICD_FILENAMES=libintelocl.so
175+
pytest ./demos/game-of-life/game_of_life_demo --variant dpnp
176+
- name: Run tests (numba parallel)
177+
run: |
178+
. $CONDA/etc/profile.d/conda.sh
179+
conda activate test-env
180+
export OCL_ICD_FILENAMES=libintelocl.so
181+
pytest ./demos/game-of-life/game_of_life_demo --variant numba --parallel
182+
- name: Run tests (numba no-parallel)
183+
run: |
184+
. $CONDA/etc/profile.d/conda.sh
185+
conda activate test-env
186+
export OCL_ICD_FILENAMES=libintelocl.so
187+
pytest ./demos/game-of-life/game_of_life_demo --variant numba --no-parallel
188+
189+
test_windows:
190+
needs: build_windows
191+
runs-on: ${{ matrix.runner }}
192+
defaults:
193+
run:
194+
shell: cmd /C CALL {0}
195+
strategy:
196+
matrix:
197+
python: ['3.8', '3.9', '3.10']
198+
experimental: [false]
199+
runner: [windows-latest]
200+
continue-on-error: ${{ matrix.experimental }}
201+
env:
202+
workdir: '${{ github.workspace }}'
203+
CHANNELS: -c dppy/label/dev -c intel -c conda-forge --override-channels
204+
steps:
205+
- name: Checkout sources
206+
uses: actions/checkout@v3
207+
with:
208+
fetch-depth: 0
209+
- name: Download artifact
210+
uses: actions/download-artifact@v3
211+
with:
212+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
213+
- uses: conda-incubator/setup-miniconda@v2
214+
with:
215+
use-only-tar-bz2: false
216+
auto-update-conda: true
217+
conda-build-version: '*'
218+
miniconda-version: 'latest'
219+
activate-environment: test-env
220+
python-version: ${{ matrix.python }}
221+
- name: Create conda channel with the artifact bit
222+
shell: cmd /C CALL {0}
223+
run: |
224+
echo ${{ env.workdir }}
225+
mkdir ${{ env.workdir }}\channel\win-64
226+
move ${{ env.PACKAGE_NAME }}-*.tar.bz2 ${{ env.workdir }}\channel\win-64
227+
dir ${{ env.workdir }}\channel\win-64
228+
- name: Index the channel
229+
shell: cmd /C CALL {0}
230+
run: conda index ${{ env.workdir }}\channel
231+
232+
- name: Dump package version info from created channel into ver.json
233+
shell: cmd /C CALL {0}
234+
run: |
235+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.workdir }}/channel --override-channels --info --json > ${{ env.workdir }}\ver.json
236+
- name: Output content of produced ver.json
237+
shell: pwsh
238+
run: Get-Content -Path ${{ env.workdir }}\ver.json
239+
- name: Collect dependencies
240+
shell: cmd /C CALL {0}
241+
run: |
242+
conda install -n test-env ${{ env.PACKAGE_NAME }} python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile && conda activate test-env && pip install pytest-mock
243+
- name: Display lockfile content
244+
shell: pwsh
245+
run: Get-Content -Path .\lockfile
246+
- name: Cache conda packages
247+
uses: actions/cache@v3
248+
env:
249+
CACHE_NUMBER: 4 # Increase to reset cache
250+
with:
251+
path: /home/runner/conda_pkgs_dir
252+
key:
253+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
254+
restore-keys: |
255+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
256+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
257+
- name: Install opencl_rt
258+
shell: cmd /C CALL {0}
259+
run: conda install -n test-env opencl_rt -c intel --override-channels
260+
- name: Install dependencies
261+
shell: cmd /C CALL {0}
262+
run: |
263+
SET "TEST_DEPENDENCIES=pytest pytest-cov"
264+
conda install -n test-env ${{ env.PACKAGE_NAME }} %TEST_DEPENDENCIES% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
265+
- name: Configure Intel OpenCL CPU RT
266+
shell: pwsh
267+
run: |
268+
$script_path="$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1"
269+
&$script_path
270+
# Check the variable assisting OpenCL CPU driver to find TBB DLLs which are not located where it expects them by default
271+
$cl_cfg="$env:CONDA_PREFIX\Library\lib\cl.cfg"
272+
Get-Content -Tail 5 -Path $cl_cfg
273+
cd ./demos/game-of-life
274+
- name: Run tests (numpy)
275+
shell: cmd /C CALL {0}
276+
run: >-
277+
conda activate test-env && pytest ./demos/game-of-life/game_of_life_demo --variant numpy
278+
- name: Run tests (dpnp)
279+
shell: cmd /C CALL {0}
280+
run: >-
281+
conda activate test-env && pytest ./demos/game-of-life/game_of_life_demo --variant dpnp
282+
- name: Run tests (numba no-parallel)
283+
shell: cmd /C CALL {0}
284+
run: >-
285+
conda activate test-env && pytest ./demos/game-of-life/game_of_life_demo --variant numba --no-parallel
286+
- name: Run tests (numba parallel)
287+
shell: cmd /C CALL {0}
288+
run: >-
289+
conda activate test-env && pytest ./demos/game-of-life/game_of_life_demo --variant numba --parallel
290+
291+
292+
upload_linux:
293+
needs: test_linux
294+
if: ${{github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/')}}
295+
runs-on: ubuntu-20.04
296+
strategy:
297+
matrix:
298+
python: ['3.8', '3.9', '3.10']
299+
steps:
300+
- name: Download artifact
301+
uses: actions/download-artifact@v3
302+
with:
303+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
304+
305+
- name: Install anaconda-client
306+
run: conda install anaconda-client
307+
- name: Add conda to system path
308+
run: echo $CONDA/bin >> $GITHUB_PATH
309+
310+
- name: Upload
311+
env:
312+
ANACONDA_TOKEN: ${{ secrets.PYCODDIYTOKEN }}
313+
run: |
314+
anaconda --token $ANACONDA_TOKEN upload --user pycoddiy --label main ${PACKAGE_NAME}-*.tar.bz2
315+
316+
upload_windows:
317+
needs: test_windows
318+
if: ${{github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/')}}
319+
runs-on: windows-latest
320+
strategy:
321+
matrix:
322+
python: ['3.8', '3.9', '3.10']
323+
steps:
324+
- name: Download artifact
325+
uses: actions/download-artifact@v3
326+
with:
327+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
328+
- uses: conda-incubator/setup-miniconda@v2
329+
with:
330+
auto-activate-base: true
331+
activate-environment: ""
332+
- name: Install anaconda-client
333+
run: conda install anaconda-client
334+
335+
- name: Upload
336+
env:
337+
ANACONDA_TOKEN: ${{ secrets.PYCODDIYTOKEN }}
338+
run: |
339+
anaconda --token ${{ env.ANACONDA_TOKEN }} upload --user pycoddiy --label main ${{ env.PACKAGE_NAME }}-*.tar.bz2

0 commit comments

Comments
 (0)