Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (88 loc) · 3.08 KB
/
Copy pathMakefile
File metadata and controls
99 lines (88 loc) · 3.08 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
# Makefile for MLOps Azure Databricks GitHub Playbook
.PHONY: setup test lint format clean help deploy-dev deploy-staging deploy-prod
# Variables
PYTHON = python
VENV = .venv
PIP = $(VENV)/bin/pip
PYTEST = $(VENV)/bin/pytest
FLAKE8 = $(VENV)/bin/flake8
BLACK = $(VENV)/bin/black
ISORT = $(VENV)/bin/isort
TERRAFORM = terraform
DATABRICKS = databricks
# Default target
help:
@echo "MLOps Azure Databricks GitHub Playbook"
@echo ""
@echo "Usage:"
@echo " make setup Install dependencies and set up environment"
@echo " make test Run all tests"
@echo " make lint Run linting checks"
@echo " make format Format code"
@echo " make clean Clean up generated files"
@echo " make deploy-dev Deploy to development environment"
@echo " make deploy-staging Deploy to staging environment"
@echo " make deploy-prod Deploy to production environment"
@echo " make help Show this help message"
# Setup environment
setup:
@echo "Setting up environment..."
@if [ ! -d "$(VENV)" ]; then $(PYTHON) -m venv $(VENV); fi
@$(PIP) install --upgrade pip
@$(PIP) install -r requirements.txt
@$(PIP) install -e .
@$(PIP) install pre-commit
@pre-commit install
@./scripts/setup/setup_dev_environment.sh
@echo "Setup complete! Activate the virtual environment with: source $(VENV)/bin/activate"
# Run tests
test:
@echo "Running tests..."
@$(PYTEST) tests/ -v
# Run linting
lint:
@echo "Running linting checks..."
@$(FLAKE8) src tests
@$(BLACK) --check src tests
@$(ISORT) --check-only --profile black src tests
# Format code
format:
@echo "Formatting code..."
@$(BLACK) src tests
@$(ISORT) --profile black src tests
# Clean generated files
clean:
@echo "Cleaning up..."
@rm -rf __pycache__
@rm -rf .pytest_cache
@rm -rf dist
@rm -rf build
@rm -rf *.egg-info
@find . -type d -name __pycache__ -exec rm -rf {} +
@find . -type d -name "*.egg-info" -exec rm -rf {} +
@find . -type f -name "*.pyc" -delete
@find . -type f -name "*.pyo" -delete
@find . -type f -name "*.pyd" -delete
@echo "Cleanup complete!"
# Deployment targets
deploy-dev:
@echo "Deploying to development environment..."
@cd infrastructure/terraform && \
$(TERRAFORM) workspace select dev || $(TERRAFORM) workspace new dev && \
$(TERRAFORM) apply -var-file=dev.tfvars -auto-approve
@echo "Deploying notebooks and code..."
@$(DATABRICKS) workspace import_dir notebooks /Shared/dev/notebooks -o
deploy-staging:
@echo "Deploying to staging environment..."
@cd infrastructure/terraform && \
$(TERRAFORM) workspace select staging || $(TERRAFORM) workspace new staging && \
$(TERRAFORM) apply -var-file=staging.tfvars -auto-approve
@echo "Deploying notebooks and code..."
@$(DATABRICKS) workspace import_dir notebooks /Shared/staging/notebooks -o
deploy-prod:
@echo "Deploying to production environment..."
@cd infrastructure/terraform && \
$(TERRAFORM) workspace select prod || $(TERRAFORM) workspace new prod && \
$(TERRAFORM) apply -var-file=prod.tfvars -auto-approve
@echo "Deploying notebooks and code..."
@$(DATABRICKS) workspace import_dir notebooks /Shared/prod/notebooks -o