Skip to content

Commit ab7512d

Browse files
authored
refactor python in GH actions (#5281)
* refactor python in GH actions * . * .
1 parent 64163c2 commit ab7512d

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

.github/workflows/ci_test-full.yml

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,47 @@ jobs:
4747
if: runner.os == 'windows'
4848
run: |
4949
# remove Horovod from requirements
50-
python -c "fname = 'requirements/extra.txt' ; lines = [line for line in open(fname).readlines() if not line.startswith('horovod')] ; open(fname, 'w').writelines(lines)"
50+
fname = 'requirements/extra.txt'
51+
lines = [line for line in open(fname).readlines() if not line.startswith('horovod')]
52+
open(fname, 'w').writelines(lines)
53+
shell: python
5154

5255
# versions <= 1.3 may have issues on mac with some BLAS ops due to missing mkl (https://github.com/pytorch/pytorch/issues/18996)
5356
- name: Adjust minimal for Python 3.8 and MacOS
5457
if: matrix.requires == 'minimal' && (runner.os == 'macOS' || matrix.python-version == 3.8)
5558
run : |
56-
python -c "fname = 'requirements.txt' ; req = open(fname).read().replace('torch>=1.3', 'torch>=1.4') ; open(fname, 'w').write(req)"
57-
python -c "fname = 'requirements/examples.txt' ; req = open(fname).read().replace('torchvision>=0.4.1', 'torchvision>=0.5.0') ; open(fname, 'w').write(req)"
58-
python -c "fname = 'requirements/extra.txt' ; req = open(fname).read().replace('torchtext>=0.3.1', 'torchtext>=0.5.0') ; open(fname, 'w').write(req)"
59+
fname = 'requirements.txt'
60+
req = open(fname).read().replace('torch>=1.3', 'torch>=1.4')
61+
open(fname, 'w').write(req)
62+
63+
fname = 'requirements/examples.txt'
64+
req = open(fname).read().replace('torchvision>=0.4.1', 'torchvision>=0.5.0')
65+
open(fname, 'w').write(req)
66+
67+
fname = 'requirements/extra.txt'
68+
req = open(fname).read().replace('torchtext>=0.3.1', 'torchtext>=0.5.0')
69+
open(fname, 'w').write(req)
70+
shell: python
5971

6072
- name: Set min. dependencies
6173
if: matrix.requires == 'minimal'
6274
run: |
63-
python -c "fname = 'requirements.txt' ; req = open(fname).read().replace('>=', '==') ; open(fname, 'w').write(req)"
64-
python -c "fname = 'requirements/extra.txt' ; req = open(fname).read().replace('>=', '==') ; open(fname, 'w').write(req)"
65-
python -c "fname = 'requirements/loggers.txt' ; req = open(fname).read().replace('>=', '==') ; open(fname, 'w').write(req)"
66-
python -c "fname = 'requirements/test.txt' ; req = open(fname).read().replace('>=', '==') ; open(fname, 'w').write(req)"
67-
python -c "fname = 'requirements/examples.txt' ; req = open(fname).read().replace('>=', '==') ; open(fname, 'w').write(req)"
75+
files = (
76+
'requirements.txt',
77+
'requirements/extra.txt',
78+
'requirements/loggers.txt',
79+
'requirements/test.txt',
80+
'requirements/examples.txt',
81+
)
82+
for fname in files:
83+
req = open(fname).read().replace('>=', '==')
84+
open(fname, 'w').write(req)
85+
6886
# remove Fairscale from requirements
69-
python -c "fname = 'requirements/extra.txt' ; lines = [line for line in open(fname).readlines() if 'fairscale' not in line] ; open(fname, 'w').writelines(lines)"
87+
fname = 'requirements/extra.txt'
88+
lines = [line for line in open(fname).readlines() if 'fairscale' not in line]
89+
open(fname, 'w').writelines(lines)
90+
shell: python
7091

7192
# Note: This uses an internal pip API and may not always work
7293
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow

0 commit comments

Comments
 (0)