use just instead of make

This commit is contained in:
mbsantiago 2025-06-26 13:29:23 -06:00
parent 70c96b6844
commit 6d91153a56
3 changed files with 118 additions and 117 deletions

117
Makefile
View File

@ -1,117 +0,0 @@
# Variables
SOURCE_DIR = src
TESTS_DIR = tests
PYTHON_DIRS = src tests
DOCS_SOURCE = docs/source
DOCS_BUILD = docs/build
HTML_COVERAGE_DIR = htmlcov
# Default target (optional, often 'help' or 'all')
.DEFAULT_GOAL := help
# Phony targets (targets that don't produce a file with the same name)
.PHONY: help test coverage coverage-html coverage-serve docs docs-serve format format-check lint lint-fix typecheck check clean clean-pyc clean-test clean-docs clean-build
help:
@echo "Makefile Targets:"
@echo " help Show this help message."
@echo " test Run tests using pytest."
@echo " coverage Run tests and generate coverage data (.coverage, coverage.xml)."
@echo " coverage-html Generate an HTML coverage report in $(HTML_COVERAGE_DIR)/."
@echo " coverage-serve Serve the HTML coverage report locally."
@echo " docs Build documentation using Sphinx."
@echo " docs-serve Serve documentation with live reload using sphinx-autobuild."
@echo " format Format code using ruff."
@echo " format-check Check code formatting using ruff."
@echo " lint Lint code using ruff."
@echo " lint-fix Lint code using ruff and apply automatic fixes."
@echo " typecheck Type check code using pyright."
@echo " check Run all checks (format-check, lint, typecheck)."
@echo " clean Remove all build, test, documentation, and Python artifacts."
@echo " clean-pyc Remove Python bytecode and cache."
@echo " clean-test Remove test and coverage artifacts."
@echo " clean-docs Remove built documentation."
@echo " clean-build Remove package build artifacts."
# Testing & Coverage
test:
pytest tests
coverage:
pytest --cov=batdetect2 --cov-report=term-missing --cov-report=xml tests
coverage-html: coverage
@echo "Generating HTML coverage report..."
coverage html -d $(HTML_COVERAGE_DIR)
@echo "HTML coverage report generated in $(HTML_COVERAGE_DIR)/"
coverage-serve: coverage-html
@echo "Serving report at http://localhost:8000/ ..."
python -m http.server --directory $(HTML_COVERAGE_DIR) 8000
# Documentation
docs:
sphinx-build -b html $(DOCS_SOURCE) $(DOCS_BUILD)
docs-serve:
sphinx-autobuild $(DOCS_SOURCE) $(DOCS_BUILD) --watch $(SOURCE_DIR) --open-browser
# Formatting & Linting
format:
ruff format $(PYTHON_DIRS)
format-check:
ruff format --check $(PYTHON_DIRS)
lint:
ruff check $(PYTHON_DIRS)
lint-fix:
ruff check --fix $(PYTHON_DIRS)
# Type Checking
typecheck:
pyright $(PYTHON_DIRS)
# Combined Checks
check: format-check lint typecheck test
# Cleaning tasks
clean-pyc:
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -exec rm -rf {} +
clean-test:
rm -f .coverage coverage.xml
rm -rf .pytest_cache htmlcov/
clean-docs:
rm -rf $(DOCS_BUILD)
clean-build:
rm -rf build/ dist/ *.egg-info/
clean: clean-build clean-pyc clean-test clean-docs
example-preprocess:
batdetect2 preprocess \
--base-dir . \
--dataset-field datasets.train \
--config config.yaml \
--force \
-vv \
config.yaml example_data/preprocessed
example-train:
batdetect2 train \
--train-examples example_data/preprocessed \
--train-config config.yaml \
--train-config-field train \
--preprocess-config config.yaml \
--preprocess-config-field preprocessing \
--target-config config.yaml \
--target-config-field targets \
--postprocess-config config.yaml \
--postprocess-config-field postprocessing \
--model-config config.yaml \
--model-config-field model

117
justfile Normal file
View File

@ -0,0 +1,117 @@
# Default command, runs if no recipe is specified.
default:
just --list
# Variables
SOURCE_DIR := "src"
TESTS_DIR := "tests"
PYTHON_DIRS := "src tests"
DOCS_SOURCE := "docs/source"
DOCS_BUILD := "docs/build"
HTML_COVERAGE_DIR := "htmlcov"
# Show available commands
help:
@just --list
# Testing & Coverage
# Run tests using pytest.
test:
pytest {{TESTS_DIR}}
# Run tests and generate coverage data.
coverage:
pytest --cov=batdetect2 --cov-report=term-missing --cov-report=xml {{TESTS_DIR}}
# Generate an HTML coverage report.
coverage-html: coverage
@echo "Generating HTML coverage report..."
coverage html -d {{HTML_COVERAGE_DIR}}
@echo "HTML coverage report generated in {{HTML_COVERAGE_DIR}}/"
# Serve the HTML coverage report locally.
coverage-serve: coverage-html
@echo "Serving report at http://localhost:8000/ ..."
python -m http.server --directory {{HTML_COVERAGE_DIR}} 8000
# Documentation
# Build documentation using Sphinx.
docs:
sphinx-build -b html {{DOCS_SOURCE}} {{DOCS_BUILD}}
# Serve documentation with live reload.
docs-serve:
sphinx-autobuild {{DOCS_SOURCE}} {{DOCS_BUILD}} --watch {{SOURCE_DIR}} --open-browser
# Formatting & Linting
# Format code using ruff.
format:
ruff format {{PYTHON_DIRS}}
# Check code formatting using ruff.
format-check:
ruff format --check {{PYTHON_DIRS}}
# Lint code using ruff.
lint:
ruff check {{PYTHON_DIRS}}
# Lint code using ruff and apply automatic fixes.
lint-fix:
ruff check --fix {{PYTHON_DIRS}}
# Type Checking
# Type check code using pyright.
typecheck:
pyright {{PYTHON_DIRS}}
# Combined Checks
# Run all checks (format-check, lint, typecheck).
check: format-check lint typecheck test
# Cleaning tasks
# Remove Python bytecode and cache.
clean-pyc:
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -exec rm -rf {} +
# Remove test and coverage artifacts.
clean-test:
rm -f .coverage coverage.xml
rm -rf .pytest_cache htmlcov/
# Remove built documentation.
clean-docs:
rm -rf {{DOCS_BUILD}}
# Remove package build artifacts.
clean-build:
rm -rf build/ dist/ *.egg-info/
# Remove all build, test, documentation, and Python artifacts.
clean: clean-build clean-pyc clean-test clean-docs
# Examples
# Preprocess example data.
example-preprocess OPTIONS:
batdetect2 preprocess \
--base-dir . \
--dataset-field datasets.train \
--config example_data/config.yaml \
{{OPTIONS}} \
example_data/datasets.yaml example_data/preprocessed
# Train on example data.
example-train:
batdetect2 train \
--train-examples example_data/preprocessed \
--train-config config.yaml \
--train-config-field train \
--preprocess-config config.yaml \
--preprocess-config-field preprocessing \
--target-config config.yaml \
--target-config-field targets \
--postprocess-config config.yaml \
--postprocess-config-field postprocessing \
--model-config config.yaml \
--model-config-field model

View File

@ -86,6 +86,7 @@ dev = [
"autodoc-pydantic>=2.2.0", "autodoc-pydantic>=2.2.0",
"pytest-cov>=6.1.1", "pytest-cov>=6.1.1",
"ty>=0.0.1a12", "ty>=0.0.1a12",
"rust-just>=1.40.0",
] ]
dvclive = [ dvclive = [
"dvclive>=3.48.2", "dvclive>=3.48.2",