-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (86 loc) · 3.23 KB
/
Makefile
File metadata and controls
103 lines (86 loc) · 3.23 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
ARGS:= $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# Get git commit hash automatically
GIT_COMMIT := $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
GIT_COMMIT_SHORT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
install:
uv sync --refresh --force-reinstall --group test --group dev
sdk-sandbox:
@echo "Downloading sandbox definition from blaxel-ai/sandbox"
@curl -H "Authorization: token $$(gh auth token)" \
-H "Accept: application/vnd.github.v3.raw" \
-o ./definition.yml \
https://api.github.com/repos/blaxel-ai/sandbox/contents/sandbox-api/docs/openapi.yml?ref=main
rm -rf src/blaxel/core/sandbox/client/api src/blaxel/core/sandbox/client/models
.venv/bin/openapi-python-client generate \
--path=definition.yml \
--output-path=./tmp-sdk-sandbox \
--overwrite \
--custom-template-path=./templates \
--config=./openapi-python-client.yml
cp -r ./tmp-sdk-sandbox/blaxel/* ./src/blaxel/core/sandbox/client
rm -rf ./tmp-sdk-sandbox
uv run ruff format
uv run ruff check --fix
sdk-controlplane:
@echo "Downloading controlplane definition from blaxel-ai/controlplane"
@curl -H "Authorization: token $$(gh auth token)" \
-H "Accept: application/vnd.github.v3.raw" \
-o ./definition.yml \
https://api.github.com/repos/blaxel-ai/controlplane/contents/api/api/definitions/controlplane.yml?ref=main
rm -rf src/blaxel/core/client/api src/blaxel/core/client/models
.venv/bin/openapi-python-client generate \
--path=definition.yml \
--output-path=./tmp-sdk-python \
--overwrite \
--custom-template-path=./templates \
--config=./openapi-python-client.yml
cp -r ./tmp-sdk-python/blaxel/* ./src/blaxel/core/client
rm -rf ./tmp-sdk-python
uv run ruff format
uv run ruff check --fix
sdk: sdk-sandbox sdk-controlplane
# Build with commit hash injection
build:
@echo "🔨 Building Python SDK with commit: $(GIT_COMMIT_SHORT)"
@echo "💉 Injecting commit hash into pyproject.toml"
@if [ -f pyproject.toml ]; then \
if grep -q "^\[tool\.blaxel\]" pyproject.toml; then \
sed -i.bak 's/^commit = .*/commit = "$(GIT_COMMIT)"/' pyproject.toml && rm pyproject.toml.bak; \
else \
echo "" >> pyproject.toml; \
echo "[tool.blaxel]" >> pyproject.toml; \
echo 'commit = "$(GIT_COMMIT)"' >> pyproject.toml; \
fi; \
fi
@echo "✅ Build completed with commit: $(GIT_COMMIT_SHORT)"
# Clean build artifacts and reset pyproject.toml
clean:
@echo "🧹 Cleaning build artifacts"
@git checkout pyproject.toml 2>/dev/null || true
@rm -rf dist/ build/ *.egg-info/
@echo "✅ Clean completed"
doc:
rm -rf docs
uv run pdoc blaxel src/* -o docs --force --skip-errors
lint:
uv run ruff check --fix
tag:
git checkout main
git pull origin main
git tag -a v$(ARGS) -m "Release v$(ARGS)"
git push origin v$(ARGS)
test:
uv sync --group test
uv run pytest tests/ -v --ignore=tests/integration/ --ignore=tests/sandbox/integration/
FRAMEWORK_DIRS := llamaindex langgraph openai livekit crewai pydantic googleadk
IGNORE_FRAMEWORK := $(foreach dir,$(FRAMEWORK_DIRS),--ignore=tests/integration/$(dir)/)
test-integration:
uv run pytest tests/integration/ $(IGNORE_FRAMEWORK) -s
test-integration-%:
uv run --extra $* pytest tests/integration/$*/ -s
install-dev:
uv sync --group test
pip install -e .
%:
@:
.PHONY: sdk