-
Notifications
You must be signed in to change notification settings - Fork 187
Expand file tree
/
Copy pathMakefile
More file actions
145 lines (115 loc) · 4.56 KB
/
Makefile
File metadata and controls
145 lines (115 loc) · 4.56 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
PIPELINE_FAMILY := general
PIPELINE_PACKAGE := general
PACKAGE_NAME := prepline_${PIPELINE_PACKAGE}
.PHONY: help
help: Makefile
@sed -n 's/^\(## \)\([a-zA-Z]\)/\2/p' $<
###########
# Install #
###########
## install-base: installs minimum requirements to run the API
.PHONY: install-base
install-base: install-base-packages install-nltk-models
## install: installs all test and dev requirements
.PHONY: install
install: install-base install-test
.PHONY: install-base-packages
install-base-packages:
uv sync --no-dev --frozen
.PHONY: install-test
install-test:
uv sync --group test --frozen
.PHONY: install-nltk-models
install-nltk-models:
uv run python -c "from unstructured.nlp.tokenize import download_nltk_packages; download_nltk_packages()"
## lock: regenerates uv.lock
.PHONY: lock
lock:
uv lock --upgrade
PANDOC_VERSION := 3.9
.PHONY: install-pandoc
install-pandoc:
@ARCH=$$(uname -m) && \
if [ "$$ARCH" = "x86_64" ]; then PANDOC_ARCH="amd64"; else PANDOC_ARCH="arm64"; fi && \
wget -q "https://github.com/jgm/pandoc/releases/download/$(PANDOC_VERSION)/pandoc-$(PANDOC_VERSION)-linux-$$PANDOC_ARCH.tar.gz" -O /tmp/pandoc.tar.gz && \
tar -xzf /tmp/pandoc.tar.gz -C /tmp && \
sudo cp /tmp/pandoc-$(PANDOC_VERSION)/bin/pandoc /usr/local/bin/ && \
rm -rf /tmp/pandoc*
##########
# Docker #
##########
# Docker targets are provided for convenience only and are not required in a standard development environment
# Note that the image has notebooks baked in, however the current working directory
# is mounted under /home/notebook-user/local/ when the image is started with
# docker-start-api or docker-start-jupyter
DOCKER_IMAGE ?= pipeline-family-${PIPELINE_FAMILY}-dev:latest
.PHONY: docker-build
docker-build:
PIPELINE_FAMILY=${PIPELINE_FAMILY} PIPELINE_PACKAGE=${PIPELINE_PACKAGE} ./scripts/docker-build.sh
.PHONY: docker-start-api
docker-start-api:
docker run -p 8000:8000 \
-it --rm \
--mount type=bind,source=$(realpath .),target=/home/notebook-user/local \
$(if $(MAX_LIFETIME_SECONDS),-e MAX_LIFETIME_SECONDS=$(MAX_LIFETIME_SECONDS)) \
pipeline-family-${PIPELINE_FAMILY}-dev:latest scripts/app-start.sh
.PHONY: docker-start-bash
docker-start-bash:
docker run -p 8000:8000 -it --rm --mount type=bind,source=$(realpath .),target=/home/notebook-user/local --entrypoint /bin/bash pipeline-family-${PIPELINE_FAMILY}-dev:latest
.PHONY: docker-test
docker-test:
DOCKER_IMAGE=${DOCKER_IMAGE} ./scripts/docker-smoke-test.sh
#########
# Local #
#########
## run-web-app: runs the FastAPI api with hot reloading
.PHONY: run-web-app
run-web-app:
PYTHONPATH=$(realpath .) uv run uvicorn ${PACKAGE_NAME}.api.app:app --reload --log-config logger_config.yaml
#################
# Test and Lint #
#################
## test: runs core tests
.PHONY: test
test:
PYTHONPATH=. uv run pytest -n auto -v test_${PIPELINE_PACKAGE} --cov=${PACKAGE_NAME} --cov-report term-missing
# Setting a low bar here - need more tests!
.PHONY: check-coverage
check-coverage:
uv run coverage report --fail-under=60
## 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:
uv run --no-sync ruff format --check ${PACKAGE_NAME}
uv run --no-sync ruff check ${PACKAGE_NAME}
uv run --no-sync mypy ${PACKAGE_NAME} --ignore-missing-imports --implicit-optional
.PHONY: check-tests
check-tests:
uv run --no-sync ruff format --check test_${PIPELINE_PACKAGE} scripts/smoketest.py
uv run --no-sync ruff check test_${PIPELINE_PACKAGE} scripts/smoketest.py
## tidy: run ruff format and fix
.PHONY: tidy
tidy:
uv run --no-sync ruff format ${PACKAGE_NAME} test_${PIPELINE_PACKAGE} scripts/smoketest.py
uv run --no-sync ruff check --fix ${PACKAGE_NAME} test_${PIPELINE_PACKAGE} scripts/smoketest.py
## 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 references in files
.PHONY: check-version
check-version:
# Fail if syncing version would produce changes
scripts/version-sync.sh -c \
-s CHANGELOG.md \
-f prepline_general/api/__version__.py release \
## version-sync: update references to version with most recent version from CHANGELOG.md
.PHONY: version-sync
version-sync:
scripts/version-sync.sh \
-s CHANGELOG.md \
-f prepline_general/api/__version__.py release \