Skip to content

Commit

Permalink
Update the template
Browse files Browse the repository at this point in the history
Updated a few files, including the README.md file to make the template cleaner and better
  • Loading branch information
habedi committed Jan 5, 2025
1 parent 26e1a73 commit 477be73
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 52 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ max_line_length = 100
# Markdown files
[*.md]
trim_trailing_whitespace = false # Don't remove trailing whitespace in Markdown files
max_line_length = 120
# Bash scripts
[*.sh]
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -29,14 +29,16 @@ jobs:
- name: Run Tests with Coverage
run: |
poetry run pytest tests/ --doctest-modules --cov=src --cov-report xml --cov-report html \
poetry run pytest tests/ --doctest-modules --cov=src/ --cov-report xml \
--cov-report html:htmlcov-${{ matrix.python-version }} \
--junitxml=junit/test-results-${{ matrix.python-version }}.xml
continue-on-error: false
continue-on-error: true # Continue on error to upload test results and coverage reports as artifacts

- name: Upload Test Results and Coverage Reports
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: test-results-and-coverage
overwrite: true # Overwrite the existing artifact(s) with the same name
path: |
junit/test-results-${{ matrix.python-version }}.xml
htmlcov/
htmlcov-${{ matrix.python-version }}/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ coverage.xml
*.cover
.hypothesis/
.pytest_cache/
test-reports/
test-report.xml
test-results.xml

# IDE specific files and directories
.idea/
Expand Down
74 changes: 32 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,46 @@
# Template for Python Projects
# A Template Repository for Data Science Projects

[![Tests](https://github.com/habedi/template-python-project-repo/actions/workflows/tests.yml/badge.svg)](https://github.com/habedi/template-python-project-repo/actions/workflows/tests.yml)
[![Python version](https://img.shields.io/badge/Python-%3E=3.10-blue)](https://github.com/habedi/template-python-project-repo)
[![License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/habedi/template-python-project-repo/blob/main/LICENSE)
[![Tests](https://github.com/habedi/template-python-project/actions/workflows/tests.yml/badge.svg)](https://github.com/habedi/template-python-project/actions/workflows/tests.yml)
[![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 repository is as a template for starting Python projects. It includes a basic structure for organizing the things
like code,
data, and notebooks, as well as a configuration file for managing the dependencies using Poetry. The repository also
includes a GitHub Actions workflow for running tests on the codebase.
This is a simple and minimalistic template repository for starting new data science and machine learning projects in
Python.

I made it mainly for my personal and professional machine learning data science projects, but feel free to use it
as a starting point for your own projects if you find it useful.
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.

## Installing Poetry
---

We use [Poetry](https://python-poetry.org/) for managing the dependencies and virtual environment for the project. To
get
started, you need to install Poetry on your machine. We can install Poetry by running the following command in the
command
line using pip.
## Notable Features

```bash
pip install poetry
```

When the installation is finished, run the following command in the shell in the root folder of this repository to
install the dependencies, and create a virtual environment for the project.

```bash
poetry install
```
- 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/).
- Extra configuration files for various tasks like linting, formatting, and testing.

After that, enter the Poetry environment by invoking the poetry shell command.

```bash
poetry shell
```
---

## Folder Structure

The repository has the following structure:
The repository is organized as follows:

```plaintext
template-python-project/
├── bin/ # Scripts and command-line tools
├── data/ # Raw and processed datasets
├── notebooks/ # Jupyter notebooks for exploration, analysis, and prototyping
├── src/ # Source code for the project
├── models/ # ML models and related files
├── tests/ # Unit tests and test files
├── pyproject.toml # Project metadata and dependencies
├── LICENSE # License information
└── README.md # Project documentation
```

- `bin/`: scripts and executables for command line use
- `data/`: data files and datasets
- `src/`: source code files
- `notebooks/`: Jupyter notebooks files
- `models/`: trained models and model files
- `tests/`: test files for the source code
- `pyproject.toml`: project metadata and dependencies
- `LICENSE`: license information
- `README.md`: project information and instructions
---

## License

Files in this repository are licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
The files in this repository are licensed under the [MIT License](LICENSE).
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[tool.poetry]
name = "template-python-project-repo"
name = "template-python-project"
version = "0.1.0"
description = "A template for a data science or machine learning project in Python."
description = "A template repository for data science and machine learning projects in Python."
authors = ["Hassan Abedi <hassan.abedi.t@gmail.com>"]
maintainers = ["Hassan Abedi <hassan.abedi.t@gmail.com>"]
readme = "README.md"
repository = "https://github.com/habedi/template-python-project"
license = "MIT"
packages = [{ include = "src", from = "." }]

Expand All @@ -14,10 +15,10 @@ python = "^3.10"
[tool.poetry.dev-dependencies]
poetry-dynamic-versioning = "^1.4.0"
pytest = "^8.0.1"
pytest-cov = "^5.0.0"
pytest-cov = "^6.0.0"
pytest-mock = "^3.14.0"
mypy = "^1.11.1"
ruff = "^0.7.1"
ruff = "^0.8.6"

[tool.poetry.scripts]
cli_script = "src.cli:main"
Expand Down
File renamed without changes.

0 comments on commit 477be73

Please sign in to comment.