-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
53 lines (42 loc) · 2.02 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
# Names of the code directory and the Docker image, change them to match your project
DOCKER_IMAGE_NAME := break_prediction
DOCKER_CONTAINER_NAME := break_prediction
CODE_DIRECTORY := code
DATA_DIRECTORY := data
DOCKER_PARAMS= -it --rm --name=$(DOCKER_CONTAINER_NAME)
# Specify GPU device(s) to use. Comment out this line if you don't have GPUs available
DOCKER_PARAMS+= --gpus '"device=3"' #'"device=0,1"'
# Run Docker container while mounting the local directory
DOCKER_RUN_MOUNT= docker run $(DOCKER_PARAMS) -v $(PWD):/workspace/break_detection $(DOCKER_IMAGE_NAME)
usage:
@echo "Available commands:\n-----------"
@echo " build Build the Docker image"
@echo " run Run the Docker image in a container, after building it"
@echo " run-bash Same as 'run', and launches an interactive bash session in the container while mounting the current directory"
@echo " stop Stop the container if it is running"
@echo " poetry Use poetry to modify 'pyproject.toml' and 'poetry.lock' files (e.g. 'make poetry add requests' to add the 'requests' package)"
@echo " check Check coding conventions using multiple tools"
@echo " clean Format your code using black and isort to fit coding conventions"
@echo " logs print the last 250 lines from the end of the logs"
build:
docker build -t $(DOCKER_IMAGE_NAME) .
run: build stop
docker run $(DOCKER_PARAMS) $(DOCKER_IMAGE_NAME)
run-bash:
$(DOCKER_RUN_MOUNT) /bin/bash
stop:
docker stop $(DOCKER_IMAGE_NAME) || true && docker rm $(DOCKER_IMAGE_NAME) || true
poetry:
$(DOCKER_RUN_MOUNT) poetry $(filter-out $@,$(MAKECMDGOALS))
%: # Avoid printing anything after executing the 'poetry' target
@:
check:
$(DOCKER_RUN_MOUNT) poetry run pyflakes $(CODE_DIRECTORY) || exit 1
$(DOCKER_RUN_MOUNT) poetry run black --check $(CODE_DIRECTORY) || exit 1
$(DOCKER_RUN_MOUNT) poetry run isort --check $(CODE_DIRECTORY) || exit 1
@echo "\nAll is good !\n"
clean:
$(DOCKER_RUN_MOUNT) poetry run black $(CODE_DIRECTORY)
$(DOCKER_RUN_MOUNT) poetry run isort $(CODE_DIRECTORY)
logs:
docker logs --tail 250 ${DOCKER_TAG}