Skip to content

Commit

Permalink
Third iteration
Browse files Browse the repository at this point in the history
- Added a `Makefile` for managing various tasks.
- Updated the `README.md` and `pyproject.toml` files, fixing typos and issues.
  • Loading branch information
habedi committed Jan 25, 2025
1 parent 477be73 commit c047857
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 18 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Hassan Abedi
Copyright (c) 2025 Hassan Abedi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
64 changes: 64 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Variables
PYTHON = python
PIP = pip
POETRY = poetry

# Default target
.DEFAULT_GOAL := help

.PHONY: help
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: install
install: ## Install dependencies
$(POETRY) install

.PHONY: test
test: ## Run tests
$(POETRY) run pytest

.PHONY: lint
lint: ## Run ruff and flake8
$(POETRY) run ruff check .
$(POETRY) run flake8 .

.PHONY: format
format: ## Format code with ruff and black
$(POETRY) run ruff format .
$(POETRY) run black .

.PHONY: mypy
mypy: ## Run mypy
$(POETRY) run mypy .

.PHONY: clean
clean: ## Clean up generated files
find . -type f -name '*.pyc' -delete
find . -type d -name '__pycache__' -exec rm -r {} +
rm -rf .mypy_cache
rm -rf .pytest_cache
rm -rf .ruff_cache
rm -rf .coverage
rm -rf htmlcov
rm -rf coverage.xml
rm -rf junit

.PHONY: coverage
coverage: ## Run tests with coverage
$(POETRY) run pytest --cov=src --cov-report=term-missing

.PHONY: build
build: ## Build the project
$(POETRY) build

.PHONY: check
check: lint mypy test ## Run lint, mypy, and tests

.PHONY: all
all: install check build ## Install dependencies, run checks, and build the project

.PHONY: precommit
precommit: ## Install and run pre-commit hooks
$(POETRY) run pre-commit install
$(POETRY) run pre-commit run --all-files
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,24 @@
[![Python Version](https://img.shields.io/badge/Python-%3E=3.10-blue)](https://github.com/habedi/template-python-project)
[![License](https://img.shields.io/badge/License-MIT-blue)](https://github.com/habedi/template-python-project/blob/main/LICENSE)

This is a simple and minimalistic template repository for starting new data science and machine learning projects in
Python.
This is a template repository for starting new data science and machine learning projects in Python.

I created this template to help me speed up the setup process for my projects.
And to have a consistent structure across all my personal and professional projects.
I'm sharing it here in the hope that others find it useful.
So, feel free to use it as a starting point for your projects.
I created this template to help me speed up the setup process for my projects and to have a consistent structure across
all my personal and professional projects.
I'm sharing it here in case it might be useful to others as well.

---

## Notable Features
## Features

- A predefined file and folder layout that should be suitable for most data science workflows.
- Easy dependency and environment management with [Poetry](https://python-poetry.org/).
- Easy dependency and environment management with [Poetry](https://python-poetry.org/)
or [uv](https://github.com/astral-sh/uv).
- Extra configuration files for various tasks like linting, formatting, and testing.

---

## Folder Structure

The repository is organized as follows:
## Structure

```plaintext
template-python-project/
Expand All @@ -36,7 +33,8 @@ template-python-project/
├── tests/ # Unit tests and test files
├── pyproject.toml # Project metadata and dependencies
├── LICENSE # License information
└── README.md # Project documentation
├── README.md # Project documentation
└── Makefile # Makefile for managing common tasks like linting and testing
```

---
Expand Down
12 changes: 7 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pytest-cov = "^6.0.0"
pytest-mock = "^3.14.0"
mypy = "^1.11.1"
ruff = "^0.8.6"
black = "^24.10.0"
flake8 = "^7.1.1"

[tool.poetry.scripts]
cli_script = "src.cli:main"
Expand All @@ -28,7 +30,7 @@ requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.pytest.ini_options]
pythonpath = [".", "src", 'bin']
pythonpath = [".", "src", 'bin', 'notebooks']

[tool.mypy]
python_version = "3.10"
Expand Down Expand Up @@ -69,14 +71,14 @@ exclude = [
]
line-length = 100
indent-width = 4
src = ["mongo_analyser", "tests"]
target-version = "py311"
src = ["src", "tests", "bin", "notebooks"]
target-version = "py310"

[tool.ruff.lint]
select = ["ANN", "D", "E", "F", "I"]
ignore = [
"ANN101", # Don't annotate self
"ANN102" # Don't annotate cls
# Ignore missing docstrings
"D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107",
]
fixable = ["ALL"]
unfixable = []
Expand Down

0 comments on commit c047857

Please sign in to comment.