Skip to content

Commit 5839063

Browse files
authored
Make pretrained models optional to install (#590)
* separate pretrained model tests * only test on python 3.10 and 3.11 * fix indentation * fix lint * remove pretrained pipelines from tutorial tests * add installation options
1 parent c48bb62 commit 5839063

File tree

5 files changed

+60
-16
lines changed

5 files changed

+60
-16
lines changed

.github/workflows/tests.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,21 @@ jobs:
124124
run: pip install invoke jupyter matplotlib .
125125
- name: invoke tutorials
126126
run: invoke tutorials
127+
128+
129+
pretrained:
130+
runs-on: ${{ matrix.os }}
131+
strategy:
132+
matrix:
133+
python-version: ['3.10', '3.11']
134+
os: [ubuntu-latest, macos-latest, windows-latest]
135+
steps:
136+
- uses: actions/checkout@v1
137+
- name: Set up Python ${{ matrix.python-version }}
138+
uses: actions/setup-python@v2
139+
with:
140+
python-version: ${{ matrix.python-version }}
141+
- name: Install package and dependencies
142+
run: pip install invoke jupyter .[pretrained]
143+
- name: invoke pretrained
144+
run: invoke pretrained

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ install-test: clean-build clean-pyc ## install the package and test dependencies
8181
install-develop: clean-build clean-pyc ## install the package in editable mode and dependencies for development
8282
pip install -e .[dev]
8383

84+
.PHONY: install-pretrained
85+
install-pretrained: clean-build clean-pyc ## install the package and pretrained pipelines
86+
pip install -e .[pretrained]
87+
88+
.PHONY: install-pretrained-develop
89+
install-pretrained-develop: clean-build clean-pyc ## install the package with pretrained in editable mode and dependencies for development
90+
pip install -e .[pretrained-dev]
91+
8492
MINIMUM := $(shell sed -n '/install_requires = \[/,/]/p' setup.py | grep -v -e '[][]' | sed 's/ *\(.*\),$?$$/\1/g' | tr '>' '=')
8593

8694
.PHONY: install-minimum
@@ -127,6 +135,10 @@ test-readme: ## run the readme snippets
127135
test-tutorials: ## run the tutorial notebooks
128136
invoke tutorials
129137

138+
.PHONY: test-pretrained-tutorials
139+
test-pretrained-tutorials: ## run the tutorial notebooks
140+
invoke pretrained
141+
130142
.PHONY: test
131143
test: test-unit test-readme test-tutorials ## test everything that needs test dependencies
132144

orion/primitives/units.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
import numpy as np
1515
import torch
1616
import torch.nn.functional as F
17-
from smart_open import open as smart_open
18-
from timm.layers import DropPath, Mlp
19-
from timm.layers.helpers import to_2tuple
2017
from torch import nn
2118
from torch.utils.data import DataLoader
2219
from tqdm import tqdm
2320

2421
from orion.data import BUCKET, S3_URL
22+
from smart_open import open as smart_open
23+
from timm.layers import DropPath, Mlp
24+
from timm.layers.helpers import to_2tuple
2525

2626
warnings.filterwarnings('ignore')
2727

setup.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@
3737

3838
# fix conflict
3939
'protobuf<4',
40-
41-
# fails on python 3.6
42-
'opencv-python<4.7',
40+
]
4341

44-
#UniTS
45-
'timm',
42+
pretrained_requires = [
43+
#units
44+
'timm',
4645
'smart_open',
47-
4846
]
4947

5048
setup_requires = [
@@ -128,6 +126,8 @@
128126
extras_require={
129127
'test': tests_require,
130128
'dev': development_requires + tests_require,
129+
'pretrained': pretrained_requires,
130+
'pretrained-dev': pretrained_requires + development_requires + tests_require,
131131
},
132132
include_package_data=True,
133133
install_requires=install_requires,

tasks.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,29 @@ def readme(c):
9292

9393
@task
9494
def tutorials(c):
95+
pipelines = os.listdir(os.path.join('orion', 'pipelines', 'pretrained'))
9596
for ipynb_file in glob.glob('tutorials/*.ipynb') + glob.glob('tutorials/**/*.ipynb'):
96-
if 'OrionDBExplorer' in ipynb_file: # skip db testing
97-
continue
98-
if '.ipynb_checkpoints' not in ipynb_file:
99-
c.run((
100-
'jupyter nbconvert --execute --ExecutePreprocessor.timeout=4400 '
101-
f'--to=html --stdout {ipynb_file}'
102-
), hide='out')
97+
for pipeline in pipelines:
98+
if pipeline in ipynb_file: # skip pretrained pipelines
99+
continue
100+
if '.ipynb_checkpoints' not in ipynb_file:
101+
c.run((
102+
'jupyter nbconvert --execute --ExecutePreprocessor.timeout=4400 '
103+
f'--to=html --stdout {ipynb_file}'
104+
), hide='out')
103105

106+
@task
107+
def pretrained(c):
108+
pipelines = os.listdir(os.path.join('orion', 'pipelines', 'pretrained'))
109+
for ipynb_file in glob.glob('tutorials/pipelines/*.ipynb'):
110+
for pipeline in pipelines:
111+
if pipeline not in ipynb_file: # skip non-pretrained pipelines
112+
continue
113+
if '.ipynb_checkpoints' not in ipynb_file:
114+
c.run((
115+
'jupyter nbconvert --execute --ExecutePreprocessor.timeout=4400 '
116+
f'--to=html --stdout {ipynb_file}'
117+
), hide='out')
104118

105119
@task
106120
def lint(c):

0 commit comments

Comments
 (0)