-
Notifications
You must be signed in to change notification settings - Fork 41
/
Makefile
84 lines (68 loc) · 2.55 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
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
.PHONY: help
help: ## Print this help message
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
.PHONY: init
init: ## Locally install all dev dependencies
poetry install --all-extras
.PHONY: init-cpu
init-cpu: ## Locally install all dev dependencies with CPU support
init-cpu: init
poetry run pip install torch torchvision sentence-transformers accelerate \
--extra-index-url https://download.pytorch.org/whl/cpu
.PHONY: init-gpu
init-gpu: ## Locally install all dev dependencies with GPU support
init-gpu: init
poetry run pip install torch torchvision sentence-transformers accelerate
.PHONY: clean
clean: ## Clean project
rm -rf .ruff_cache/ .mypy_cache/
.PHONY: check-format
check-format: ## Check code formatting
poetry run black --check .
.PHONY: format
format: ## Fix code formatting
poetry run black .
.PHONY: typecheck
typecheck: ## Typecheck all source files
poetry run mypy -p assistant
.PHONY: lint
lint: ## Lint all source files
poetry run ruff assistant
.PHONY: run
run: ## Run web app
poetry run streamlit run assistant/app.py
.PHONY: build-wheel
build-wheel: ## Build package
poetry build -f wheel
.PHONY: build-image
build-image: ## Build docker image
docker build -t renumics-rag -f Dockerfile .
.PHONY: run-image-openai
run-image-openai: ## Build docker image
run-image-openai: build-image
docker run -it --rm -p 8000:8000 -p 8001:8001 --network=host -e OPENAI_API_KEY=$$OPENAI_API_KEY renumics-rag
.PHONY: run-image-azure
run-image-azure: ## Build docker image
run-image-azure: build-image
docker run -it --rm -p 8000:8000 -p 8001:8001 --network=host \
-e OPENAI_API_TYPE=$$OPENAI_API_TYPE \
-e OPENAI_API_VERSION=$$OPENAI_API_VERSION \
-e AZURE_OPENAI_API_KEY=$$AZURE_OPENAI_API_KEY \
-e AZURE_OPENAI_ENDPOINT=$$AZURE_OPENAI_ENDPOINT \
renumics-rag
.PHONY: docker-login
docker-login: ## Log in to Azure registry
docker login -u "$$AZURE_REGISTRY_USERNAME" -p "$$AZURE_REGISTRY_PASSWORD" "$$AZURE_REGISTRY"
.PHONY: release-image
release-image: ## Tag and push image to Azure registry
release-image: docker-login build-image
TIMESTAMP="$(shell date '+%Y-%m-%d_%H-%M-%S')"
docker tag renumics-rag "$${AZURE_REGISTRY}/renumics-rag:$$TIMESTAMP"
docker push "$${AZURE_REGISTRY}/renumics-rag:$$TIMESTAMP"
docker tag renumics-rag "$${AZURE_REGISTRY}/renumics-rag:latest"
docker push "$${AZURE_REGISTRY}/renumics-rag:latest"