-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
359 lines (324 loc) · 14.3 KB
/
action.yml
File metadata and controls
359 lines (324 loc) · 14.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# https://github.com/tddschn/install-easygraph
# https://github.com/marketplace/actions/install-easygraph
name: 'Install EasyGraph'
description: 'Action that build and install python-easygraph from source (https://github.com/easy-graph/Easy-Graph)'
branding:
icon: 'download-cloud'
color: 'green'
inputs:
repository:
description: 'Easy-Graph repository, e.g., your fork'
required: false
default: 'easy-graph/Easy-Graph'
ref:
description: 'Branch, tag or commit to checkout for Easy-Graph'
required: false
default: 'pybind11'
install-pytorch:
description: 'Install PyTorch, an optional dependency of Easy-Graph'
required: false
default: 'true'
install-lxml:
description: 'Install lxml, an optional dependency for easygraph (installation would takes longer)'
required: false
default: 'false'
# removed because easygraph doesn't use boost-python anymore
# cpp-binding-framework: # id of input
# description: "The framework used to build easygraph's C++ binding"
# required: false
# default: "pybind11"
# easygraph-checkout-path:
# default: "Easy-Graph"
# description: 'The path to checkout the Easy-Graph repository'
# required: false
# boost-version:
# default: "1.79.0"
# description: 'The version of boost to use'
# required: false
use-cached-build:
default: 'true'
description: 'Use cached build if available'
required: false
python-package-manager-install-command:
default: 'python -m pip install'
# 'conda install --yes'
# 'mamba install --yes'
description: 'The python package manager to use'
required: false
# HOMEBREW_GITHUB_API_TOKEN:
# default: ${{ secrets.GITHUB_TOKEN }}
# description: 'The GitHub token to use for Homebrew'
# required: false
outputs:
site-packages-path:
description: python site-packages path
value: '${{ steps.get-eg-install-location.outputs.site-packages-path }}'
eg-egg-dir-path:
description: easygraph egg directory path
value: '${{ steps.get-eg-install-location.outputs.eg-egg-dir-path }}'
runs:
using: "composite"
steps:
# - name: Print action inputs
# shell: bash
# run: |
# echo '::group::Action Inputs'
# echo '${{ toJSON(inputs) }}'
# echo '::endgroup::'
# - name: Choosing a branch based on the cpp-binding-framework input
# shell: python
# id: choose-branch
# run: |
# cpp_binding_framework = '${{ inputs.cpp-binding-framework }}'
# if cpp_binding_framework == 'pybind11':
# branch = 'pybind11'
# else:
# branch = 'master'
# print('branch: ' + branch)
# # append it to $GITHUB_ENV file, using python
# import os
# github_env_file = os.environ['GITHUB_ENV']
# with open(github_env_file, 'a') as f:
# f.write('BRANCH=' + branch.strip() + '\n')
# - name: Getting the SHA1 of the latest commit of the EasyGraph repository
# shell: bash
# id: 'get-sha1'
# run: |
# echo '::group::Getting the SHA1 of the latest commit of the EasyGraph repository'
# echo "branch: ${{ env.BRANCH }}"
# SHA1="$(git ls-remote https://github.com/easy-graph/Easy-Graph '${{ env.BRANCH }}' | awk '{ print $1 }')"
# echo "SHA1: $SHA1"
# # echo "SHA1=$SHA1" >> $GITHUB_OUTPUT
# echo "EG_SHA1=$SHA1" >> $GITHUB_ENV
# echo '::endgroup::'
- name: Create a temporary dir for checking out easygraph and tddschn/install-easygraph
id: tempdir
# env:
# HOMEBREW_GITHUB_API_TOKEN: ${{ inputs.GITHUB_TOKEN }}
run: |
echo '::group::Creating temp dir'
if [[ "${{ runner.os }}" == "macOS" ]]; then
echo '::group::macOS detected. Installing gmktemp and aliasing it.'
brew install coreutils
# https://github.com/actions/toolkit/issues/766
shopt -s expand_aliases
alias mktemp='gmktemp'
echo '::endgroup::'
fi
EG_TMP_DIR="$(mktemp --directory)"
EG_TMP_DIR_RELATIVE="$(echo "${EG_TMP_DIR}" | cut -c2-)"
ACTION_TMP_DIR="$(mktemp --directory)"
ACTION_TMP_DIR_RELATIVE="$(echo "${ACTION_TMP_DIR}" | cut -c2-)"
echo "EG_TMP_DIR: $EG_TMP_DIR"
echo "ACTION_TMP_DIR: $ACTION_TMP_DIR"
echo "tmp-dir=$EG_TMP_DIR_RELATIVE" >> $GITHUB_OUTPUT
echo "action-tmp-dir=$ACTION_TMP_DIR_RELATIVE" >> $GITHUB_OUTPUT
echo "action-tmp-dir-absolute=$ACTION_TMP_DIR" >> $GITHUB_OUTPUT
echo 'moving temp dirs under workspace'
mkdir -p -v "$GITHUB_WORKSPACE/tmp"
mv -v "$EG_TMP_DIR" "$GITHUB_WORKSPACE/tmp"
mv -v "$ACTION_TMP_DIR" "$GITHUB_WORKSPACE/tmp"
echo '::endgroup::'
shell: bash
- name: 'Checkout tddschn/install-easygraph'
uses: actions/checkout@v3
with:
path: '${{ steps.tempdir.outputs.action-tmp-dir }}'
repository: 'tddschn/install-easygraph'
- name: Get eg installation location
# working dir has no effect
# working-directory: '${{ steps.tempdir.outputs.action-tmp-dir }}'
shell: python
id: get-eg-install-location
run: |
import sys, os
from pathlib import Path
action_dir = '${{ github.workspace }}/${{ steps.tempdir.outputs.action-tmp-dir}}'
sys.path.insert(0, action_dir)
from utils import get_eg_egg_dir_path, set_output, get_site_packages_path, get_sys_version_sha1
eg_egg_dir_path= get_eg_egg_dir_path('${{ inputs.repository }}', '${{ inputs.ref }}')
set_output('site-packages-path', get_site_packages_path())
set_output('eg-egg-dir-path', eg_egg_dir_path)
set_output('python-version', sys.version)
set_output('python-version-sha1', get_sys_version_sha1())
# - name: Using cache on eg installation dir (egg)
- name: Using cache on site-packages/*
if: "inputs.use-cached-build == 'true'"
uses: actions/cache@v3
id: cache
with:
key: 'eg-commit-repo-${{ inputs.repository }}-ref-${{ inputs.ref }}-@python-version-sha1-${{ steps.get-eg-install-location.outputs.python-version-sha1 }}'
path: |
${{ steps.get-eg-install-location.outputs.site-packages-path }}/*
# path: |
# ${{ steps.get-eg-install-location.outputs.eg-egg-dir-path }}
- name: Append eg egg dir to site-packages on cache hit
if: "inputs.use-cached-build != 'true' && steps.cache.outputs.cache-hit == 'true'"
shell: python
run: |
print('::group::Appending eg egg dir to site-packages')
import sys, os
action_dir = '${{ github.workspace }}/${{ steps.tempdir.outputs.action-tmp-dir}}'
sys.path.insert(0, action_dir)
from utils import append_eg_egg_dir_rel_path_to_easy_install_pth
append_eg_egg_dir_rel_path_to_easy_install_pth('${{ inputs.repository }}', '${{ inputs.ref }}')
print('::endgroup::')
- name: checkout Easy-Graph
uses: actions/checkout@v3
with:
repository: '${{ inputs.repository }}'
ref: '${{ inputs.ref }}'
path: ${{ steps.tempdir.outputs.tmp-dir }}
# - name: checkout Easy-Graph master branch
# if: "(inputs.use-cached-build != 'true' || steps.cache.outputs.cache-hit != 'true') && inputs.cpp-binding-framework == 'boost-python'"
# uses: actions/checkout@v3
# with:
# repository: easy-graph/Easy-Graph
# # path: ${{ inputs.easygraph-checkout-path }}
# # uses tmp-dir
# path: ${{ steps.tempdir.outputs.tmp-dir }}
# ref: 'master'
# - name: checkout Easy-Graph pybind11 branch
# if: "(inputs.use-cached-build != 'true' || steps.cache.outputs.cache-hit != 'true') && inputs.cpp-binding-framework == 'pybind11'"
# uses: actions/checkout@v3
# with:
# repository: easy-graph/Easy-Graph
# # path: ${{ inputs.easygraph-checkout-path }}
# path: ${{ steps.tempdir.outputs.tmp-dir }}
# ref: 'pybind11'
# - run: |
# echo '::endgroup::'
# shell: bash
- name: install easygraph dependencies (prior to setup.py)
if: "inputs.use-cached-build != 'true' || steps.cache.outputs.cache-hit != 'true'"
shell: bash
run: |
echo '::group::Installing dependencies (prior to setup.py)'
python -m pip install pytest
python -m pip install Pillow
python -m pip install kiwisolver
python -m pip install gensim
if [[ "${{ inputs.install-lxml }}" == "true" ]]; then
python -m pip install lxml
fi
if [[ "${{ inputs.install-pytorch }}" == "true" ]]; then
python -m pip install torch
fi
echo '::endgroup::'
- name: 'install remaining easygraph dependencies (${{ inputs.python-package-manager-install-command }})'
if: "inputs.use-cached-build != 'true' || steps.cache.outputs.cache-hit != 'true'"
shell: bash
run: |
echo '::group::Installing remaining dependencies'
${{ inputs.python-package-manager-install-command }} numpy pandas matplotlib statsmodels
${{ inputs.python-package-manager-install-command }} tqdm joblib six scikit-learn tensorflow
${{ inputs.python-package-manager-install-command }} scipy progressbar progressbar33
${{ inputs.python-package-manager-install-command }} nose
echo '::endgroup::'
- name: "prepping for building easygraph's cpp binding (pybind11)"
if: "(inputs.use-cached-build != 'true' || steps.cache.outputs.cache-hit != 'true')"
shell: bash
# working-directory: ${{ inputs.easygraph-checkout-path }}
working-directory: '${{ steps.tempdir.outputs.tmp-dir }}'
id: prepping-for-building-pybind11
run: |
echo '::group::prepping for building easygraph'"'"'s cpp binding (pybind11)'
pip install pybind11
echo '::endgroup::'
- name: "build easygraph's cpp binding (pybind11)"
if: "(inputs.use-cached-build != 'true' || steps.cache.outputs.cache-hit != 'true')"
shell: bash
# working-directory: ${{ inputs.easygraph-checkout-path }}
working-directory: '${{ steps.tempdir.outputs.tmp-dir }}'
id: build-pybind11
run: |
echo '::group::building easygraph'"'"'s cpp binding (pybind11)'
python setup.py build_ext
echo '::endgroup::'
# - name: "prepping for building easygraph's cpp binding (boost-python)"
# if: "(inputs.use-cached-build != 'true' || steps.cache.outputs.cache-hit != 'true') && inputs.cpp-binding-framework == 'boost-python'"
# shell: bash
# env:
# BOOST_VERSION: ${{ inputs.boost-version }}
# working-directory: '${{ steps.tempdir.outputs.tmp-dir }}'
# id: prepping-for-building-boost-python
# run: |
# echo '::group::Getting and formatting python and boost versions'
# PYTHON_VERSION="$(python -V | cut -d' ' -f2 | cut -d'.' -f1-2)"
# PYTHON_VERSION_ABBR=${PYTHON_VERSION//./}
# BOOST_VERSION_ALIAS=boost_${BOOST_VERSION//./_}
# echo '::endgroup::'
# echo '::group::Versions info'
# echo "PYTHON_VERSION: ${PYTHON_VERSION}"
# echo "PYTHON_VERSION_ABBR: ${PYTHON_VERSION_ABBR}"
# echo "BOOST_VERSION: ${BOOST_VERSION}"
# echo "BOOST_VERSION_ALIAS: ${BOOST_VERSION_ALIAS}"
# echo '::endgroup::'
# echo '::group::Install build dependencies with apt-get'
# sudo apt-get update
# sudo apt-get install gcc -y
# sudo apt-get install g++ -y
# echo '::endgroup::'
# echo '::group::Downloading and extracting boost'
# wget https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/${BOOST_VERSION_ALIAS}.tar.gz
# tar -xf ${BOOST_VERSION_ALIAS}.tar.gz
# echo '::endgroup::'
# echo '::group::Building boost and boost-python'
# cd ${BOOST_VERSION_ALIAS}
# ./bootstrap.sh --with-python=python
# sudo ./b2 cxxflags="-fPIC" install --with-python
# sudo ln -s /usr/local/lib/libboost_python${PYTHON_VERSION_ABBR}.a /usr/local/lib/libboost_python.a
# echo '::endgroup::'
# - name: "build easygraph's cpp binding (boost-python)"
# if: "(inputs.use-cached-build != 'true' || steps.cache.outputs.cache-hit != 'true') && inputs.cpp-binding-framework == 'boost-python'"
# shell: bash
# env:
# BOOST_VERSION: ${{ inputs.boost-version }}
# working-directory: '${{ steps.tempdir.outputs.tmp-dir }}'
# id: build-boost-python
# run: |
# # echo '::group::Running build_ext'
# echo '::group::build easygraph'"'"'s cpp binding (boost-python)'
# python setup.py build_ext -l boost_python -L "/usr/local/lib" -I "/usr/local/include"
# echo '::endgroup::'
- name: "install easygraph"
if: "inputs.use-cached-build != 'true' || steps.cache.outputs.cache-hit != 'true'"
shell: bash
env:
BOOST_VERSION: ${{ inputs.boost-version }}
working-directory: '${{ steps.tempdir.outputs.tmp-dir }}'
run: |
echo '::group::Installing easygraph'
python setup.py install
echo '::endgroup::'
- name: Test easygraph installation
shell: python
run: |
print('::group::Testing easygraph installation')
try:
import easygraph as eg
import cpp_easygraph as ceg
print(f'eg: {eg}')
print(f'ceg: {ceg}')
except ModuleNotFoundError as e:
import os
from pathlib import Path
site_packages_path = '${{ steps.get-eg-install-location.outputs.site-packages-path }}'
eg_egg_dir_path = '${{ steps.get-eg-install-location.outputs.eg-egg-dir-path }}'
print(f'site_packages_path: {site_packages_path}')
print(f'eg_egg_dir_path: {eg_egg_dir_path}')
print('dir listing of site_packages_path:')
print(os.listdir(site_packages_path))
print('dir listing of eg_egg_dir_path:')
print(os.listdir(eg_egg_dir_path))
raise e
print('::endgroup::')
- name: Remove temp dirs
if: ${{ always() }}
run: |
echo '::group::Removing temp dir'
if [[ -d '$GITHUB_WORKSPACE/tmp' ]]; then
sudo rm -rf "$GITHUB_WORKSPACE/tmp"
fi
echo '::endgroup::'
shell: bash