-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
188 lines (155 loc) · 8.03 KB
/
Makefile
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
#
# Copyright (c) 2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
# Note: These are just placeholders for future additions to Makefile.
# You can remove these comments later.
DOCS_VENV = ".venv/docs"
NOTEBOOKS_VENV = ".venv/notebooks"
PYTORCH_VENV = ".venv/pytorch"
TENSORFLOW_VENV = ".venv/tensorflow"
TEST_VENV = ".venv/test"
RELEASE_VENV = ".venv/releases"
LATEST_RELEASE=$(RELEASE_VENV)/$(shell date +"%Y-%m-%d-%H-%M-%S")
ACTIVATE_DOCS_VENV = $(DOCS_VENV)/bin/activate
ACTIVATE_NOTEBOOKS_VENV = $(NOTEBOOKS_VENV)/bin/activate
ACTIVATE_PYTORCH_VENV = $(PYTORCH_VENV)/bin/activate
ACTIVATE_TENSORFLOW_VENV = ${TENSORFLOW_VENV}/bin/activate
ACTIVATE_TEST_VENV = "$(TEST_VENV)/bin/activate"
ACTIVATE_RELEASE_VENV = "$(RELEASE_VENV)/bin/activate"
# Customize sample test run commands
# PY_TEST_EXTRA_ARGS="'-vvv -k test_platform_util_with_no_args'" make test
# PY_TEST_EXTRA_ARGS="'--collect-only'" make test
PY_TEST_EXTRA_ARGS ?= "--durations=0"
test_venv:
@echo "Creating a virtualenv for testing..."
@test -d $(TEST_VENV) || virtualenv -p python3 $(TEST_VENV)
@echo "Installing test dependencies..."
@. $(ACTIVATE_TEST_VENV) && pip install -r $(CURDIR)/tests/requirements-test.txt
pytorch_venv:
@echo "Creating a virtualenv for testing pytorch..."
@test -d $(PYTORCH_VENV) || virtualenv -p python3 $(PYTORCH_VENV)
@echo "Installing test dependencies..."
@. $(ACTIVATE_PYTORCH_VENV) && \
pip install -r $(CURDIR)/tests/requirements-test.txt && \
echo "Building the TLT API in pytorch env..." && \
pip install --extra-index-url https://download.pytorch.org/whl/cpu .[pytorch]
tensorflow_venv: test_venv
@echo "Creating a virtualenv for testing tensorflow..."
@test -d $(TENSORFLOW_VENV) || virtualenv -p python3 $(TENSORFLOW_VENV)
@echo "Installing test dependencies..." && \
. $(ACTIVATE_TENSORFLOW_VENV) && \
pip install -r $(CURDIR)/tests/requirements-test.txt && \
echo "Building the TLT API in tensorflow env..." && \
pip install --extra-index-url https://download.pytorch.org/whl/cpu .[tensorflow]
notebooks_venv:
@echo "Creating a virtualenv for notebook testing..."
@test -d $(NOTEBOOKS_VENV) || virtualenv -p python3 $(NOTEBOOKS_VENV)
@echo "Installing TF & PYT notebook dependencies..." && \
. $(ACTIVATE_NOTEBOOKS_VENV) && \
pip install --extra-index-url https://download.pytorch.org/whl/cpu -r $(CURDIR)/notebooks/requirements.txt
lint: test_venv
@echo "Style checks..."
@. $(ACTIVATE_TEST_VENV) && \
flake8 tlt tests downloader docker && \
flake8 notebooks && \
flake8 docs
pytorch_unittest: pytorch_venv
@echo "Testing pytorch unit test API..." && \
. $(ACTIVATE_PYTORCH_VENV) && \
py.test --ignore=tests/tensorflow_tests -vvv -s $(PY_TEST_EXTRA_ARGS) "-k not integration and not skip and not tensorflow"
tensorflow_unittest: tensorflow_venv
@echo "Testing tensorflow unit test API..." && \
. $(ACTIVATE_TENSORFLOW_VENV) && \
py.test --ignore=tests/pytorch_tests -vvv -s $(PY_TEST_EXTRA_ARGS) "-k not integration and not skip and not pytorch"
unittest: pytorch_unittest tensorflow_unittest
pytorch_integration: pytorch_venv
@echo "Testing pytorch unit test API..." && \
. $(ACTIVATE_PYTORCH_VENV) && \
py.test --ignore=tests/tensorflow_tests -vvv -s $(PY_TEST_EXTRA_ARGS) "-k integration and not skip and not tensorflow"
tensorflow_integration: tensorflow_venv
@echo "Testing tensorflow unit test API..." && \
. $(ACTIVATE_TENSORFLOW_VENV) && \
py.test --ignore=tests/pytorch_tests -vvv -s $(PY_TEST_EXTRA_ARGS) "-k integration and not skip and not pytorch"
integration: pytorch_integration tensorflow_integration
pytorch_test: pytorch_unittest pytorch_integration
tensorflow_test: tensorflow_unittest tensorflow_integration
test: pytorch_test tensorflow_test
clean_pytorch:
rm -rf $(PYTORCH_VENV)
clean_tensorflow:
rm -rf $(TENSORFLOW_VENV)
clean_notebooks:
rm -rf $(NOTEBOOKS_VENV)
clean_docs:
rm -rf $(DOCS_VENV)
clean: clean_docs clean_notebooks clean_pytorch clean_tensorflow
docs_venv:
@echo "Creating a virtualenv for build and test docs..."
@test -d $(DOCS_VENV) || virtualenv -p python3 $(DOCS_VENV)
@echo "Installing docs dependencies..." && \
. $(ACTIVATE_DOCS_VENV) && \
pip install -r $(CURDIR)/docs/requirements-docs.txt && \
echo "Installing all TLT dependencies" && \
pip install --extra-index-url https://download.pytorch.org/whl/cpu .[pytorch,tensorflow]
html: docs_venv
@echo "Building Sphinx documentation..."
@. $(ACTIVATE_DOCS_VENV) && $(MAKE) -C docs clean html
test_docs: html
@echo "Testing Sphinx documentation..."
@. $(ACTIVATE_DOCS_VENV) && $(MAKE) -C docs doctest
test_pytorch_notebooks: notebooks_venv
@. $(ACTIVATE_NOTEBOOKS_VENV) && \
pip install --extra-index-url https://download.pytorch.org/whl/cpu .[pytorch] && \
bash run_notebooks.sh pytorch
test_tensorflow_notebooks: notebooks_venv
@. $(ACTIVATE_NOTEBOOKS_VENV) && \
pip install --extra-index-url https://download.pytorch.org/whl/cpu .[tensorflow] && \
bash run_notebooks.sh tensorflow
test_custom_notebooks: notebooks_venv
@echo "Testing Jupyter notebooks with custom datasets..."
@. $(ACTIVATE_NOTEBOOKS_VENV) && \
pip install --extra-index-url https://download.pytorch.org/whl/cpu .[pytorch,tensorflow] && \
bash run_notebooks.sh $(CURDIR)/notebooks/image_classification/tlt_api_pyt_image_classification/TLT_PyTorch_Image_Classification_Transfer_Learning.ipynb remove_for_custom_dataset && \
bash run_notebooks.sh $(CURDIR)/notebooks/text_classification/tlt_api_pyt_text_classification/TLT_PYT_Text_Classification.ipynb remove_for_custom_dataset && \
bash run_notebooks.sh $(CURDIR)/notebooks/image_classification/tlt_api_tf_image_classification/TLT_TF_Image_Classification_Transfer_Learning.ipynb remove_for_custom_dataset && \
bash run_notebooks.sh $(CURDIR)/notebooks/text_classification/tlt_api_tf_text_classification/TLT_TF_Text_Classification.ipynb remove_for_custom_dataset
test_catalog_notebooks: notebooks_venv
@echo "Testing Jupyter notebooks with public catalog datasets..."
@. $(ACTIVATE_NOTEBOOKS_VENV) && \
pip install --extra-index-url https://download.pytorch.org/whl/cpu .[pytorch,tensorflow] && \
bash run_notebooks.sh $(CURDIR)/notebooks/image_classification/tlt_api_pyt_image_classification/TLT_PyTorch_Image_Classification_Transfer_Learning.ipynb remove_for_tv_dataset && \
bash run_notebooks.sh $(CURDIR)/notebooks/text_classification/tlt_api_pyt_text_classification/TLT_PYT_Text_Classification.ipynb remove_for_hf_dataset && \
bash run_notebooks.sh $(CURDIR)/notebooks/image_classification/tlt_api_tf_image_classification/TLT_TF_Image_Classification_Transfer_Learning.ipynb remove_for_tf_dataset && \
bash run_notebooks.sh $(CURDIR)/notebooks/text_classification/tlt_api_tf_text_classification/TLT_TF_Text_Classification.ipynb remove_for_tf_dataset
release_venv:
@echo "Creating a virtualenv for to create the installer..."
@test -d $(RELEASE_VENV) || virtualenv -p python3 $(RELEASE_VENV)
@. $(ACTIVATE_RELEASE_VENV) && \
python setup.py bdist_wheel && \
mkdir $(LATEST_RELEASE) && \
mv build dist *.egg-info $(LATEST_RELEASE) && \
cp -rp $(LATEST_RELEASE) $(RELEASE_VENV)/latest
check_release: release_venv
@echo "Create and smoke test PyPi wheel..." && \
. $(ACTIVATE_RELEASE_VENV) && \
pip install twine && \
twine check $(RELEASE_VENV)/latest/dist/intel_transfer_learning_tool*.whl
# Only run this if absolutely sure to publish the wheel on PyPi
# release:
# @echo "Publish PyPi wheel..." && \
# . $(ACTIVATE_RELEASE_VENV) && \
# twine upload --verbose --repository-url https://upload.pypi.org/legacy/ $(RELEASE_VENV)/<RELEASE_DIR>/dist/<WHEEL_NAME_HERE>