feat(python): workflow context propagation quickstart#1309
Open
nelson-parente wants to merge 3 commits into
Open
feat(python): workflow context propagation quickstart#1309nelson-parente wants to merge 3 commits into
nelson-parente wants to merge 3 commits into
Conversation
Ports Cassie Coyle's Go-SDK reference example (dapr/go-sdk#823) to Python. Demonstrates PropagationScope.LINEAGE and PropagationScope.OWN_HISTORY in a fraud-detection payment scenario with a 3-level workflow hierarchy. Requires Dapr 1.18+ (dapr/dapr#9810) and dapr-ext-workflow 1.18+ (dapr/python-sdk#1025). Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
7 tasks
Aligns the Python workflow history propagation quickstart with the canonical Go reference (dapr/go-sdk#823, dapr#1315) so all SDK quickstarts share the same patient intake / e-prescribing scenario. - Swap credit-card/fraud scenario for patient-intake/e-prescribing - Adopt PatientIntake -> PrescribeMedication -> ComplianceAudit hierarchy - Add is_replaying guards around all print() calls inside workflows - Use Cassie's PascalCase activity/workflow names for cross-SDK consistency Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
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.
Summary
Scenario
Patient intake / e-prescribing pipeline. A compliance audit and a pharmacy dispense step refuse to act unless the propagated history proves the required upstream checks (insurance, allergies, drug interactions) actually ran.
ComplianceAuditusesLINEAGEto verify the full ancestor chain.DispenseMedicationusesOWN_HISTORYas a trust boundary — the pharmacy step doesn't get to see the upstream patient-intake chain.Python API used (from dapr/python-sdk#1025)
PropagationScope.LINEAGE/PropagationScope.OWN_HISTORYpropagation=kwarg onctx.call_child_workflow()andctx.call_activity()ctx.get_propagated_history()→PropagatedHistory | NonePropagatedHistory.get_workflow_by_name(name)→WorkflowResultWorkflowResult.get_activity_by_name(name)→ActivityResult(with.completed,.output)PropagationNotFoundErrorReplay safety
All
print()calls inside workflows are guarded byif not ctx.is_replaying:so they only fire on the live execution, not on each durable replay.Status — DRAFT
Pending before marking ready:
dapr-ext-workflow==1.18.0rc0is availablectx.is_replayingis exposed as a property (not a method) in the Python SDKdapr.yamlresourcesPath: ../../componentsresolves correctlyTest plan
pip3 install -r requirements.txtwithdapr-ext-workflow>=1.18.0rc0availabledapr run -f .against Dapr 1.18 RC sidecarLINEAGE(sees both PatientIntake + PrescribeMedication)PrescribeMedicationevents viaOWN_HISTORYNonefromget_propagated_history()without crashReferences