-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (41 loc) · 2.08 KB
/
Makefile
File metadata and controls
51 lines (41 loc) · 2.08 KB
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
#################################################################################
# GLOBALS #
#################################################################################
PYTHON_VERSION = python3.8
VIRTUALENV := build/virtualenv
#################################################################################
# COMMANDS #
#################################################################################
# Set the default location for the virtualenv to be stored
# Create the virtualenv by installing the requirements and test requirements
.PHONY: $(VIRTUALENV)
$(VIRTUALENV): requirements.txt
@if [ -d $(VIRTUALENV) ]; then rm -rf $(VIRTUALENV); fi
@mkdir -p $(VIRTUALENV)
virtualenv --python $(PYTHON_VERSION) $(VIRTUALENV)
$(VIRTUALENV)/bin/pip3 install -r requirements.txt
$(VIRTUALENV)/bin/pip3 install -r requirements_test.txt
$(VIRTUALENV)/bin/pip3 install -r requirements_dev.txt
.PHONY: virtualenv
virtualenv: $(VIRTUALENV)
# Update the requirements to latest. This is required because typically we won't
# want to incldue test requirements in the requirements of the application, and
# because it makes life much easier when we want to keep our dependencies up to
# date.
.PHONY: update-requirements-txt
update-requirements-txt: VIRTUALENV := /tmp/update-requirements-virtualenv
update-requirements-txt: unpinned_requirements.txt
@if [ -d $(VIRTUALENV) ]; then rm -rf $(VIRTUALENV); fi
@mkdir -p $(VIRTUALENV)
virtualenv --python $(PYTHON_VERSION) $(VIRTUALENV)
$(VIRTUALENV)/bin/pip3 install --upgrade -r unpinned_requirements.txt
echo "# Created by 'make update-requirements-txt'. DO NOT EDIT!" > requirements.txt
$(VIRTUALENV)/bin/pip freeze | grep -v pkg-resources==0.0.0 >> requirements.txt
.PHONY: serve
serve:
$(VIRTUALENV)/bin/uvicorn src.api:app --reload
.PHONY: test-api
test-api:
curl --header "Content-Type: application/json" --request POST \
--data '{"text":"You'\''ve WON a PRIZE, text back to find out what"}' \
localhost:8000/predict