Skip to content

Commit 0ca26d0

Browse files
committed
update toml conf and makefile
1 parent 325dd16 commit 0ca26d0

2 files changed

Lines changed: 88 additions & 53 deletions

File tree

Makefile

Lines changed: 81 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# ==============================================================
2-
# Minimal Cog Makefile: Build, Push, Deploy, Clean, Delete, Lint,Test,Doc Deploy(Todo)
3-
# ==============================================================
4-
51
MODEL_DIR ?= $(CURDIR)
62
MODEL_DIR := $(abspath $(MODEL_DIR))
73
MODEL_NAME := $(notdir $(MODEL_DIR))
@@ -15,83 +11,116 @@ REGISTRY := r8.im
1511
IMAGE_TAG := $(REGISTRY)/$(USERNAME)/$(MODEL_NAME)
1612

1713

18-
# --------------------------------------------------------------
19-
# Skinny help
20-
# --------------------------------------------------------------
14+
# ----------------------------------------
15+
# Help
16+
# ----------------------------------------
2117
.PHONY: help
2218
help: ## Show available commands
23-
@echo "Cog Makefile Commands:"
24-
@echo ""
2519
@grep -E '^[a-zA-Z_-]+:.*?##' Makefile | sed 's/:.*##/: /'
2620

2721

28-
# --------------------------------------------------------------
29-
# Build image
30-
# --------------------------------------------------------------
22+
# ----------------------------------------
23+
# Login
24+
# ----------------------------------------
25+
.PHONY: login
26+
login: ## Login to Replicate using Cog
27+
@if [ ! -x "$(COG_CMD)" ]; then echo "Cog not found"; exit 1; fi
28+
"$(COG_CMD)" login
29+
30+
31+
# ----------------------------------------
32+
# Lint
33+
# ----------------------------------------
34+
.PHONY: lint
35+
lint: ## Run ruff linting and pytest collection checks
36+
ruff check .
37+
pytest --collect-only
38+
39+
40+
# ----------------------------------------
41+
# Build
42+
# ----------------------------------------
3143
.PHONY: build
32-
build: ## Build Cog image for MODEL_DIR
33-
@if [ ! -x "$(COG_CMD)" ]; then echo "Cog not found at $(COG_CMD)"; exit 1; fi
34-
@if [ ! -f "$(MODEL_DIR)/cog.yaml" ]; then echo "cog.yaml missing in $(MODEL_DIR)"; exit 1; fi
44+
build: ## Build Cog image
45+
@if [ ! -x "$(COG_CMD)" ]; then echo "Cog not found"; exit 1; fi
46+
@if [ ! -f "$(MODEL_DIR)/cog.yaml" ]; then echo "cog.yaml missing"; exit 1; fi
3547
cd "$(MODEL_DIR)" && "$(COG_CMD)" build -t "$(MODEL_NAME)"
36-
echo "Build complete: $(MODEL_NAME)"
3748

3849

39-
# --------------------------------------------------------------
40-
# Push image
41-
# --------------------------------------------------------------
50+
# ----------------------------------------
51+
# Push
52+
# ----------------------------------------
4253
.PHONY: push
43-
push: ## Push model to Replicate (no auto-login)
54+
push: ## Push image to Replicate
4455
cd "$(MODEL_DIR)" && "$(COG_CMD)" push "$(IMAGE_TAG)"
45-
echo "Pushed: $(IMAGE_TAG)"
4656

4757

48-
# --------------------------------------------------------------
49-
# Deploy with auto-login
50-
# --------------------------------------------------------------
58+
# ----------------------------------------
59+
# Deploy
60+
# ----------------------------------------
5161
.PHONY: deploy
52-
deploy: ## Deploy model to Replicate (auto-login, prefers model-local cog)
53-
@if [ ! -x "$(COG_CMD)" ]; then echo "Cog not found at $(COG_CMD)"; exit 1; fi
54-
@if [ ! -f "$(MODEL_DIR)/cog.yaml" ]; then echo "cog.yaml missing in $(MODEL_DIR)"; exit 1; fi
55-
@if ! "$(COG_CMD)" whoami >/dev/null 2>&1; then \
56-
echo "Not logged in → running cog login..."; \
57-
"$(COG_CMD)" login || exit 1; \
58-
fi
62+
deploy: ## Auto-login and push
63+
@if ! "$(COG_CMD)" whoami >/dev/null 2>&1; then "$(COG_CMD)" login; fi
5964
cd "$(MODEL_DIR)" && "$(COG_CMD)" push "$(IMAGE_TAG)"
60-
echo "Deployed: $(IMAGE_TAG)"
6165

6266

63-
# --------------------------------------------------------------
67+
# ----------------------------------------
6468
# Remove local Docker images
65-
# --------------------------------------------------------------
69+
# ----------------------------------------
6670
.PHONY: remove-image
67-
remove-image: ## Remove local Docker images for MODEL_DIR
71+
remove-image: ## Remove local Docker images
6872
@if command -v docker >/dev/null 2>&1; then \
6973
docker rmi -f "$(MODEL_NAME)" 2>/dev/null || true; \
7074
docker rmi -f "$(IMAGE_TAG)" 2>/dev/null || true; \
71-
echo "Local images removed."; \
72-
else \
73-
echo "Docker not installed; skipping."; \
7475
fi
7576

7677

77-
# --------------------------------------------------------------
78-
# Delete model-local Cog + images
79-
# --------------------------------------------------------------
78+
# ----------------------------------------
79+
# Delete local Cog + images
80+
# ----------------------------------------
8081
.PHONY: delete-local
81-
delete-local: ## Remove model-local Cog and Docker artifacts
82-
@if [ -f "$(LOCAL_COG)" ]; then rm -f "$(LOCAL_COG)"; echo "Removed model-local Cog."; fi
83-
$(MAKE) -s remove-image MODEL_DIR="$(MODEL_DIR)"
84-
echo "delete-local complete."
82+
delete-local: ## Delete .cog and local images
83+
@if [ -f "$(LOCAL_COG)" ]; then rm -f "$(LOCAL_COG)"; fi
84+
$(MAKE) -s remove-image
8585

8686

87-
# --------------------------------------------------------------
88-
# Clean Python cache
89-
# --------------------------------------------------------------
87+
# ----------------------------------------
88+
# Clean pycache
89+
# ----------------------------------------
9090
.PHONY: clean
91-
clean: ## Remove pycache and *.pyc
92-
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
93-
find . -type f -name "*.pyc" -delete 2>/dev/null || true
94-
echo "Clean complete."
91+
clean: ## Clean __pycache__ and pyc files
92+
find . -type d -name "__pycache__" -exec rm -rf {} +
93+
find . -type f -name "*.pyc" -delete
94+
95+
96+
# ----------------------------------------
97+
# Testing (unit / integration / deployment)
98+
# ----------------------------------------
99+
.PHONY: unit
100+
unit: ## Run unit tests
101+
pytest -m "unit"
102+
103+
.PHONY: integration
104+
integration: ## Run integration tests
105+
pytest -m "integration"
106+
107+
.PHONY: deployment
108+
deployment: ## Run deployment tests
109+
pytest -m "deployment"
110+
111+
112+
# ----------------------------------------
113+
# CI → Unit tests only
114+
# ----------------------------------------
115+
.PHONY: ci
116+
ci: lint unit ## Run linting + unit tests only
117+
118+
119+
# ----------------------------------------
120+
# CD → All tests
121+
# ----------------------------------------
122+
.PHONY: cd
123+
cd: lint unit integration deployment ## Run all tests for CD pipeline
95124

96125

97126
.DEFAULT_GOAL := help

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ gemma-torchao = [
7575
dev-tooling = [
7676
"pre-commit",
7777
"ty",
78+
"ruff",
7879
"pytest"
7980
]
8081

@@ -84,6 +85,11 @@ minversion = "8.0"
8485
addopts = "-ra -q"
8586
testpaths = ["tests"]
8687
pythonpath = ["src"]
88+
markers = [
89+
"unit: fast contract tests",
90+
"integration: tests requiring Replicate API",
91+
"deployment: tests verifying container build",
92+
]
8793
filterwarnings = [
8894
"ignore::DeprecationWarning",
8995
"ignore::UserWarning",
@@ -95,8 +101,8 @@ line-length = 99
95101
target-version = "py310"
96102
fix = true
97103
show-fixes = true
104+
ignore = ["E203"]
98105
select = ["E", "F", "I", "B", "UP"]
99-
ignore = ["E203", "W503"]
100106
exclude = ["__pycache__", "build", "dist"]
101107

102108
[tool.ruff.format]

0 commit comments

Comments
 (0)