-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
127 lines (103 loc) · 3.6 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
116
117
118
119
120
121
122
123
124
125
126
127
all: lint typecheck cover book grounding-size check
.PHONY: test
test:
@echo "==> 🧪 Tests"
@poetry run pytest -svv draco
.PHONY: cover
cover:
@echo "==> 🧪 Tests with Coverage =="
@poetry run pytest --cov=draco --cov-report=term-missing .
.PHONY: lint
lint:
@echo "==> 👕 Linting"
@poetry run ruff format draco jupyterlite pyodide docs
@poetry run ruff check .
.PHONY: typecheck
typecheck:
@echo "==> ✅ Type checks"
@make mypy pytype
.PHONY: mypy
mypy:
@poetry run mypy -p draco --check-untyped-defs
.PHONY: pytype
pytype:
@poetry run pytype draco
book:
@echo "==> 📕 Book"
@poetry run jupyter-book build docs
# This command does NOT support hot-reloading,
# but it is useful to quickly get a preview of how the deployed docs would look like.
# Especially useful for previewing `{eval-rst}` blocks.
.PHONY: book-serve
book-serve: book
@echo "==> 📡 Serving Book at http://localhost:5000"
@poetry run python -m http.server --directory docs/_build/html --bind 0.0.0.0 5000
.PHONY: book-strict
book-strict:
@poetry run jupyter-book build -W -n --keep-going docs
.PHONY: lab
lab:
@poetry run jupyter lab --ip=0.0.0.0 --allow-root --NotebookApp.allow_origin="*"
.PHONY: build
build:
@echo "==> 👷♀️ Build"
@poetry build -vvv
.PHONY: check
check:
@poetry check
.PHONY: grounding-size
grounding-size: ./draco/asp/examples/*
@echo "==> ⏚ Size of grounded program"
@for file in $^ ; do \
echo $${file} ; \
poetry run python -m clingo draco/asp/generate.lp draco/asp/constraints.lp draco/asp/define.lp draco/asp/helpers.lp draco/asp/hard.lp $${file} --text | wc -l ; \
done
.PHONY: publish
publish: build
@echo "==> 📰 Publish"
@poetry publish --dry-run
.PHONY: clean
clean:
@poetry run jupyter-book clean docs
@find . -type d -name '*.ipynb_checkpoints' -exec rm -r {} +
@find . -type d -name '*pytest_cache*' -exec rm -rf {} +
@find . -type d -name '.mypy_cache' -exec rm -rf {} +
@find . -type d -name '.pytype' -exec rm -rf {} +
@find . -type d -name '.ruff_cache' -exec rm -rf {} +
@find . -type d -name '__pycache__' -exec rm -rf {} +
@find . -type f -name "*.py[co]" -exec rm -rf {} +
@find . -type f -name ".coverage.*" -exec rm -rf {} +
@rm -f jupyterlite/.jupyterlite.doit.db
@rm -rf .coverage
@rm -rf dist
@rm -rf jupyterlite/lite-dir/files
@rm -rf jupyterlite/lite-dir/static/pyodide
@rm -rf pyodide/pyodide-src
.PHONY: serve
serve:
@echo "==> 📡 Serve"
@poetry run uvicorn draco.server.__main__:app --reload --host=0.0.0.0
.PHONY: pyodide-prepare
pyodide-prepare:
@poetry run python pyodide/build.py --prepare
.PHONY: pyodide-finalize
pyodide-finalize:
@poetry run python pyodide/build.py --finalize
.PHONY: pyodide-build
pyodide-build: pyodide-prepare
@echo "==> 🐳 Building Pyodide Distribution"
@cd pyodide/pyodide-src && ./run_docker --non-interactive bash -c './build_draco.sh'
@make pyodide-finalize
.PHONY: jupyterlite-build
jupyterlite-build:
@echo "==> 💡 Building Jupyter Lite Static Site"
@cd jupyterlite && rm -rf lite-dir/static/pyodide && poetry run python build.py && poetry run jupyter lite build
# Re-using the Jupyter Lite build target, since it handles the download and 'caching' of our Pyodide distribution.
.PHONY: pyodide-serve
pyodide-serve: jupyterlite-build
@echo "==> 📡 Serving Pyodide Console at http://localhost:9000/console.html"
@poetry run python -m http.server --directory dist/jupyterlite/static/pyodide --bind 0.0.0.0 9000
.PHONY: jupyterlite-serve
jupyterlite-serve: jupyterlite-build
@echo "==> 📡 Serving Jupyter Lite at http://localhost:9999"
@poetry run python -m http.server --directory dist/jupyterlite --bind 0.0.0.0 9999