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

ProcessFunction: Add support for variadic arguments #5691

Commits on Dec 14, 2022

  1. ProcessFunction: Add support for variadic arguments

    Up till now, variadic arguments, i.e., arguments defined as `*args` in a
    function signature which collects any remaining positional arguments,
    were not supported for process functions. The main reason was that it
    wasn't immediately clear what the link label should be for these inputs.
    
    For normal positional arguments we can take the name of the argument
    declaration in the function signature, and for keyword arguments we take
    the keyword with which the argument is passed in the function invocation.
    But for variadic arguments there is no specific argument name, not in
    the function signature, nor in the function invocation. However, we can
    simply create a link label. We just have to ensure that it doesn't clash
    with the link labels that will be generated for the positional and
    keyword arguments.
    
    Here the link label will be determined with the following format:
    
        `{label_prefix}_{index}`
    
    The `label_prefix` is determined the name of the variadic argument. If a
    function is declared as `function(a, *args, **kwargs)` the prefix will
    be equal to `args` and if it is `function(*some_var_args)` it will be
    `some_var_args`. The index will simply be the zero-base index of the
    argument within the variadic arguments tuple. This would therefore give
    link labels `args_0`, `args_1` etc. in the first example.
    
    If there would be a clash of labels, for example with the function def:
    
        def function(args_0, *args):
    
    which when invoked as:
    
        function(1, *(2, 3))
    
    would generate the labels `args_0` for the first positional argument,
    but also `args_0` for the first variadic argument. This clash is
    detected and a `RuntimeError` is raised instructing the user to fix it.
    sphuber committed Dec 14, 2022
    Configuration menu
    Copy the full SHA
    36118c8 View commit details
    Browse the repository at this point in the history