-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
115 lines (82 loc) · 4.93 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
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
.PHONY: apidocs docs-comprehensive generate html install install-dev install-extras install-generator install-lint install-pre-commit test test-4edge test-integ test-local help
help: ## Print all targets with their descriptions
@grep -E '^[a-zA-Z_-]+:.*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {if (NF == 1) {printf "\033[36m%-30s\033[0m %s\n", $$1, ""} else {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}}'
install: ## Install the package from source
poetry install
install-extras: install ## Install the package from source with extra dependencies
poetry run pip install numpy
install-lint: ## Only install the linter dependencies
poetry install --only lint
install-dev: ## Only install the dev dependencies
poetry install --only dev
install-pre-commit: install ## Install pre-commit hooks
poetry run pre-commit install
install-generator: install ## Install dependencies for SDK code generator
npm install
generate: install-generator ## Generate the SDK from our public openapi spec
node_modules/.bin/openapi-generator-cli generate -i spec/public-api.yaml \
-g python \
-o ./generated \
--additional-properties=packageName=groundlight_openapi_client
# strict-nullable makes nullable fields Optional in the generated Pydantic classes: https://github.com/koxudaxi/datamodel-code-generator/issues/327
poetry run datamodel-codegen --input spec/public-api.yaml --output generated/model.py --strict-nullable --use-schema-description --output-model-type pydantic_v2.BaseModel --use-subclass-enum
poetry run black .
PYTEST=poetry run pytest -v
# You can pass extra arguments to pytest by setting the TEST_ARGS environment variable.
# For example:
# `make test TEST_ARGS="-k some_filter"`
TEST_ARGS=
CLOUD_FILTERS = -m "not run_only_for_edge_endpoint"
EDGE_FILTERS = -m "not skip_for_edge_endpoint"
# Record information about the slowest 25 tests (but don't show anything slower than 0.1 seconds)
PROFILING_ARGS = \
--durations 25 \
--durations-min 0.1
test: install ## Run tests against the prod API (needs GROUNDLIGHT_API_TOKEN)
${PYTEST} ${PROFILING_ARGS} ${TEST_ARGS} ${CLOUD_FILTERS} test
test-4edge: install ## Run tests against the prod API via the edge-endpoint (needs GROUNDLIGHT_API_TOKEN)
${PYTEST} ${PROFILING_ARGS} ${TEST_ARGS} ${EDGE_FILTERS} test
test-local: install ## Run tests against a localhost API (needs GROUNDLIGHT_API_TOKEN and a local API server)
GROUNDLIGHT_ENDPOINT="http://localhost:8000/" $(MAKE) test
test-integ: install ## Run tests against the integ API server (needs GROUNDLIGHT_API_TOKEN)
GROUNDLIGHT_ENDPOINT="https://api.integ.groundlight.ai/" $(MAKE) test
test-dev: install ## Run tests against a dev API server (needs GROUNDLIGHT_API_TOKEN and properly configured dns-hostmap)
GROUNDLIGHT_ENDPOINT="https://api.dev.groundlight.ai/" $(MAKE) test
test-docs: install ## Run the example code and tests in our docs against the prod API (needs GROUNDLIGHT_API_TOKEN)
${PYTEST} --markdown-docs ${TEST_ARGS} docs README.md
test-docs-integ: install ## Run the example code and tests in our docs against the integ API (needs GROUNDLIGHT_API_TOKEN)
GROUNDLIGHT_ENDPOINT="https://api.integ.groundlight.ai/" ${PYTEST} --markdown-docs ${TEST_ARGS} docs README.md
# Adjust which paths we lint
LINT_PATHS="src test bin samples"
lint: install-lint ## Run linter to check formatting and style
./code-quality/lint ${LINT_PATHS}
format: install-lint ## Run standard python formatting
./code-quality/format ${LINT_PATHS}
# Targets for building code.groundlight.ai and API reference documentation
install-sphinx-deps: ## Only install the sphinx dependencies
poetry install --no-root --only sphinx-deps
# The following is auto-generated by sphinx-quickstart:
# To test out doc changes locally, run
# poetry run make html && open build/html/index.html
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = sphinx_docs
BUILDDIR = build
sphinx-help: ## Print help for Sphinx build options (Sphinx is used to build our API reference documentation)
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
## Before running this, make sure that you have installed the node modules
## by running `node install` in the docs directory.
develop-docs-comprehensive: docs-comprehensive ## Start an interactive server to test docs locally.
cd docs && npm start
docs-comprehensive: apidocs ## Builds docs comprehensively (integrating API reference docs built with sphinx into the docusaurus docs).
rm -rf docs/static/api-reference-docs
rm -rf docs/build/api-reference-docs
mkdir docs/static/api-reference-docs
mv build/html/* docs/static/api-reference-docs/
cd docs && npm run build
apidocs: ## Installs necessary npm packages and builds API reference documentation using Sphinx.
cd docs && npm install
poetry run make html
html: ## Builds HTML reference documentation using Sphinx.
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(0)
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."