-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
68 lines (52 loc) · 1.95 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
SHELL := /bin/bash
DIR=$(shell basename $$(pwd))
CONTAINER_IMAGE=quay.io/vicenteherrera/promptfoo
CONTAINER_TAG=latest
CONFIG_FILE=$(shell for p in "env.txt" "../env.txt" "../../env.txt" "../../../env.txt"; do [[ -f "$$p" ]] && echo "$$p" && break; done || echo "")
all: requirements install_promptfoo
run: run-offline
run-online: config_exists
source ${CONFIG_FILE} && \
cd data && \
promptfoo eval
run-offline: config_exists
source ${CONFIG_FILE} && \
cd data && \
PROMPTFOO_DISABLE_TELEMETRY=1 \
PROMPTFOO_DISABLE_UPDATE=1 \
promptfoo eval
run-view:
promptfoo view -y -p 15500
install_promptfoo:
npm install -g promptfoo
requirements:
npm --version
config_exists:
@[ ! -z "${CONFIG_FILE}" ] || ( echo "Error: Config file env.txt not found" && exit 1 )
@echo "Config file found at ${CONFIG_FILE}"
# Container targets ------------------------------------------
# Check if sudo is required to run Docker
RUNSUDO := $(shell groups | grep ' docker \|com\.apple' 1>/dev/null || echo "sudo")
container-build: config_exists
@echo "Building container image ${CONTAINER_IMAGE}:${CONTAINER_TAG}"
@source ${CONFIG_FILE} && \
${RUNSUDO} docker build . -f build/containerfile_dev \
--secret id=OPENAI_API_KEY,env=OPENAI_API_KEY \
-t ${CONTAINER_IMAGE}:${CONTAINER_TAG}
${RUNSUDO} docker image ls ${CONTAINER_IMAGE}:${CONTAINER_TAG}
container-run:
@echo "Running container image ${CONTAINER_IMAGE}:${CONTAINER_TAG}"
@${RUNSUDO} docker run -it \
-p 15500:15500 \
${CONTAINER_IMAGE}:${CONTAINER_TAG} sh -c "make run-view"
container-run-dev: config_exists
@echo "Running container image with local dir mounted ${CONTAINER_IMAGE}:${CONTAINER_TAG}"
@${RUNSUDO} docker run \
-v "$$(pwd)"/${CONFIG_FILE}:/home/env.txt" \
-u $$(id -u):$$(id -g) \
-p 15500:15500 \
-it \
${CONTAINER_IMAGE}:${CONTAINER_TAG} /bin/bash
container-push:
@echo "Pushing container image ${CONTAINER_IMAGE}:${CONTAINER_TAG}"
${RUNSUDO} docker push ${CONTAINER_IMAGE}:${CONTAINER_TAG}