Skip to content

Conversation

@Hazhzeng
Copy link
Contributor

@Hazhzeng Hazhzeng commented Feb 21, 2020

Background

To support durable function running in Python Worker, we should create a rich binding for OrchestrationTrigger

Features

  1. Added an OrchestrationContext type for accepting orchestrate context
  2. Allow user code to use orchestration_context.body to access the orchestration data
  3. Set has_implicit_output=True for OrchestrationTrigger to enable context return even when $return is not defined in function.json

Usage

// function.json
{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "orctx",  //context is a reserved keyword in azure functions Python, we use context to pass the function_name and invocation_id to our customers
      "type": "orchestrationTrigger",
      "direction": "in"
      // remove datatype here
    }
  ],
  "disabled": false
}
# main.py
import azure.functions as func

def main(orctx: func.OrchestrationContext):
# or
# def main(orctx):
    orchestrate = df.Orchestrator.create(generator_function)
    result = orchestrate(orctx.body)  # need to add .body
    return result

Copy link
Member

@scgbear scgbear left a comment

Choose a reason for hiding this comment

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

The changes look good. Curious if these will also fix the issues we're seeing with the call_activity_with_retry

@Hazhzeng
Copy link
Contributor Author

Hey @scgbear,

This PR works fine with fan-in-fan-out and function-chain.
However, when it uses call_activity_with_retry("ParrotValue", retry_options, i) it always passes a None value to the activity function.

@asedighi and I found out the variable name input does not match to its attribute name self.input_ in the following line https://github.com/Azure/azure-functions-durable-python/blob/7df1ef752b591dbd357f39d813515394796c3104/azure/durable_functions/models/actions/CallActivityWithRetryAction.py#L33

PR containing the fix is here https://github.com/Azure/azure-functions-durable-python/pull/57/files#diff-f44dfb86028dc2811e9365c215fe8e2cR33

@Hazhzeng Hazhzeng merged commit d154419 into dev Feb 25, 2020
@vrdmr vrdmr deleted the hazeng/durable branch May 4, 2020 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants