Skip to content

Enhance python starter template#12215

Merged
davidfowl merged 6 commits into
microsoft:mainfrom
eerhardt:FollowupPythonTemplate
Oct 20, 2025
Merged

Enhance python starter template#12215
davidfowl merged 6 commits into
microsoft:mainfrom
eerhardt:FollowupPythonTemplate

Conversation

@eerhardt

@eerhardt eerhardt commented Oct 20, 2025

Copy link
Copy Markdown
Member
  • Rename api_service to app
  • Add WaitFor for the redis cache
  • Make redis cache optional in the template
  • Fix a 500 error when the static folder doesn't exist. Check if the folder exists before mapping it
  • Add logging to the console as well as to OTLP
  • Remove the uv.lock file. That will be created when uv sync is run

Contributes to #12199

- Rename api_service to app
- Add WaitFor for the redis cache
- Make redis cache optional in the template
- Fix a 500 error when the static folder doesn't exist. Check if the folder exists before mapping it
- Add logging to the console as well as to OTLP
- Remove the uv.lock file. That will be created when uv sync is run
@github-actions

github-actions Bot commented Oct 20, 2025

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12215

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12215"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 Python starter template by making Redis caching optional and improving configuration consistency. The changes rename the API service to "app" for better clarity, add health checks and proper startup dependencies, improve error handling for static file serving, and enable dual logging to both console and OTLP.

Key changes:

  • Redis caching is now optional via a UseRedisCache template parameter
  • Service renamed from apiservice to app for consistency across frontend and backend
  • Added health checks, WaitFor dependencies, and console logging support

Reviewed Changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
frontend/vite.config.ts Updated proxy target to reference renamed app service
apphost.cs Added conditional Redis support, health checks, and WaitFor dependency
app/telemetry.py Added console logging handler alongside OTLP logging
app/pyproject.toml Updated project name and made Redis instrumentation conditional
app/app.py Made Redis client and caching logic conditional, added static folder existence check
.template.config/template.json Added UseRedisCache parameter definition
.template.config/localize/templatestrings.en.json Added localized strings for new parameter
.template.config/ide.host.json Added symbol info for IDE integration
.template.config/dotnetcli.host.json Added CLI mapping for new parameter

Comment thread src/Aspire.ProjectTemplates/templates/aspire-py-starter/13.0/app/pyproject.toml Outdated

@davidfowl davidfowl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works!

@davidfowl davidfowl merged commit b9817e2 into microsoft:main Oct 20, 2025
594 of 597 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the 13.0 milestone Oct 20, 2025
@davidfowl

Copy link
Copy Markdown
Contributor

I deployed the version without redis to appservice and it didn't work. Trying to debug, I'm not sure if it's related though.

@eerhardt

Copy link
Copy Markdown
Member Author

I deployed the version without redis to appservice and it didn't work. Trying to debug, I'm not sure if it's related though.

Did you ever figure this out? It deploys successfully for me. And when I try to hit it, it prints something to the console log:

2025-10-21T07:54:23  Welcome, you are now connected to log-streaming service.
Starting Log Tail -n 10 of existing logs ----
/appsvctmp/volatile/logs/runtime/sitecontainers/main/container.log 
Ending Log Tail of existing logs ---
Starting Live Log Stream ---
2025-10-21T07:54:26 
2025-10-21T07:54:26    FastAPI   Starting production server 🚀
2025-10-21T07:54:26  
2025-10-21T07:54:26              Searching for package file structure from directories with         
2025-10-21T07:54:26              __init__.py files                                                  
2025-10-21T07:54:26              Importing from /app
2025-10-21T07:54:26  
2025-10-21T07:54:26     module   🐍 app.py
2025-10-21T07:54:26  
2025-10-21T07:54:26       code   Importing the FastAPI app object from the module with the following
2025-10-21T07:54:26              code:                                                              
2025-10-21T07:54:26  
2025-10-21T07:54:26              from app import app
2025-10-21T07:54:26  
2025-10-21T07:54:26        app   Using import string: app:app
2025-10-21T07:54:26  
2025-10-21T07:54:26     server   Server started at http://0.0.0.0:8000/
2025-10-21T07:54:26     server   Documentation at http://0.0.0.0:8000/docs
2025-10-21T07:54:26  
2025-10-21T07:54:26              Logs:
2025-10-21T07:54:26  
2025-10-21T07:54:26       INFO   Started server process [1]
2025-10-21T07:54:26       INFO   Waiting for application startup.
2025-10-21T07:54:26       INFO   Application startup complete.
2025-10-21T07:54:26 INFO:uvicorn.error:Application startup complete.
2025-10-21T07:54:26       INFO   Uvicorn running on http://0.0.0.0:8000/ (Press CTRL+C to quit)
2025-10-21T07:54:26 INFO:uvicorn.error:Uvicorn running on http://0.0.0.0:8000/ (Press CTRL+C to quit)

But the page never gets served.

@eerhardt eerhardt deleted the FollowupPythonTemplate branch October 21, 2025 12:56
@davidfowl

Copy link
Copy Markdown
Contributor

Yes @ShilpiR is looking into it. This PR #12088 was supposed to fix it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants