FizzyLogic.Aspire.Python.Hosting 0.1.0-preview-1

This is a prerelease version of FizzyLogic.Aspire.Python.Hosting.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package FizzyLogic.Aspire.Python.Hosting --version 0.1.0-preview-1                
NuGet\Install-Package FizzyLogic.Aspire.Python.Hosting -Version 0.1.0-preview-1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FizzyLogic.Aspire.Python.Hosting" Version="0.1.0-preview-1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FizzyLogic.Aspire.Python.Hosting --version 0.1.0-preview-1                
#r "nuget: FizzyLogic.Aspire.Python.Hosting, 0.1.0-preview-1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FizzyLogic.Aspire.Python.Hosting as a Cake Addin
#addin nuget:?package=FizzyLogic.Aspire.Python.Hosting&version=0.1.0-preview-1&prerelease

// Install FizzyLogic.Aspire.Python.Hosting as a Cake Tool
#tool nuget:?package=FizzyLogic.Aspire.Python.Hosting&version=0.1.0-preview-1&prerelease                

Aspire hosting extensions for Python projects

.NET Aspire already has great support for orchestrating C# projects and a fast array of middleware components. This project adds additional support for running Python projects as smooth as C# projects.

System requirements

  • Python
  • .NET SDK 8 or higher

Getting started

Before using this extension you should know how to set up an Aspire project. There's an excellent guide in the documentation.

Once you've set up a basic Aspire project, follow the instructions below to get started.

Important assumptions

These extensions make a few assumptions about your project:

  • You have a virtual environment in the .venv directory in your Python project.
  • You have a Dockerfile in the root directory of your Python project.

Note: I haven't added support for Anaconda because I don't use it myself. Feel free to open a PR to add support for Anaconda.

Setting up orchestration for a Python project

using FizzyLogic.Aspire.Python.Hosting;

var builder = DistributedApplication.CreateBuilder(args);

builder.AddPythonProjectWithVirtualEnvironment("batch", "apps/batch");

builder.Build().Run();

The line builder.AddProjectWithVirtualEnvironment adds a new component to the orchestrator with the name batch located in apps/batch.

Documentation

Support for tracing, metrics, and logging

The extension automatically detects that you have the opentelemetry-distro package available in your project's virtual environment. When you have the opentelemetry distro package your application is automatically instrumented. The traces, logs, and metrics in your app are collected in the dashboard.

Depending on what you're building you'll likely need a few instrumentation libraries. There are a bunch available on pypi.

The most commonly used are:

To use these libraries you can install them in your virtual environment, and the instrumentation logic will pick them up without any extra configuration.

Support for clients

Since there are a lot of components in Aspire, it will take time to get support for them in Python. I will update this page as I start work on them.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0-preview-2.12 551 5/9/2024
0.1.0-preview-2.11 64 5/9/2024
0.1.0-preview-2.6 68 5/9/2024
0.1.0-preview-1 61 5/8/2024