refactor python in GH actions (#5281)

* refactor python in GH actions

* .
* .

(cherry picked from commit ab7512d7ba)
This commit is contained in:
Jirka Borovec 2020-12-31 17:24:33 +01:00 committed by Jirka Borovec
parent 14a204f42e
commit 336570b2ea
1 changed files with 31 additions and 10 deletions

View File

@ -47,26 +47,47 @@ jobs:
if: runner.os == 'windows'
run: |
# remove Horovod from requirements
python -c "fname = 'requirements/extra.txt' ; lines = [line for line in open(fname).readlines() if not line.startswith('horovod')] ; open(fname, 'w').writelines(lines)"
fname = 'requirements/extra.txt'
lines = [line for line in open(fname).readlines() if not line.startswith('horovod')]
open(fname, 'w').writelines(lines)
shell: python
# versions <= 1.3 may have issues on mac with some BLAS ops due to missing mkl (https://github.com/pytorch/pytorch/issues/18996)
- name: Adjust minimal for Python 3.8 and MacOS
if: matrix.requires == 'minimal' && (runner.os == 'macOS' || matrix.python-version == 3.8)
run : |
python -c "fname = 'requirements.txt' ; req = open(fname).read().replace('torch>=1.3', 'torch>=1.4') ; open(fname, 'w').write(req)"
python -c "fname = 'requirements/examples.txt' ; req = open(fname).read().replace('torchvision>=0.4.1', 'torchvision>=0.5.0') ; open(fname, 'w').write(req)"
python -c "fname = 'requirements/extra.txt' ; req = open(fname).read().replace('torchtext>=0.3.1', 'torchtext>=0.5.0') ; open(fname, 'w').write(req)"
fname = 'requirements.txt'
req = open(fname).read().replace('torch>=1.3', 'torch>=1.4')
open(fname, 'w').write(req)
fname = 'requirements/examples.txt'
req = open(fname).read().replace('torchvision>=0.4.1', 'torchvision>=0.5.0')
open(fname, 'w').write(req)
fname = 'requirements/extra.txt'
req = open(fname).read().replace('torchtext>=0.3.1', 'torchtext>=0.5.0')
open(fname, 'w').write(req)
shell: python
- name: Set min. dependencies
if: matrix.requires == 'minimal'
run: |
python -c "fname = 'requirements.txt' ; req = open(fname).read().replace('>=', '==') ; open(fname, 'w').write(req)"
python -c "fname = 'requirements/extra.txt' ; req = open(fname).read().replace('>=', '==') ; open(fname, 'w').write(req)"
python -c "fname = 'requirements/loggers.txt' ; req = open(fname).read().replace('>=', '==') ; open(fname, 'w').write(req)"
python -c "fname = 'requirements/test.txt' ; req = open(fname).read().replace('>=', '==') ; open(fname, 'w').write(req)"
python -c "fname = 'requirements/examples.txt' ; req = open(fname).read().replace('>=', '==') ; open(fname, 'w').write(req)"
files = (
'requirements.txt',
'requirements/extra.txt',
'requirements/loggers.txt',
'requirements/test.txt',
'requirements/examples.txt',
)
for fname in files:
req = open(fname).read().replace('>=', '==')
open(fname, 'w').write(req)
# remove Fairscale from requirements
python -c "fname = 'requirements/extra.txt' ; lines = [line for line in open(fname).readlines() if 'fairscale' not in line] ; open(fname, 'w').writelines(lines)"
fname = 'requirements/extra.txt'
lines = [line for line in open(fname).readlines() if 'fairscale' not in line]
open(fname, 'w').writelines(lines)
shell: python
# Note: This uses an internal pip API and may not always work
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow