forked from Unstructured-IO/unstructured-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (65 loc) · 2.34 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
PACKAGE_NAME := unstructured-python-client
CURRENT_DIR := $(shell pwd)
ARCH := $(shell uname -m)
DOCKER_IMAGE ?= downloads.unstructured.io/unstructured-io/unstructured-api:latest
###########
# Install #
###########
.PHONY: install-test
install-test:
pip install pytest requests_mock pypdf deepdiff requests-toolbelt
.PHONY: install-dev
install-dev:
pip install jupyter
pip install pylint
## install: installs all test, dev, and experimental requirements
.PHONY: install
install: install-test install-dev
#################
# Test and Lint #
#################
.PHONY: test
test: test-unit test-integration-docker
.PHONY: test-unit
test-unit:
PYTHONPATH=. pytest _test_unstructured_client -v -k "unit"
# Assumes you have unstructured-api running on localhost:8000
.PHONY: test-integration
test-integration:
PYTHONPATH=. pytest _test_unstructured_client -v -k "integration"
# Runs the unstructured-api in docker for tests
.PHONY: test-integration-docker
test-integration-docker:
-docker stop unstructured-api && docker kill unstructured-api
docker run --name unstructured-api -p 8000:8000 -d --rm ${DOCKER_IMAGE} --host 0.0.0.0 && \
curl -s -o /dev/null --retry 10 --retry-delay 5 --retry-all-errors http://localhost:8000/general/docs && \
PYTHONPATH=. pytest _test_unstructured_client -v -k "integration" && \
docker kill unstructured-api
.PHONY: lint
lint:
pylint --rcfile=pylintrc src
#############
# Speakeasy #
#############
.PHONY: client-generate
client-generate:
wget -nv -q -O openapi.json https://api.unstructured.io/general/openapi.json
speakeasy overlay validate -o ./overlay_client.yaml
speakeasy overlay apply -s ./openapi.json -o ./overlay_client.yaml > ./openapi_client.json
speakeasy generate sdk -s ./openapi_client.json -o ./ -l python
.PHONY: client-generate-local
client-generate-local:
wget -nv -q -O openapi.json http://localhost:5000/general/openapi.json
speakeasy overlay validate -o ./overlay_client.yaml
speakeasy overlay apply -s ./openapi.json -o ./overlay_client.yaml > ./openapi_client.json
speakeasy generate sdk -s ./openapi_client.json -o ./ -l python
.PHONY: publish
publish:
./scripts/publish.sh
###########
# Jupyter #
###########
## run-jupyter: starts jupyter notebook
.PHONY: run-jupyter
run-jupyter:
PYTHONPATH=$(realpath .) JUPYTER_PATH=$(realpath .) jupyter-notebook --NotebookApp.token='' --NotebookApp.password=''