-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathMakefile
More file actions
137 lines (110 loc) · 6.29 KB
/
Copy pathMakefile
File metadata and controls
137 lines (110 loc) · 6.29 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
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
# Put targets here if there is a risk that a target name might conflict with a filename.
# this list is probably overkill right now.
# See: https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: help test
git-hooks: ## Install git hooks
@echo "Installing git hooks"
cd .git/hooks && ln -sf ../../githooks/* ./
install-tools: git-hooks ## Install required utilities/tools
@command -v uv > /dev/null || { echo >&2 "uv is not installed. Installing..."; pip install uv; }
@uv --version
uv-lock-check: ## Check that the uv.lock file is in a good shape
uv lock --check
install-deps-test: ## Install all required dev dependencies needed to test the service, according to uv.lock
uv sync --group dev
update-deps: uv-lock-regenerate install-deps-test ## Regenerate lock files (with cooldown) and sync dev deps
check-types: ## Checks type hints in sources
uv run mypy src/ lsc_agent_eval/src/ tests
black-check:
uv run black --check src tests script lsc_agent_eval
black-format:
uv run black src tests script lsc_agent_eval
# Skip packages published within this many days (supply-chain cooldown).
# Override: make sync-lock-and-requirements COOLDOWN_DAYS=0
COOLDOWN_DAYS ?= 7
uv-lock-regenerate: ## Regenerate both CPU and GPU lock files from pyproject.toml (with cooldown)
$(eval COOLDOWN_CUTOFF := $(shell python3 -c "from datetime import datetime,timezone,timedelta;print((datetime.now(timezone.utc)-timedelta(days=$(COOLDOWN_DAYS))).strftime('%Y-%m-%dT%H:%M:%SZ'))"))
@echo "Regenerating CPU lock file (uv.lock)..."
@echo "Cooldown: excluding packages newer than $(COOLDOWN_CUTOFF) ($(COOLDOWN_DAYS) days)"
uv lock --exclude-newer "$(COOLDOWN_CUTOFF)"
@echo "Regenerating GPU lock file (uv-gpu.lock)..."
@# Use mktemp for safe temporary files
@( \
set -e; \
BACKUP_FILE=$$(mktemp "$${TMPDIR:-/tmp}/pyproject-backup.XXXXXX"); \
TEMP_FILE=$$(mktemp "$${TMPDIR:-/tmp}/pyproject-temp.XXXXXX"); \
trap "rm -f $$TEMP_FILE; [ -f $$BACKUP_FILE ] && mv $$BACKUP_FILE pyproject.toml; echo '❌ Error: GPU lock generation failed, pyproject.toml restored'; exit 1" EXIT; \
cp pyproject.toml $$BACKUP_FILE; \
sed '/^\[tool\.uv\.sources\]/,/^torch = /d' pyproject.toml > $$TEMP_FILE; \
mv $$TEMP_FILE pyproject.toml; \
uv lock --locked 2>/dev/null || uv lock --exclude-newer "$(COOLDOWN_CUTOFF)"; \
mv uv.lock uv-gpu.lock; \
mv $$BACKUP_FILE pyproject.toml; \
trap - EXIT; \
)
@echo "Restoring CPU lock file (uv.lock)..."
uv lock --exclude-newer "$(COOLDOWN_CUTOFF)"
@echo "✅ Done! Created uv.lock (CPU) and uv-gpu.lock (GPU) [cooldown=$(COOLDOWN_DAYS)d]"
generate-requirements: ## Generate pinned requirements-*.txt from uv.lock (no -e ., safe without clone)
@echo "Generating requirements.txt (runtime only, no optional extras)..."
uv export --frozen --no-hashes --no-dev --no-emit-project -o requirements.txt
@echo "Generating requirements-nlp-metrics.txt (base + nlp-metrics)..."
uv export --frozen --no-hashes --no-dev --no-emit-project --extra nlp-metrics -o requirements-nlp-metrics.txt
@echo "Generating requirements-local-embeddings.txt (base + local-embeddings, excludes torch)..."
uv export --frozen --no-hashes --no-dev --no-emit-project --extra local-embeddings --no-emit-package torch -o requirements-local-embeddings.txt
@echo "Generating requirements-all-extras.txt (base + all optional extras, excludes torch)..."
uv export --frozen --no-hashes --no-dev --no-emit-project --all-extras --no-emit-package torch -o requirements-all-extras.txt
@TORCH_VERSION=$$(grep 'torch.*version.*2\.' uv.lock | head -1 | sed 's/.*version = "\([^"]*\)".*/\1/'); \
echo ""; \
echo "========================================"; \
echo "Requirements files generated:"; \
echo " - requirements.txt"; \
echo " - requirements-nlp-metrics.txt"; \
echo " - requirements-local-embeddings.txt (torch excluded - install separately)"; \
echo " - requirements-all-extras.txt (torch excluded - install separately)"; \
echo ""; \
echo "For local-embeddings extras, install torch separately:"; \
echo " CPU: pip install torch==$$TORCH_VERSION --index-url https://download.pytorch.org/whl/cpu"; \
echo " GPU: pip install torch==$$TORCH_VERSION"; \
echo "Note: Dev dependencies use uv.lock for local development"; \
echo "========================================"
sync-lock-and-requirements: uv-lock-regenerate generate-requirements ## Regenerate lock files and requirements-*.txt
verify-packages-completeness: requirements-all-extras.txt ## Verify pinned requirements resolve (full optional set)
uv pip download -d /tmp/ --use-pep517 --verbose -r requirements-all-extras.txt
distribution-archives: ## Generate distribution archives to be uploaded into Python registry
uv run python -m build
test: install-deps-test ## Execute tests with Pytest
uv run pytest tests lsc_agent_eval/tests
e2e_tests: install-deps-test
uv run pytest tests/integration -v -m integration
e2e_tests_agentic: install-deps-test ## Run agentic integration tests (requires live OpenShift cluster)
uv run pytest tests/integration -v -m agentic
e2e_tests_lcore: e2e_tests
# May be changed in the future to different test suite
echo "LCORE e2e tests done"
pre-commit: black-check docstyle pyright pylint ruff check-types bandit
@echo "All checks successful"
help: ## Show this help screen
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@echo 'Available targets are:'
@echo ''
@grep -E '^[ a-zA-Z0-9_.-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-33s\033[0m %s\n", $$1, $$2}'
@echo ''
shellcheck: ## Run shellcheck
@mkdir -p .shellcheck-stable
@wget -qO- "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.$$(uname -m).tar.xz" | tar -xJ -C .shellcheck-stable --strip-components=1
@PATH="$$PWD/.shellcheck-stable:$$PATH" shellcheck --version
@PATH="$$PWD/.shellcheck-stable:$$PATH" find . -name "*.sh" -type f ! -path "./.venv/*" ! -path "./lsc_agent_eval/.venv/*" ! -path "./.history/*" ! -path "./.git/*" -exec shellcheck -e SC1091 {} +
pylint:
uv run pylint src
uv run pylint lsc_agent_eval/src tests
pyright:
uv run pyright src lsc_agent_eval/src tests
docstyle:
uv run pydocstyle -v src tests script lsc_agent_eval
ruff:
uv run ruff check src tests script lsc_agent_eval
bandit: ## Security scanning with Bandit
uv run bandit -c pyproject.toml -r src/lightspeed_evaluation -ll