-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
Support positional stream args in DynamicMap callback #4534
Conversation
to accept stream values as positional arg dictionaries in DynamicMap callbacks.
The changes look fine to me, but I'll try to fix the tests before merging. |
Ok, updated with master and tests are passing. Anything else come to mind for this PR @philippjfr? |
@philippjfr alright if we merge this today? |
Yes, looks good to me. |
Thanks a lot @philippjfr! |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR is a step toward supporting #4433 using a
DynamicMap
transformation. The idea is described in #4433 (comment).Background
The callback function for a
DynamicMap
is currently called by passing the kdim values as positional arguments, followed by stream parameter values as keyword arguments. For example:Here the
i_value
argument is thei
key dimension that is called positionally (namedi_value
to emphasize that it's called by position not by name), and thex
andy
arguments are the stream parameters and they are called as keyword arguments. So here thex
andy
argument names must match the param names of thexy_stream
stream.This approach is convenient when writing callback functions by hand, when there are only a few stream parameters and the stream parameter names don't conflict. But it's less convenience when building a callback function programmatically that will input many streams with potentially overlapping parameter names. This will be the situation when building the transformation in #4433.
Description
This PR adds a
positional_stream_args
parameter to theDynamicMap
class that, when set toTrue
, will configure theDynamicMap
to pass stream values to the callback function positionally. The stream arguments will follow the kdim arguments (if any), the value of each stream argument is adict
containing key-value pairs for each param in the stream, and the order of the stream arguments is determined by the order of the streams in thestreams
parameter list.Here's an example of what this looks like:
When
positional_stream_args=True
there is no possibility of stream parameter name clashes.Of course, the default is
False
to match the current behavior.Does this sound reasonable @jlstevens @philippjfr ?