Skip to content

Commit dbaa69e

Browse files
adarshyogaZzEeKkAa
authored andcommitted
adding conda recipe
1 parent b851eec commit dbaa69e

File tree

4 files changed

+529
-0
lines changed

4 files changed

+529
-0
lines changed
Lines changed: 369 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,369 @@
1+
# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: Conda package
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
13+
env:
14+
PACKAGE_NAME: dpbench
15+
MODULE_NAME: dpbench
16+
CHANNELS: '-c dppy/label/dev -c intel -c conda-forge --override-channels'
17+
VER_JSON_NAME: 'version.json'
18+
VER_SCRIPT1: "import json; f = open('version.json', 'r'); j = json.load(f); f.close(); "
19+
VER_SCRIPT2: "d = j['dpbench'][0]; print('='.join((d[s] for s in ('version', 'build'))))"
20+
21+
jobs:
22+
build:
23+
name: Build ['${{ matrix.os }}', python='${{ matrix.python }}']
24+
25+
strategy:
26+
matrix:
27+
python: ['3.9', '3.10']
28+
os: [ubuntu-latest, windows-latest]
29+
30+
runs-on: ${{ matrix.os }}
31+
32+
defaults:
33+
run:
34+
shell: ${{ matrix.os == 'windows-latest' && 'cmd /C CALL {0}' || 'bash -l {0}' }}
35+
36+
continue-on-error: false
37+
38+
steps:
39+
- name: Cancel Previous Runs
40+
uses: styfle/[email protected]
41+
with:
42+
access_token: ${{ github.token }}
43+
44+
- name: Checkout DPBENCH repo
45+
uses: actions/[email protected]
46+
with:
47+
fetch-depth: 0
48+
49+
- name: Setup miniconda
50+
uses: conda-incubator/[email protected]
51+
with:
52+
auto-update-conda: true
53+
python-version: ${{ matrix.python }}
54+
miniconda-version: 'latest'
55+
activate-environment: 'build'
56+
57+
- if: matrix.os == 'ubuntu-latest'
58+
name: Store conda paths as envs on Linux
59+
run: echo "CONDA_BLD=$CONDA_PREFIX/conda-bld/linux-64/" >> $GITHUB_ENV
60+
61+
- if: matrix.os == 'windows-latest'
62+
name: Store conda paths as envs on Win
63+
run: |
64+
@echo on
65+
(echo CONDA_BLD=%CONDA_PREFIX%\conda-bld\win-64\) >> %GITHUB_ENV%
66+
67+
- name: Install conda-build
68+
run: conda install conda-build
69+
70+
- name: Cache conda packages
71+
uses: actions/[email protected]
72+
env:
73+
CACHE_NUMBER: 1 # Increase to reset cache
74+
with:
75+
path: ${{ env.CONDA_PKGS_DIR }}
76+
key:
77+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
78+
restore-keys: |
79+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
80+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
81+
82+
- name: Build conda package
83+
run: conda build --no-test --python ${{ matrix.python }} ${{ env.CHANNELS }} conda-recipe
84+
85+
- name: Upload artifact
86+
uses: actions/[email protected]
87+
with:
88+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
89+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.tar.bz2
90+
91+
test_linux:
92+
name: Test ['${{ matrix.os }}', python='${{ matrix.python }}']
93+
94+
needs: build
95+
96+
runs-on: ${{ matrix.os }}
97+
98+
defaults:
99+
run:
100+
shell: bash -l {0}
101+
102+
strategy:
103+
matrix:
104+
python: ['3.9', '3.10']
105+
os: [ubuntu-linux, ubuntu-latest]
106+
experimental: [false]
107+
108+
continue-on-error: ${{ matrix.experimental }}
109+
110+
env:
111+
conda-pkgs: '/home/runner/conda_pkgs_dir/'
112+
channel-path: '${{ github.workspace }}/channel/'
113+
pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/'
114+
extracted-pkg-path: '${{ github.workspace }}/pkg/'
115+
tests-path: '${{ github.workspace }}/pkg/info/test/tests/'
116+
ver-json-path: '${{ github.workspace }}/version.json'
117+
118+
steps:
119+
- name: Download artifact
120+
uses: actions/[email protected]
121+
with:
122+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
123+
path: ${{ env.pkg-path-in-channel }}
124+
125+
- name: Extract package archive
126+
run: |
127+
mkdir -p ${{ env.extracted-pkg-path }}
128+
tar -xvf ${{ env.pkg-path-in-channel }}/${{ env.PACKAGE_NAME }}-*.tar.bz2 -C ${{ env.extracted-pkg-path }}
129+
130+
- name: Setup miniconda
131+
uses: conda-incubator/[email protected]
132+
with:
133+
auto-update-conda: true
134+
python-version: ${{ matrix.python }}
135+
miniconda-version: 'latest'
136+
activate-environment: 'test'
137+
138+
# Needed to be able to run conda index
139+
- name: Install conda-build
140+
run: conda install conda-build
141+
142+
- name: Create conda channel
143+
run: conda index ${{ env.channel-path }}
144+
145+
- name: Test conda channel
146+
run: |
147+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
148+
cat ${{ env.ver-json-path }}
149+
150+
- name: Collect dependencies
151+
run: |
152+
export PACKAGE_VERSION=$(python -c "${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}")
153+
154+
echo PACKAGE_VERSION=${PACKAGE_VERSION}
155+
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
156+
157+
conda install ${{ env.PACKAGE_NAME }}=${PACKAGE_VERSION} python=${{ matrix.python }} ${{ env.TEST_CHANNELS }} --only-deps --dry-run > lockfile
158+
cat lockfile
159+
env:
160+
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
161+
162+
- name: Cache conda packages
163+
uses: actions/[email protected]
164+
env:
165+
CACHE_NUMBER: 1 # Increase to reset cache
166+
with:
167+
path: ${{ env.conda-pkgs }}
168+
key:
169+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
170+
restore-keys: |
171+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
172+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
173+
174+
- name: Install dpbench
175+
run: conda install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
176+
env:
177+
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
178+
179+
- name: List installed packages
180+
run: conda list
181+
182+
- name: Smoke test
183+
run: python -c "import dpnp, dpctl, dpbench; dpctl.lsplatform()"
184+
185+
- name: Run benchmakrs
186+
run: |
187+
dpbench run -i numpy,numba_dpex_p,dpnp,numba_n
188+
working-directory: ${{ env.tests-path }}
189+
190+
# test_windows:
191+
# name: Test ['windows-latest', python='${{ matrix.python }}']
192+
193+
# needs: build
194+
195+
# runs-on: windows-latest
196+
197+
# defaults:
198+
# run:
199+
# shell: cmd /C CALL {0}
200+
201+
# strategy:
202+
# matrix:
203+
# python: ['3.8', '3.9', '3.10']
204+
# experimental: [false]
205+
206+
# continue-on-error: ${{ matrix.experimental }}
207+
208+
# env:
209+
# conda-pkgs: 'C:\Users\runneradmin\conda_pkgs_dir\'
210+
# channel-path: '${{ github.workspace }}\channel\'
211+
# pkg-path-in-channel: '${{ github.workspace }}\channel\win-64\'
212+
# extracted-pkg-path: '${{ github.workspace }}\pkg'
213+
# tests-path: '${{ github.workspace }}\pkg\info\test\tests\'
214+
# ver-json-path: '${{ github.workspace }}\version.json'
215+
# active-env-name: 'test'
216+
217+
# steps:
218+
# - name: Download artifact
219+
# uses: actions/[email protected]
220+
# with:
221+
# name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
222+
# path: ${{ env.pkg-path-in-channel }}
223+
224+
# - name: Extract package archive
225+
# run: |
226+
# @echo on
227+
# mkdir -p ${{ env.extracted-pkg-path }}
228+
229+
# set SEARCH_SCRIPT="DIR ${{ env.pkg-path-in-channel }} /s/b | FINDSTR /r "dpnp-.*\.tar\.bz2""
230+
# FOR /F "tokens=* USEBACKQ" %%F IN (`%SEARCH_SCRIPT%`) DO (
231+
# SET FULL_PACKAGE_PATH=%%F
232+
# )
233+
# echo FULL_PACKAGE_PATH: %FULL_PACKAGE_PATH%
234+
235+
# python -c "import shutil; shutil.unpack_archive(r\"%FULL_PACKAGE_PATH%\", extract_dir=r\"${{ env.extracted-pkg-path }}\")"
236+
# dir ${{ env.extracted-pkg-path }}
237+
238+
# - name: Setup miniconda
239+
# uses: conda-incubator/[email protected]
240+
# with:
241+
# auto-update-conda: true
242+
# python-version: ${{ matrix.python }}
243+
# miniconda-version: 'latest'
244+
# activate-environment: ${{ env.active-env-name }}
245+
246+
# - name: Store conda paths as envs
247+
# run: |
248+
# @echo on
249+
# (echo CONDA_LIB_PATH=%CONDA_PREFIX%\Library\lib\) >> %GITHUB_ENV%
250+
# (echo CONDA_LIB_BIN_PATH=%CONDA_PREFIX%\Library\bin\) >> %GITHUB_ENV%
251+
252+
# # Needed to be able to run conda index
253+
# - name: Install conda-build
254+
# run: conda install conda-build
255+
256+
# - name: Create conda channel
257+
# run: conda index ${{ env.channel-path }}
258+
259+
# - name: Test conda channel
260+
# run: |
261+
# @echo on
262+
# conda search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
263+
264+
# - name: Dump version.json
265+
# run: more ${{ env.ver-json-path }}
266+
267+
# - name: Collect dependencies
268+
# run: |
269+
# @echo on
270+
# set "SCRIPT=${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}"
271+
# FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
272+
# SET PACKAGE_VERSION=%%F
273+
# )
274+
# echo PACKAGE_VERSION: %PACKAGE_VERSION%
275+
# (echo PACKAGE_VERSION=%PACKAGE_VERSION%) >> %GITHUB_ENV%
276+
277+
# conda install ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} ${{ env.TEST_CHANNELS }} --only-deps --dry-run > lockfile
278+
# env:
279+
# TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
280+
281+
# - name: Dump lockfile
282+
# run: more lockfile
283+
284+
# - name: Cache conda packages
285+
# uses: actions/[email protected]
286+
# env:
287+
# CACHE_NUMBER: 1 # Increase to reset cache
288+
# with:
289+
# path: ${{ env.conda-pkgs }}
290+
# key:
291+
# ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
292+
# restore-keys: |
293+
# ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
294+
# ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
295+
296+
# - name: Install opencl_rt
297+
# run: conda install opencl_rt -c intel --override-channels
298+
299+
# - name: Install dpnp
300+
# run: |
301+
# @echo on
302+
# conda install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
303+
# env:
304+
# TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
305+
306+
# - name: List installed packages
307+
# run: conda list
308+
309+
# - name: Activate OCL CPU RT
310+
# shell: pwsh
311+
# run: |
312+
# $script_path="$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1"
313+
# &$script_path
314+
# # Check the variable assisting OpenCL CPU driver to find TBB DLLs which are not located where it expects them by default
315+
# $cl_cfg="$env:CONDA_PREFIX\Library\lib\cl.cfg"
316+
# Get-Content -Tail 5 -Path $cl_cfg
317+
318+
# - name: Smoke test
319+
# run: python -c "import dpnp, dpctl; dpctl.lsplatform()"
320+
321+
# # TODO: run the whole scope once the issues on CPU are resolved
322+
# - name: Run tests
323+
# run: |
324+
# python -m pytest -q -ra --disable-warnings -vv ${{ env.TEST_SCOPE }}
325+
# working-directory: ${{ env.tests-path }}
326+
327+
# upload:
328+
# name: Upload ['${{ matrix.os }}', python='${{ matrix.python }}']
329+
330+
# needs: [test_linux, test_windows]
331+
332+
# strategy:
333+
# matrix:
334+
# python: ['3.9', '3.10']
335+
# os: [ubuntu-20.04, windows-latest]
336+
337+
# runs-on: ${{ matrix.os }}
338+
339+
# defaults:
340+
# run:
341+
# shell: ${{ matrix.os == 'windows-latest' && 'cmd /C CALL {0}' || 'bash -l {0}' }}
342+
343+
# continue-on-error: false
344+
345+
# if: |
346+
# (github.repository == 'IntelPython/dpnp') &&
347+
# (github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
348+
349+
# steps:
350+
# - name: Download artifact
351+
# uses: actions/[email protected]
352+
# with:
353+
# name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
354+
355+
# - name: Setup miniconda
356+
# uses: conda-incubator/[email protected]
357+
# with:
358+
# auto-update-conda: true
359+
# python-version: ${{ matrix.python }}
360+
# miniconda-version: 'latest'
361+
# activate-environment: 'upload'
362+
363+
# - name: Install anaconda-client
364+
# run: conda install anaconda-client
365+
366+
# - name: Upload
367+
# run: anaconda --token ${{ env.ANACONDA_TOKEN }} upload --user dppy --label dev ${{ env.PACKAGE_NAME }}-*.tar.bz2
368+
# env:
369+
# ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}

0 commit comments

Comments
 (0)