Skip to content
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: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ repos:
hooks:
- id: local-ty
name: ty check
entry: uv run ty check template tests
entry: uv run ty check python_template tests
require_serial: true
language: unsupported
pass_filenames: false
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ ENV PATH="/app/.venv/bin:$PATH"
WORKDIR /app

# Run the FastAPI application by default
CMD ["uvicorn", "template.api:app", "--host", "0.0.0.0", "--port", "80", "--log-config", "log_conf.yaml"]
CMD ["uvicorn", "python_template.api:app", "--host", "0.0.0.0", "--port", "80", "--log-config", "log_conf.yaml"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ruff:
$(RUN) ruff check --fix --show-fixes .

ty:
$(RUN) ty check template tests
$(RUN) ty check python_template tests

test:
$(RUN) pytest
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<!-- markdownlint-disable MD059 -->

# Template
# Python template

![testing workflow](https://github.com/Komorebi-AI/python-template/actions/workflows/pytest.yml/badge.svg)
[![prek](https://img.shields.io/badge/prek-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/j178/prek)

Librería Python de ejemplo
Aplicación Python de ejemplo

## Structure

The repository is structured into the following directories:

- `/template`: Python source code
- `/python_template`: Python source code
- `/tests`: Python code for testing via pytest
- `/data`: data folder

Expand Down Expand Up @@ -47,7 +47,7 @@ Install package and pinned dependencies with the [`uv`](https://docs.astral.sh/u
4. Run any command or Python script with `uv run`, for instance:

```bash
uv run template
uv run python_template/main.py
```

Alternatively, you can also activate the virtual env and run the scripts normally:
Expand Down Expand Up @@ -120,6 +120,12 @@ make hooks
make ruff
```

#### Run type checker

```bash
make ty
```

#### Run tests

```bash
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"

[project]
requires-python = ">=3.14,<3.15"
name = "template"
name = "python_template"
# La versión se obtiene automáticamente de git con `setuptools_scm`
#version = "0.1.0"
description = "Librería Python de ejemplo"
description = "Aplicación Python de ejemplo"
readme = "README.md"
authors = [{ name = "Komorebi AI", email = "info@komorebi.ai" }]
dynamic = ["version"]
Expand All @@ -23,11 +23,11 @@ dependencies = [
homepage = "https://github.com/Komorebi-AI/python-template"

[project.scripts]
template = "template.main:main"
python_template = "python_template.main:main"


[tool.setuptools]
packages = ["template"]
packages = ["python_template"]

[tool.setuptools_scm]
# Importante crear esta sección vacia para activar el plugin
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions template/api.py → python_template/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from fastapi import FastAPI
from pydantic import BaseModel

from template.main import __version__
from python_template.main import __version__

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -37,7 +37,7 @@ def read_root() -> dict[str, str]:
logger.error("ERROR")
logger.critical("CRITICAL")

return {"template-api": f"version {__version__}"}
return {"python_template-api": f"version {__version__}"}


@app.post("/predict")
Expand All @@ -54,7 +54,7 @@ def predict(request: Request) -> Response:
port = 7000 if len(sys.argv) < 2 else int(sys.argv[1])
host = "127.0.0.1" if len(sys.argv) < 3 else sys.argv[2]
uvicorn.run(
"template.api:app",
"python_template.api:app",
host=host,
port=port,
reload=True,
Expand Down
4 changes: 2 additions & 2 deletions template/main.py → python_template/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import typer

try:
__version__: str | None = version("template")
__version__: str | None = version("python_template")
except PackageNotFoundError:
# package is not installed
__version__ = None
Expand All @@ -16,7 +16,7 @@

def print_version() -> None:
"""Print package version."""
print(f"Template version {__version__}")
print(f"Python template version {__version__}")


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_trivial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from template.main import print_version
from python_template.main import print_version


def test_print_version():
Expand Down
154 changes: 77 additions & 77 deletions uv.lock

Large diffs are not rendered by default.

Loading