forked from Unstructured-IO/unstructured-inference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (119 loc) · 4.48 KB
/
Makefile
File metadata and controls
153 lines (119 loc) · 4.48 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
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
PACKAGE_NAME := unstructured_inference
PIP_VERSION := 23.1.2
.PHONY: help
help: Makefile
@sed -n 's/^\(## \)\([a-zA-Z]\)/\2/p' $<
###########
# Install #
###########
## install-base: installs core requirements needed for text processing bricks
.PHONY: install-base
install-base: install-base-pip-packages
pip install -r requirements/base.txt
## install: installs all test, dev, and experimental requirements
.PHONY: install
install: install-base-pip-packages install-dev install-detectron2
.PHONY: install-ci
install-ci: install-base-pip-packages install-test install-paddleocr
.PHONY: install-base-pip-packages
install-base-pip-packages:
python3 -m pip install pip==${PIP_VERSION}
.PHONY: install-detectron2
install-detectron2:
pip install "detectron2@git+https://github.com/facebookresearch/detectron2.git@e2ce8dc#egg=detectron2"
.PHONY: install-paddleocr
install-paddleocr:
pip install "unstructured.PaddleOCR"
.PHONY: install-test
install-test: install-base
pip install -r requirements/test.txt
.PHONY: install-dev
install-dev: install-test
pip install -r requirements/dev.txt
## pip-compile: compiles all base/dev/test requirements
.PHONY: pip-compile
pip-compile:
pip-compile --upgrade requirements/base.in
# NOTE(robinson) - We want the dependencies for detectron2 in the requirements.txt, but not
# the detectron2 repo itself. If detectron2 is in the requirements.txt file, an order of
# operations issue related to the torch library causes the install to fail
sed 's/^detectron2 @/# detectron2 @/g' requirements/base.txt
pip-compile --upgrade requirements/test.in
pip-compile --upgrade requirements/dev.in
##########
# Docker #
##########
# Docker targets are provided for convenience only and are not required in a standard development environment
# Note that the current working directory is mounted under
# /home/notebook-user/local/ when the image is started with
# docker-start-api
.PHONY: docker-build
docker-build:
PIP_VERSION=${PIP_VERSION} ./scripts/docker-build.sh
.PHONY: docker-start-api
docker-start-api:
docker run -p 8000:8000 --mount type=bind,source=$(realpath .),target=/home/notebook-user/local -t --rm --entrypoint uvicorn unstructured-inference-dev:latest ${PACKAGE_NAME}.api:app --log-config logger_config.yaml --host 0.0.0.0 --port 8000
#########
# Local #
########
## run-app-dev: runs the FastAPI api with hot reloading
.PHONY: run-app-dev
run-app-dev:
PYTHONPATH=. uvicorn unstructured_inference.api:app --log-config logger_config.yaml --reload
## start-app-local: runs FastAPI in the container with hot reloading
.PHONY: start-app-local
start-app-local:
docker run --name=ml-inference-container -p 127.0.0.1:5000:5000 ml-inference-dev
## stop-app-local: stops the container
.PHONY: stop-app-local
stop-app-local:
docker stop ml-inference-container | xargs docker rm
#################
# Test and Lint #
#################
## test: runs all unittests
.PHONY: test
test:
PYTHONPATH=. pytest -m "not slow" test_${PACKAGE_NAME} --cov=${PACKAGE_NAME} --cov-report term-missing
.PHONY: test-slow
test-slow:
PYTHONPATH=. pytest test_${PACKAGE_NAME} --cov=${PACKAGE_NAME} --cov-report term-missing
## check: runs linters (includes tests)
.PHONY: check
check: check-src check-tests check-version
## check-src: runs linters (source only, no tests)
.PHONY: check-src
check-src:
black --line-length 100 ${PACKAGE_NAME} --check
flake8 ${PACKAGE_NAME}
mypy ${PACKAGE_NAME} --ignore-missing-imports
.PHONY: check-tests
check-tests:
black --line-length 100 test_${PACKAGE_NAME} --check
flake8 test_${PACKAGE_NAME}
## check-scripts: run shellcheck
.PHONY: check-scripts
check-scripts:
# Fail if any of these files have warnings
scripts/shellcheck.sh
## check-version: run check to ensure version in CHANGELOG.md matches version in package
.PHONY: check-version
check-version:
# Fail if syncing version would produce changes
scripts/version-sync.sh -c \
-s CHANGELOG.md \
-f unstructured_inference/__version__.py semver
## tidy: run black
.PHONY: tidy
tidy:
black --line-length 100 ${PACKAGE_NAME}
black --line-length 100 test_${PACKAGE_NAME}
## version-sync: update __version__.py with most recent version from CHANGELOG.md
.PHONY: version-sync
version-sync:
scripts/version-sync.sh \
-s CHANGELOG.md \
-f unstructured_inference/__version__.py semver
.PHONY: check-coverage
check-coverage:
coverage report --fail-under=95