Python DSC Adapter and Test Resource implementation#1520
Draft
shammu1 wants to merge 1 commit intoPowerShell:mainfrom
Draft
Python DSC Adapter and Test Resource implementation#1520shammu1 wants to merge 1 commit intoPowerShell:mainfrom
shammu1 wants to merge 1 commit intoPowerShell:mainfrom
Conversation
Author
|
@microsoft-github-policy-service agree company="Microsoft" |
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.
PR Summary
The Python adapter (Microsoft.DSC.Adapters/Python) enables DSC v3 to dynamically execute Python resource classes. It acts as a bridge between the DSC framework and Python-based resource implementations, handling all DSC operations (get, set, test, export, list, validate).
Key Features
Dynamic Resource Discovery: Reads resource mappings from pyproject.toml under [tool.dsc.resources]
Operation Routing: Routes DSC operations to appropriate Python resource class methods
Structured Logging: Full trace/debug/info/error logging with optional profiling capabilities
State Management: Handles JSON serialization and properly emits state + diffs per DSC specification
Error Handling: Graceful error handling with proper exit codes and stderr logging
Core Components
adapter.py: Main ResourceAdapter class managing operation routing, class loading, and resource discovery
discovery.py: Parses pyproject.toml and dynamically imports resource classes
cli.py: Command-line interface handling arguments and stdin input
dsc_logging.py: Environment variable-based logging configuration
Test Coverage
Three comprehensive test layers:
Unit Tests (Python/unittest) — Tests adapter internals: initialization, manifest discovery, class resolution, operation routing
Component Tests (Pester) — Validates adapter subprocess behavior directly: output shapes, exit codes, error handling
Integration Tests (Pester) — End-to-end DSC CLI integration testing through the full DSC framework
PR Context
DSC already supports adapters for non-native resource ecosystems, and this PR adds a Python adapter so Python-based resources can participate in the same DSC execution model as built-in and PowerShell resources.
This adapter is needed to: