-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (73 loc) · 2.15 KB
/
Copy pathMakefile
File metadata and controls
91 lines (73 loc) · 2.15 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
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
.PHONY: *
APP_PORT := 5039
DOCKER_TAG := latest
DOCKER_IMAGE := planet
DVC_REMOTE_NAME := models_onnx
USERNAME := dmitriy
PYENV=/home/$(USERNAME)/.pyenv/versions/3.9.17/bin/python
VENV=/opt/python_venvs/api_venv
PYTHON=$(VENV)/bin/python3
PIP=$(VENV)/bin/pip
.PHONY: venv
venv:
$(PYENV) -m venv $(VENV)
@echo 'Path to Python executable $(shell pwd)/$(PYTHON)'
.PHONY: install
install: venv
@echo "=== Installing common dependencies ==="
$(PIP) install --upgrade pip
$(PIP) install -r requirements.txt
.PHONY: run_app
run_app:
python3 -m uvicorn app:create_app --host='0.0.0.0' --port=$(APP_PORT)
.PHONY: download_model
download_model:
dvc remote modify --local models_onnx keyfile ~/.ssh/id_rsa
dvc pull
.PHONY: run_unit_tests
run_unit_tests:
PYTHONPATH=. pytest tests/unit/
.PHONY: run_integration_tests
run_integration_tests:
PYTHONPATH=. pytest tests/integration/
.PHONY: run_all_tests
run_all_tests:
make run_unit_tests
make run_integration_tests
.PHONY: generate_coverage_report
generate_coverage_report:
PYTHONPATH=. pytest --cov=src --cov-report html tests/
.PHONY: lint
lint:
PYTHONPATH=. flake8 .
.PHONY: build
build:
docker build -f Dockerfile . -t $(DOCKER_IMAGE):$(DOCKER_TAG)
.PHONY: deploy
deploy:
ansible-playbook -i deploy/ansible/inventory.ini deploy/ansible/deploy.yml \
-e host=$(DEPLOY_HOST) \
-e docker_image=$(DOCKER_IMAGE) \
-e docker_tag=$(DOCKER_TAG) \
-e docker_registry_user=$(CI_REGISTRY_USER) \
-e docker_registry_password=$(CI_REGISTRY_PASSWORD) \
-e docker_registry=$(CI_REGISTRY) \
.PHONY: destroy
destroy:
ansible-playbook -i deploy/ansible/inventory.ini deploy/ansible/destroy.yml \
-e host=$(DEPLOY_HOST)
.PHONY: install_dvc
install_dvc:
pip install dvc[ssh]==3.33.2
.PHONY: init_dvc
init_dvc:
dvc init --no-scm
dvc remote add --default $(DVC_REMOTE_NAME) ssh://91.206.15.25/home/$(USERNAME)/dvc_models
dvc remote modify $(DVC_REMOTE_NAME) user $(USERNAME)
dvc config cache.type hardlink,symlink
.PHONY: install_c_libs
install_c_libs:
apt-get update && apt-get install -y --no-install-recommends gcc ffmpeg libsm6 libxext6
.PHONY: docker_run
docker_run:
docker run -p 5039:5039 -d $(DOCKER_IMAGE):$(DOCKER_TAG)