Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not require input value for start_new, call_activity, etc #91

Closed
anthonychu opened this issue Mar 26, 2020 · 3 comments
Closed

Do not require input value for start_new, call_activity, etc #91

anthonychu opened this issue Mar 26, 2020 · 3 comments
Assignees

Comments

@anthonychu
Copy link
Member

Currently, for all client and context functions that take an input, we must pass None if we don't want to pass an input value at all. We should make the input value parameter optional instart_new, call_activity, etc.

For example,

    x = yield context.call_activity("F1", None)

should be

    x = yield context.call_activity("F1")

@davidmrdavid @priyaananthasankar

@davidmrdavid
Copy link
Collaborator

Good observation, I'll take this on

@davidmrdavid
Copy link
Collaborator

@anthonychu

I fixed start_new here: #93
Judging from call_activity's signature, it appears to already work. Below is a snippet showing that we already provide default values, note the i=None from DurableOrchestrationContext.py:

        self.call_activity = lambda n, i=None: call_activity_task(
            state=self.histories,
            name=n,
            input_=i)
        self.call_activity_with_retry = \
            lambda n, o, i=None: call_activity_with_retry_task(
                state=self.histories,
                retry_options=o,
                name=n,

Please let me know what you think

@davidmrdavid
Copy link
Collaborator

Just triple checked, and this (call_activity with no input) already works, provided that the called Activity has a default value.

You can reproduce this yourself by modifying the function_chaining sample as follows:

The new DurableActivity.py:

def main(name: str="Bob") -> str:
    """Activity function performing a specific step in the chain
    
    Parameters
    ----------
    name : str
        Name of the item to be hello'ed at 
    
    Returns
    -------
    str
        Returns a welcome string
    """
    return f'Hello : {name}!'

The new DurableOrchestration:

import logging

import azure.functions as func
import azure.durable_functions as df


def orchestrator_function(context: df.DurableOrchestrationContext):
    """This function provides the core function chaining orchestration logic

    Parameters
    ----------
    context: DurableOrchestrationContext
        This context has the past history
        and the durable orchestration API's to chain a set of functions

    Returns
    -------
    final_result: str
        Returns the final result after the chain completes

    Yields
    -------
    call_activity: str
        Yields at every step of the function chain orchestration logic
    """

    # Chained functions - output of a function is passed as
    # input to the next function in the chain

   # Note, in this case, there's no actual chaining
    final_result = yield context.call_activity("DurableActivity")

    return final_result


main = df.Orchestrator.create(orchestrator_function)

I'll close this issue, for now. Please feel free to re-open it if necessary 😄

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

No branches or pull requests

2 participants