forked from LLNL/merlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
173 lines (130 loc) · 4.93 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
###############################################################################
# Copyright (c) 2019, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory
# Written by the Merlin dev team, listed in the CONTRIBUTORS file.
#
# LLNL-CODE-797170
# All rights reserved.
# This file is part of Merlin, Version: 1.0.5.
#
# For details, see https://github.com/LLNL/merlin.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
###############################################################################
PYTHON?=python3
PYV=$(shell $(PYTHON) -c "import sys;t='{v[0]}_{v[1]}'.format(v=list(sys.version_info[:2]));sys.stdout.write(t)")
PYVD=$(shell $(PYTHON) -c "import sys;t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));sys.stdout.write(t)")
VENV?=venv_merlin_py$(PYV)
PIP?=$(VENV)/bin/pip
MRLN=merlin/
TEST=tests/
WKFW=merlin/examples/workflows/
MAX_COMPLEXITY?=5
VER?=1.0.0
VSTRING=[0-9]\+\.[0-9]\+\.[0-9]\+
CHANGELOG_VSTRING="## \[$(VSTRING)\]"
INIT_VSTRING="__version__ = \"$(VSTRING)\""
PENV=merlin$(PYV)
.PHONY : all
.PHONY : install-dev
.PHONY : virtualenv
.PHONY : install-workflow-deps
.PHONY : install-pip-mysql
.PHONY : install-merlin
.PHONY : update
.PHONY : pull
.PHONY : clean-output
.PHONY : clean-py
.PHONY : clean
.PHONY : unit-tests
.PHONY : cli-tests
.PHONY : tests
.PHONY : fix-style
.PHONY : check-style
.PHONY : check-camel-case
.PHONY : checks
all: install-dev install-merlin install-workflow-deps install-pip-mysql
# install requirements
install-dev: virtualenv
$(PIP) install -r requirements/dev.txt
# this only works outside the venv
virtualenv:
$(PYTHON) -m venv $(VENV) --prompt $(PENV) --system-site-packages
$(PIP) install --upgrade pip
install-workflow-deps:
$(PIP) install -r $(WKFW)feature_demo/requirements.txt
install-pip-mysql:
$(PIP) install -r requirements/mysql.txt
install-merlin:
$(PIP) install -e .
# this only works outside the venv
update: pull install clean
pull:
git pull
# remove python bytecode files
clean-py:
-find $(MRLN) -name "*.py[cod]" -exec rm -f {} \;
-find $(MRLN) -name "__pycache__" -type d -exec rm -rf {} \;
# remove all studies/ directories
clean-output:
-find $(MRLN) -name "studies*" -type d -exec rm -rf {} \;
-find . -maxdepth 1 -name "studies*" -type d -exec rm -rf {} \;
-find . -maxdepth 1 -name "merlin.log" -type f -exec rm -rf {} \;
# clean out unwanted files
clean: clean-py
unit-tests:
-python -m pytest $(TEST)
# run CLI tests
cli-tests:
-python $(TEST)integration/run_tests.py
# run unit and CLI tests
tests: unit-tests cli-tests
# automatically make python files pep 8-compliant
fix-style:
isort -rc $(MRLN)
isort -rc $(TEST)
isort *.py
black --target-version py36 $(MRLN)
black --target-version py36 $(TEST)
black --target-version py36 *.py
# run code style checks
check-style:
-python -m flake8 --max-complexity $(MAX_COMPLEXITY) --exclude ascii_art.py $(MRLN)
-black --check --target-version py36 $(MRLN)
# finds all strings in project that begin with a lowercase letter,
# contain only letters and numbers, and contain at least one lowercase
# letter and at least one uppercase letter.
check-camel-case: clean-py
grep -rnw --exclude=lbann_pb2.py $(MRLN) -e "[a-z]\([A-Z0-9]*[a-z][a-z0-9]*[A-Z]\|[a-z0-9]*[A-Z][A-Z0-9]*[a-z]\)[A-Za-z0-9]*"
# run all checks
checks: check-style check-camel-case
# Increment the Merlin version. USE ONLY ON DEVELOP BEFORE MERGING TO MASTER.
# Use like this: make VER=?.?.? verison
version:
# do merlin/__init__.py
sed -i 's/__version__ = "$(VSTRING)"/__version__ = "$(VER)"/g' merlin/__init__.py
# do CHANGELOG.md
sed -i 's/## \[Unreleased\]/## [$(VER)]/g' CHANGELOG.md
# do all file headers (works on linux)
find merlin/ -type f -print0 | xargs -0 sed -i 's/Version: $(VSTRING)/Version: $(VER)/g'
find *.py -type f -print0 | xargs -0 sed -i 's/Version: $(VSTRING)/Version: $(VER)/g'
# do git tag
#git tag $(VER)
# remind user to use git push --tags
#echo "Remember to use git push --tags"