馃毀 Host-free Python environment API - #674
Draft
atifaziz wants to merge 7 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses #378 by proposing a new API for setting up the Python API that does not require a host builder.
It explores alternative APIs that don't require Microsoft's dependency injection hosting framework (
IHost/IHostBuilder). The implementation demonstrates two potential approaches, each treating a different API as the "core" implementation, which requires a team decision on the long-term architecture direction.Key Design Changes
New
PythonEnvironmentConfigurationClass - Immutable Configuration PatternThe centerpiece of this exploration is the new
PythonEnvironmentConfigurationclass (preferred), which uses non-destructive mutation through an immutable builder pattern. This class:ImmutableArray<T>collectionsIServiceProviderfor internal service resolution while maintaining external immutabilityIPythonEnvironmentBuilderfunctionalityTwo Approaches Under Consideration
This PR demonstrates two different approaches for integrating host-free functionality, each building on top of a different API being treated as the "core":
Approach 1: DI-First with
Python.GetEnvironmentHelperThe
Pythonstatic class treats the existing service-based DI infrastructure as the core implementation and provides convenience methods for non-host scenarios:This approach maintains the current service-based architecture as the foundation while offering simplified entry points.
Approach 2: Configuration-First with
AddPythonIntegrationThe new
AddPython(IServiceCollection, PythonEnvironmentConfiguration)extension assumesPythonEnvironmentConfigurationas the core API and adapts it for DI scenarios:This approach treats the immutable configuration as the primary abstraction with DI as an integration layer.
Decision Required
The team needs to decide which approach should serve as the core implementation. Maintaining both approaches long-term would double the maintenance burden for all configuration options, even though one API could theoretically be implemented in terms of the other.
Benefits and Trade-offs
Potential Benefits
Trade-offs and Concerns
Because of these concerns, there should be one core API (preferably
PythonEnvironmentConfiguration) that has a simple bridge for host-based DI scenarios.Pending work:
PythonEnvironmentConfiguration