Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade #15

Merged
merged 16 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
# This should make it easy to add new rules without breaking existing ones.

# Global rule:
<!-- Replace with your GitHub username -->
* @aniketmaurya

# tests
<!-- Replace with your GitHub username -->
/tests/** @aniketmaurya
28 changes: 0 additions & 28 deletions .github/workflows/latest-changes.yml.off

This file was deleted.

12 changes: 4 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
python-version: [3.8, 3.9]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- os: ubuntu-latest
path: ~/.cache/pip
- os: macos-latest
path: ~/Library/Caches/pip
env:
OS: ${{ matrix.os }}
PYTHON: '3.9'
PYTHON: ${{ matrix.python-version }}


steps:
Expand All @@ -47,15 +47,11 @@ jobs:
python --version
pip --version
python -m pip install --upgrade pip
pip install coverage pytest
pip install .
pip install coverage pytest pytest-cov
pip install ".[dev]"
pip list
shell: bash

- name: Prepare Test
run: |
python tests # download test data

- name: Run Test with Coverage
run: |
coverage erase
Expand Down
28 changes: 0 additions & 28 deletions .pep8speaks.yml

This file was deleted.

9 changes: 1 addition & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,8 @@ repos:
# https://prettier.io/docs/en/options.html#print-width
args: ["--print-width=120"]

- repo: https://github.com/PyCQA/docformatter
rev: 06907d0267368b49b9180eed423fae5697c1e909 # todo: fix for docformatter after last 1.7.5
hooks:
- id: docformatter
additional_dependencies: [tomli]
args: ["--in-place"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
rev: v0.8.1
hooks:
- id: ruff-format
args: ["--preview"]
Expand Down
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ARG PYTHON_VERSION=3.12
FROM python:$PYTHON_VERSION-slim

####### Add your own installation commands here #######
# RUN pip install some-package
# RUN wget https://path/to/some/data/or/weights
# RUN apt-get update && apt-get install -y <package-name>

WORKDIR /app
COPY . /app

# Install litserve and requirements
RUN pip install --no-cache-dir litserve==0.2.5
EXPOSE 8000
CMD ["python", "/app/src/python_project_template/server.py"]
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) 2021-2023 Aniket Maurya
Copyright (c) 2021-2025 Aniket Maurya

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
11 changes: 3 additions & 8 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ recursive-exclude __pycache__ *.py[cod] *.orig

# Include the README and CHANGELOG
include *.md
recursive-include assets *.png

exclude app.py
exclude .lightning
exclude .lightningignore
recursive-include src *.md

# Include the license file
include LICENSE
Expand All @@ -31,14 +27,13 @@ recursive-exclude docs *
exclude docs

# Include the Requirements
include src/requirements.txt
recursive-include src/requirements *.txt
include requirements.txt
recursive-include _requirements *.tx;t

# Exclude Makefile
exclude Makefile

prune .git
prune .github
prune scripts
prune temp*
prune test*
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ build-docs:
cp README.md docs/index.md

docsserve:
mkdocs serve --dirtyreload --livereload
uv run mkdocs serve

test:
python tests/__init__.py
pytest

coverage: ## Run tests with coverage
coverage erase
coverage run -m pytest
coverage report -m
coverage xml
coverage erase
coverage run -m pytest
coverage report -m
coverage xml

clean:
rm -rf dist
Expand All @@ -23,8 +22,8 @@ clean:
rm -f .coverage

style:
black .
isort --profile black .
ruff format .

push:
git push && git push --tags
Expand Down
125 changes: 104 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,123 @@
# Python Project Template 🐍
<div align="center">
<h1>Python Project Template 🐍</h1>
<!-- A brief description of what this project does and who it's for -->
<p>A template to kick-start your open-source Python project.</p>
</div>

<p align="center">
<a href="https://github.com/aniketmaurya/python-project-template/actions/workflows/main.yml">
<img src="https://github.com/aniketmaurya/python-project-template/actions/workflows/main.yml/badge.svg" alt="Tests">
</a>
<a href="https://codecov.io/gh/aniketmaurya/python-project-template">
<img src="https://codecov.io/gh/aniketmaurya/python-project-template/branch/main/graph/badge.svg" alt="codecov">
</a>
<a href="https://github.com/psf/black">
<img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="black">
</a>
<a href="https://github.com/aniketmaurya/python-project-template/blob/main/LICENSE">
<img src="https://img.shields.io/github/license/aniketmaurya/python-project-template.svg" alt="license">
</a>
</p>


<p align="center">
<a href="https://github.com/codespaces/badge.svg)](https://codespaces.new/aniketmaurya/python-project-template?template=false">
<img src="https://github.com/codespaces/badge.svg" alt="Open in GitHub Codespaces">
</a>
</p>



# Installation

## From Source
```bash
git clone https://github.com/aniketmaurya/python-project-template.git
cd python-project-template
pip install .
```

<!-- A brief description of what this project does and who it's for -->
A template to kick-start your open-source Python project.
## Development Installation
```bash
git clone https://github.com/aniketmaurya/python-project-template.git
cd python-project-template
pip install -e ".[dev]"
```

# Usage

## Installation
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/aniketmaurya/python-project-template?template=false)
```python
from python_project_template import do_something_awesome

Install the [Template Project] with pip
print(do_something_awesome())
```

# Features

- 🚀 Modern Python project structure
- 📦 Pre-configured setup.py and pyproject.toml
- 🧪 Testing setup with pytest
- 👷 CI/CD with GitHub Actions
- 📝 Auto-generated documentation
- 🎯 Type hints and static type checking
- 🔍 Code formatting with black and isort
- 🐛 Linting with flake8

# Project Structure

```bash
git clone https://github.com/aniketmaurya/python-project-template.git
cd python-project-template
pip install .
```
python-project-template/
├── .github/
│ └── workflows/ # GitHub Actions workflows
├── docs/ # Documentation
├── src/ # Source code
│ └── python_project_template/
├── tests/ # Test files
├── .gitignore
├── LICENSE
├── README.md
├── pyproject.toml # Project metadata and dependencies
└── setup.py # Package installation
```

## Usage/Examples
# Development

```python
from template_project import do_something_awesome
1. Clone the repository
```bash
git clone https://github.com/aniketmaurya/python-project-template.git
cd python-project-template
```

print(do_something_awesome())
2. Create a virtual environment
```bash
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
```

3. Install development dependencies
```bash
pip install -e ".[dev]"
```

<!-- ## Demo
## Running Tests

Insert gif or link to demo -->
```bash
pytest tests/
```

## Contributing

<!-- ## FAQ
Contributions are always welcome! Here's how you can help:

#### Question 1
1. Fork the repository
2. Create a new branch (`git checkout -b feature/amazing-feature`)
3. Make your changes
4. Commit your changes (`git commit -m 'Add some amazing feature'`)
5. Push to the branch (`git push origin feature/amazing-feature`)
6. Open a Pull Request

Answer 1
Please make sure to update tests as appropriate and follow the existing coding style.

#### Question 2
# License

Answer 2 -->
[MIT](https://choosealicense.com/licenses/mit/) - Feel free to use this template for your projects!
5 changes: 5 additions & 0 deletions client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Sample client to test the server
import requests

response = requests.post("http://127.0.0.1:8000/predict", json={"input": 4.0})
print(f"Status: {response.status_code}\nResponse:\n {response.text}")
4 changes: 0 additions & 4 deletions docs/CHANGELOG.md

This file was deleted.

Loading
Loading