-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (63 loc) · 2.4 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
.ONESHELL:
SHELL = /bin/bash
# Define variables
ENV_YML = environment.yml
ENV_NAME = ds
KERNEL_NAME = ds
LOCAL_CONDA = ~/.conda
GIT_REPO = https://github.com/TUW-GEO/data-science-notebooks.git
GIT_BRANCH = main
REPO_NAME = data-science-notebooks
# Help command to display available targets
help:
@echo "Makefile for setting up environment, kernel, and pulling notebooks"
@echo ""
@echo "Usage:"
@echo " make notebooks - Pull the notebooks from the Git repository"
@echo " make environment - Create the conda environment"
@echo " make kernel - Create the Jupyter kernel"
@echo " make all - Run all the above tasks"
@echo " "
@echo " make teardown - Remove the environment and kernel"
@echo " make delete - Deletes the cloned Repository and removes kernel and environment"
@echo " make remove - Deletes only the cloned Repository"
@echo " make clean - Removes ipynb_checkpoints"
@echo " make help - Display this help message"
.PHONY: all notebooks environment kernel teardown clean
all: notebooks environment kernel
# Pull the notebooks from the Git repository
notebooks:
@echo "Cloning the Git repository..."
git clone $(GIT_REPO) -b $(GIT_BRANCH) $(REPO_NAME)
@echo "Repository cloned."
# Create the environment using conda
environment:
@echo "Creating conda environment..."
mkdir -p $(LOCAL_CONDA)/envs
cd $(REPO_NAME)
mamba env create -p $(LOCAL_CONDA)/envs/$(ENV_NAME) -f env/$(ENV_YML)
@echo "Environment $(ENV_NAME) created."
# Create a Jupyter kernel from the environment
kernel: environment
@echo "Creating Jupyter kernel..."
mamba run -p $(LOCAL_CONDA)/envs/$(ENV_NAME) python -m ipykernel install --user --name "$(KERNEL_NAME)" --display-name "$(KERNEL_NAME)"
@echo "Kernel $(KERNEL_NAME) created."
# Remove the environment and kernel
teardown:
@echo "Removing the Kernel and the Environment..."
jupyter kernelspec uninstall "$(KERNEL_NAME)" -f
mamba env remove -p $(LOCAL_CONDA)/envs/$(ENV_NAME)
@echo "Kernel and Environment have been removed."
delete: teardown
@echo "Deleting all files in $(REPO_NAME)..."
rm -rf $(REPO_NAME)
@echo "$(REPO_NAME) has been deleted."
remove:
@echo "Deleting all files in $(REPO_NAME)..."
rm -rf $(REPO_NAME)
@echo "$(REPO_NAME) has been deleted."
# Clean up. Removes ipynb_checkpoints
clean:
@echo "Removing ipynb_checkpoints..."
rm --force --recursive .ipynb_checkpoints/
@echo "Clean up completed."