-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile
158 lines (127 loc) Β· 4.83 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
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
154
155
156
157
158
VERSION ?= "0.1.0.dev0"
.PHONY: install
install: ## Install the poetry environment and install the pre-commit hooks
@echo "π Creating virtual environment using pyenv and poetry"
@cd arcade && poetry install --all-extras
@cd arcade && poetry run pre-commit install
.PHONY: install-toolkits
install-toolkits: ## Install dependencies for all toolkits
@echo "π Installing dependencies for all toolkits"
@for dir in toolkits/*/ ; do \
echo "π¦ Installing dependencies for $$dir"; \
(cd $$dir && poetry lock && poetry install); \
done
.PHONY: check
check: ## Run code quality tools.
@echo "π Checking Poetry lock file consistency with 'pyproject.toml': Running poetry check --lock"
@cd arcade && poetry check --lock
@echo "π Linting code: Running pre-commit"
@cd arcade && poetry run pre-commit run -a
@echo "π Static type checking: Running mypy"
@cd arcade && poetry run mypy $(git ls-files '*.py')
.PHONY: check-toolkits
check-toolkits: ## Run code quality tools for each toolkit that has a Makefile
@echo "π Running 'make check' in each toolkit with a Makefile"
@for dir in toolkits/*/ ; do \
if [ -f "$$dir/Makefile" ]; then \
echo "π οΈ Checking toolkit $$dir"; \
(cd "$$dir" && make check); \
else \
echo "π οΈ Skipping toolkit $$dir (no Makefile found)"; \
fi; \
done
.PHONY: test
test: ## Test the code with pytest
@echo "π Testing code: Running pytest"
@cd arcade && poetry run pytest -W ignore -v --cov --cov-config=pyproject.toml --cov-report=xml
.PHONY: test-toolkits
test-toolkits: ## Iterate over all toolkits and run pytest on each one
@echo "π Testing code in toolkits: Running pytest"
@for dir in toolkits/*/ ; do \
(cd $$dir && poetry run pytest -W ignore -v --cov --cov-config=pyproject.toml --cov-report=xml || exit 1); \
done
.PHONY: coverage
coverage: ## Generate coverage report
@echo "coverage report"
@cd arcade && coverage report
@echo "Generating coverage report"
@cd arcade && coverage html
.PHONY: set-version
set-version: ## Set the version in the pyproject.toml file
@echo "π Setting version in pyproject.toml"
@cd arcade && poetry version $(VERSION)
.PHONY: unset-version
unset-version: ## Set the version in the pyproject.toml file
@echo "π Setting version in pyproject.toml"
@cd arcade && poetry version 0.1.0
.PHONY: build
build: clean-build ## Build wheel file using poetry
@echo "π Creating wheel file"
@cd arcade && poetry build
.PHONY: clean-build
clean-build: ## clean build artifacts
@cd arcade && rm -rf dist
.PHONY: publish
publish: ## publish a release to pypi.
@echo "π Publishing: Dry run."
@cd arcade && poetry config pypi-token.pypi $(PYPI_TOKEN)
@cd arcade && poetry publish --dry-run
@echo "π Publishing."
@cd arcade && poetry publish
.PHONY: build-and-publish
build-and-publish: build publish ## Build and publish.
.PHONY: docker
docker: ## Build and run the Docker container
@echo "π Building arcade and toolkit wheels..."
@make full-dist
@echo "Writing extras [fastapi, evals] to requirements.txt"
@cd arcade && poetry export --extras "fastapi evals" --output ../dist/requirements.txt
@echo "π Building Docker image"
@cd docker && make docker-build
@cd docker && make docker-run
.PHONY: publish-ecr
publish-ecr: ## Publish to the ECR
@cd docker && make publish-ecr
.PHONY: full-dist
full-dist: clean-dist ## Build all projects and copy wheels to ./dist
@echo " Building a full distribution with toolkits"
@echo "Setting version to $(VERSION)"
@make set-version
# @echo "π οΈ Building all projects and copying wheels to ./dist"
@mkdir -p dist
# Build the main arcade project
@echo "π οΈ Building arcade project wheel..."
@cd arcade && poetry build
# Copy the main arcade project wheel to the dist directory
@cp arcade/dist/*.whl dist/
@echo "Reset version to default (0.1.0)"
@make unset-version
@echo "π οΈ Building all projects and copying wheels to ./dist"
# Build and copy wheels for each toolkit
# @for toolkit_dir in toolkits/*; do \
# if [ -d "$$toolkit_dir" ]; then \
# toolkit_name=$$(basename "$$toolkit_dir"); \
# echo "Building $$toolkit_name project..."; \
# poetry build; \
# cp dist/*.whl ../../dist/toolkits; \
# cd -; \
# fi; \
# done
@echo "β
All toolkits built and wheels copied to ./dist"
.PHONY: clean-dist
clean-dist: ## Clean all built distributions
@echo "ποΈ Cleaning dist directory"
@rm -rf dist
@echo "ποΈ Cleaning arcade/dist directory"
@rm -rf arcade/dist
@echo "ποΈ Cleaning toolkits/*/dist directory"
@for toolkit_dir in toolkits/*; do \
if [ -d "$$toolkit_dir" ]; then \
rm -rf "$$toolkit_dir"/dist; \
fi; \
done
.PHONY: help
help:
@echo "π οΈ Arcade AI Dev Commands:\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help