Skip to content

Add application skeletons to further simplify project startup #4

Merged
irod973 merged 11 commits intomainfrom
feature/torch-template
Jan 10, 2026
Merged

Add application skeletons to further simplify project startup #4
irod973 merged 11 commits intomainfrom
feature/torch-template

Conversation

@irod973
Copy link
Owner

@irod973 irod973 commented Dec 7, 2025

Overview

This adds various application skeletons to provide a better experience for project setup in different cases.

This cookiecutter template was originally written for publishing a Python package which forces template clients to regularly tweak the template for different Python applications. For example, a FastAPI application would have different dependencies a different Docker entrypoint, possibly different CICD than the original Python package case.

Similarly, projects like a Torch application have more specific dependency configurations.

Testing

Setup a template and invoke the given docker-compose commands. I haven't thought about automating these yet.

# Clone the template
git clone https://github.com/irod973/python-project-template.git

# Use cookiecutter - if cookiecutter is not installed, follow the root README instructions
# Add all the starter application skeletons when prompted (FastAPI, Torchvision, Metaflow)
cookiecutter python-project-template

FastAPI: uv run just docker-compose-service fastapi_app

testproject-fastapi_app-1  | 
testproject-fastapi_app-1  | 
testproject-fastapi_app-1  |    FastAPI   Starting development server 🚀
testproject-fastapi_app-1  |  
testproject-fastapi_app-1  |              Searching for package file structure from directories with         
testproject-fastapi_app-1  |              __init__.py files                                                  
testproject-fastapi_app-1  |              Importing from /app
testproject-fastapi_app-1  |  
testproject-fastapi_app-1  |     module   📁 fastapi_app    
testproject-fastapi_app-1  |              ├── 🐍 __init__.py
testproject-fastapi_app-1  |              └── 🐍 main.py    
testproject-fastapi_app-1  |  
testproject-fastapi_app-1  |       code   Importing the FastAPI app object from the module with the following
testproject-fastapi_app-1  |              code:                                                              
testproject-fastapi_app-1  |  
testproject-fastapi_app-1  |              from fastapi_app.main import app
testproject-fastapi_app-1  |  
testproject-fastapi_app-1  |        app   Using import string: fastapi_app.main:app
testproject-fastapi_app-1  |  
testproject-fastapi_app-1  |     server   Server started at http://0.0.0.0:8000
testproject-fastapi_app-1  |     server   Documentation at http://0.0.0.0:8000/docs
testproject-fastapi_app-1  |  
testproject-fastapi_app-1  |        tip   Running in development mode, for production use: fastapi run
testproject-fastapi_app-1  |  
testproject-fastapi_app-1  |              Logs:
testproject-fastapi_app-1  |  
testproject-fastapi_app-1  |       INFO   Will watch for changes in these directories: ['/app']
testproject-fastapi_app-1  |       INFO   Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
testproject-fastapi_app-1  |       INFO   Started reloader process [1] using WatchFiles
testproject-fastapi_app-1  |       INFO   Started server process [8]
testproject-fastapi_app-1  |       INFO   Waiting for application startup.
testproject-fastapi_app-1  |       INFO   Application startup complete.

Torch: uv run just docker-compose-service torchvision_app

testproject-torchvision_app-1  | 2025-12-07 07:25:09.325 | INFO     | __main__:main:11 - type(img)=<class 'torch.Tensor'>, img.dtype=torch.uint8, img.shape=torch.Size([3, 512, 512])
testproject-torchvision_app-1  | 2025-12-07 07:25:09.333 | INFO     | __main__:main:19 - type(out)=<class 'torch.Tensor'>, out.dtype=torch.float32, out.shape=torch.Size([3, 224, 224])
testproject-torchvision_app-1 exited with code 0

Metaflow: uv run just docker-compose-service metaflow_app
This one gives an error specific to Metaflow.
[] TODO: explore resolving this (check Metaflow docs for any Docker guidance)

Attaching to testproject-metaflow_app-1
testproject-metaflow_app-1  | Metaflow 2.19.13 executing SpinPrototypeFlow    Unknown user:
testproject-metaflow_app-1  |     Metaflow could not determine your user name based on environment variables ($USERNAME etc.)
testproject-metaflow_app-1  | 
testproject-metaflow_app-1  | 
testproject-metaflow_app-1 exited with code 1

@irod973 irod973 self-assigned this Dec 7, 2025
@irod973 irod973 requested a review from Copilot December 7, 2025 07:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the cookiecutter template by adding application skeletons (FastAPI, Torchvision, Metaflow) to simplify project setup for different Python application types beyond the original package-publishing use case.

  • Adds optional application skeletons with specific dependency configurations
  • Introduces Docker multi-stage builds for more efficient containerization
  • Updates build commands and documentation to support multiple application types

Reviewed changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
{{cookiecutter.repository}}/tasks/docker.just Updates docker build to use new Dockerfile path and modifies docker-compose command to accept service parameter
{{cookiecutter.repository}}/src/torchvision_app/torchvision_example.py Adds example torchvision application with image transformation pipeline
{{cookiecutter.repository}}/pyproject.toml Adds loguru to core dependencies, configures optional dependencies for FastAPI/Metaflow/Torchvision, and fixes typo in Repository URL
{{cookiecutter.repository}}/docker/Dockerfile.python Introduces new multi-stage Dockerfile for building Python applications without uv in final image
{{cookiecutter.repository}}/docker-compose.yml Restructures services with dedicated build configurations and volume mounts for each application type
{{cookiecutter.repository}}/README.md Updates usage documentation with application-specific instructions and conditionally shows publish badge
{{cookiecutter.repository}}/Dockerfile Removes old Dockerfile in favor of new docker/Dockerfile.python
hooks/post_gen_project.py Adds type hints, refactors to use double quotes consistently, adds torchvision cleanup logic
cookiecutter.json Adds include_torchvision option and improves description placeholder
README.md Updates documentation to describe new application skeletons and removes outdated content

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


# SYSTEMS

# TODO: is this only for the package management?
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO comment should be resolved or removed. The [build-system] section defines the build backend (hatchling) used by pip/uv to build the package, not just for package management but for the build process itself.

Suggested change
# TODO: is this only for the package management?

Copilot uses AI. Check for mistakes.
@irod973 irod973 requested a review from Copilot December 7, 2025 17:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 16 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +160 to +161
requires = ["uv_build>=0.9.16,<0.10.0"]
build-backend = "uv_build"
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build backend should be 'uv' not 'uv_build'. The uv package provides its own build backend starting from version 0.5.0.

Suggested change
requires = ["uv_build>=0.9.16,<0.10.0"]
build-backend = "uv_build"
requires = ["uv>=0.5.0"]
build-backend = "uv"

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you cite where this info is coming from? The uv docs don't show this
https://docs.astral.sh/uv/concepts/build-backend/#namespace-packages

Using the uv build backend
To use uv as a build backend in an existing project, add uv_build to the [build-system] section in your pyproject.toml:

[build-system]
requires = ["uv_build>=0.9.16,<0.10.0"]
build-backend = "uv_build"

@@ -31,11 +31,12 @@ def test_project_generation(cookies: Cookies) -> None:
"license": "Apache-2.0", # Note: needs to be a "valid SPDX identifier"
"version": "1.0.0",
"description": "A test project.",
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The Python version was changed from 3.13 to 3.12 in tests, but this change is undocumented in the PR description. If this is intentional due to compatibility issues with the new dependencies (torch, etc.), consider adding a comment explaining why 3.13 is not used for testing.

Suggested change
"description": "A test project.",
"description": "A test project.",
# Python 3.12 is used instead of 3.13 due to compatibility issues with some dependencies (e.g., torch).

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignoring, this is simply standardizing on Python 3.12

Copy link
Owner Author

@irod973 irod973 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completed self-review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@irod973 irod973 merged commit 613f72e into main Jan 10, 2026
1 check passed
@irod973 irod973 deleted the feature/torch-template branch January 10, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant