Spaces:
Sleeping
Sleeping
File size: 8,011 Bytes
4780d8d |
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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# Makefile Usage Guide
This document provides detailed information about the Makefile targets available in the Mosaic project.
## Quick Start
```bash
# See all available commands
make help
# Setup development environment
make install-dev
# Run tests
make test
# Launch web interface
make run-ui
```
## Development Setup
### `make install`
Install production dependencies only (no dev tools).
```bash
make install
```
### `make install-dev`
Install all dependencies including development tools (pytest, ruff, etc.).
```bash
make install-dev
```
## Testing
### `make test`
Run full test suite with coverage reporting.
```bash
make test
```
### `make test-fast`
Run tests without coverage (faster execution).
```bash
make test-fast
```
### `make test-coverage`
Run tests with detailed coverage report (terminal + HTML).
```bash
make test-coverage
# View HTML report at: htmlcov/index.html
```
### `make test-ui`
Run only UI-related tests.
```bash
make test-ui
```
### `make test-cli`
Run only CLI-related tests.
```bash
make test-cli
```
### `make test-verbose`
Run tests with verbose output and show print statements.
```bash
make test-verbose
```
### `make test-specific`
Run a specific test file, class, or method.
```bash
# Run specific test file
make test-specific TEST=tests/test_cli.py
# Run specific test class
make test-specific TEST=tests/test_cli.py::TestArgumentParsing
# Run specific test method
make test-specific TEST=tests/test_cli.py::TestArgumentParsing::test_no_arguments_launches_web_interface
```
## Code Quality
### `make lint`
Check code for linting issues using pylint (src only for speed).
```bash
make lint
```
### `make lint-strict`
Run pylint on both src and tests (slower but comprehensive).
```bash
make lint-strict
```
### `make format`
Format code using black formatter.
```bash
make format
```
### `make format-check`
Check if code is properly formatted without making changes.
```bash
make format-check
```
### `make quality`
Run all code quality checks (format-check + lint).
```bash
make quality
```
## Running the Application
### `make run-ui`
Launch the Gradio web interface locally.
```bash
make run-ui
# Open browser to http://localhost:7860
```
### `make run-ui-public`
Launch Gradio web interface with public sharing enabled.
```bash
make run-ui-public
# Returns a public gradio.app URL for sharing
```
### `make run-single`
Process a single slide from the command line.
```bash
make run-single SLIDE=data/my_slide.svs OUTPUT=output/
```
### `make run-batch`
Process multiple slides from a CSV file.
```bash
make run-batch CSV=data/settings.csv OUTPUT=output/
```
## Docker
### `make docker-build`
Build Docker image for Mosaic.
```bash
make docker-build
# Build with custom tag
make docker-build DOCKER_TAG=v1.0.0
# Build with custom image name
make docker-build DOCKER_IMAGE_NAME=my-mosaic DOCKER_TAG=latest
```
### `make docker-build-no-cache`
Build Docker image without using cache (useful for clean builds).
```bash
make docker-build-no-cache
```
### `make docker-run`
Run Docker container in web UI mode.
```bash
make docker-run
# Access at http://localhost:7860
```
### `make docker-run-single`
Run Docker container to process a single slide.
```bash
# Place your slide in ./data directory first
make docker-run-single SLIDE=my_slide.svs
# Results will be in ./output directory
```
### `make docker-run-batch`
Run Docker container for batch processing.
```bash
# Place CSV and slides in ./data directory
make docker-run-batch CSV=settings.csv
# Results will be in ./output directory
```
### `make docker-shell`
Open an interactive shell inside the Docker container.
```bash
make docker-shell
```
### `make docker-tag`
Tag Docker image for pushing to a registry.
```bash
make docker-tag DOCKER_REGISTRY=docker.io/myusername
```
### `make docker-push`
Push Docker image to registry.
```bash
# Set your registry first
make docker-push DOCKER_REGISTRY=docker.io/myusername DOCKER_TAG=latest
```
### `make docker-clean`
Remove local Docker image.
```bash
make docker-clean
```
### `make docker-prune`
Clean up Docker build cache to free space.
```bash
make docker-prune
```
## Cleanup
### `make clean`
Remove Python cache files and build artifacts.
```bash
make clean
```
### `make clean-outputs`
Remove generated output files (masks, CSVs).
```bash
make clean-outputs
```
### `make clean-all`
Remove all artifacts, cache, and Docker images.
```bash
make clean-all
```
## Model Management
### `make download-models`
Explicitly download required models from HuggingFace.
```bash
make download-models
# Note: Models are automatically downloaded on first run
```
## CI/CD
### `make ci-test`
Run complete CI test suite (install deps, test with coverage, lint).
```bash
make ci-test
```
### `make ci-docker`
Build Docker image for CI pipeline.
```bash
make ci-docker
```
## Development Utilities
### `make shell`
Open Python shell with project in path.
```bash
make shell
```
### `make ipython`
Open IPython shell with project in path.
```bash
make ipython
```
### `make notebook`
Start Jupyter notebook server.
```bash
make notebook
```
### `make check-deps`
Check for outdated dependencies.
```bash
make check-deps
```
### `make update-deps`
Update all dependencies (use with caution).
```bash
make update-deps
```
### `make lock`
Update uv.lock file.
```bash
make lock
```
## Git Hooks
### `make pre-commit-install`
Install pre-commit hooks that run lint, format-check, and test-fast before each commit.
```bash
make pre-commit-install
```
### `make pre-commit-uninstall`
Remove pre-commit hooks.
```bash
make pre-commit-uninstall
```
## Information
### `make info`
Display project information and key commands.
```bash
make info
```
### `make version`
Show version information.
```bash
make version
```
### `make tree`
Show project directory structure (requires `tree` command).
```bash
make tree
```
## Performance
### `make profile`
Profile single slide analysis to identify performance bottlenecks.
```bash
make profile SLIDE=tests/testdata/948176.svs
# Creates profile.stats file with profiling data
```
### `make benchmark`
Run performance benchmarks on test slide.
```bash
make benchmark
# Times full analysis pipeline
```
## Common Workflows
### Setting up for development
```bash
# 1. Install dependencies
make install-dev
# 2. Run tests to ensure everything works
make test
# 3. Install pre-commit hooks
make pre-commit-install
```
### Before committing changes
```bash
# Run quality checks
make quality
# Run tests
make test
# Clean up
make clean
```
### Preparing a release
```bash
# Run full CI suite
make ci-test
# Build Docker image
make docker-build DOCKER_TAG=v1.0.0
# Test Docker image
make docker-run DOCKER_TAG=v1.0.0
# Push to registry
make docker-push DOCKER_REGISTRY=your-registry DOCKER_TAG=v1.0.0
```
### Processing slides
```bash
# Web UI (recommended for exploration)
make run-ui
# Single slide (CLI)
make run-single SLIDE=data/sample.svs OUTPUT=results/
# Batch processing (CLI)
make run-batch CSV=data/batch_settings.csv OUTPUT=results/
# Using Docker
make docker-build
make docker-run-batch CSV=batch_settings.csv
```
## Customization
You can customize Makefile behavior by setting environment variables or editing the Makefile:
```bash
# Custom Docker registry
export DOCKER_REGISTRY=my-registry.com/username
# Custom image name
export DOCKER_IMAGE_NAME=my-custom-mosaic
# Then use make commands as normal
make docker-build
make docker-push
```
## Troubleshooting
### Tests fail
```bash
# Run with verbose output
make test-verbose
# Run specific failing test
make test-specific TEST=tests/test_file.py::test_name
```
### Docker build fails
```bash
# Build without cache
make docker-build-no-cache
# Check Docker logs
docker logs <container-id>
```
### Permission errors
```bash
# Clean and rebuild
make clean-all
make install-dev
```
### Out of disk space
```bash
# Clean Docker cache
make docker-prune
# Clean project artifacts
make clean
```
|