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

Fixed no memoization bug if stream provides no kwargs #3070

Merged
merged 4 commits into from Oct 10, 2018

Conversation

philippjfr
Copy link
Member

Our recent work on supporting param.depends allows defining DynamicMaps which do not have any args or kwargs, since the parameters are available on the self in the parameterized method callback. However there is a small bug in Callable which skips memoization if both args and kwargs are empty rather than checking the kwarg_hash which is what is actually memoized on.

@philippjfr philippjfr added the type: bug Something isn't correct or isn't working label Oct 10, 2018
@philippjfr
Copy link
Member Author

Ready to review and merge.

@@ -542,7 +542,7 @@ def __call__(self, *args, **kwargs):
# Nothing to do for callbacks that accept no arguments
kwarg_hash = kwargs.pop('memoization_hash', ())
Copy link
Contributor

@jlstevens jlstevens Oct 10, 2018

Choose a reason for hiding this comment

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

How come the hash is passed in via the kwargs? Does that mean that if a user tries to use a stream with the parameter 'memoization_hash', it will not work as expected?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I suppose the Callable gets it, but at least the callback does not. Even so, it means Callable has kwargs that won't be passed to the callback (if supplied by the user).

Copy link
Member Author

Choose a reason for hiding this comment

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

How come the hash is passed in via the kwargs? Does that mean that if a user tries to use a stream with the parameter 'memoization_hash', it will not work as expected?

It's the only way we have of letting streams define hash keys to the Callable that are not simply the same as the contents and has been that way for a while. It is true that if a user stream has a parameter called memoization_hash then that won't work properly. Seems like a highly unlikely clash but if you don't think it's safe I'd be happy to add an underscore or something.

Even so, it means Callable has kwargs that won't be passed to the callback (if supplied by the user).

Don't quite follow this, when or why would a user call the Callable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't quite follow this, when or why would a user call the Callable

I don't expect this to be a common case, but ideally the Callable is a relatively transparent wrapper around the callback. This isn't a blocker for this PR though...

@jlstevens
Copy link
Contributor

jlstevens commented Oct 10, 2018

Looks good with the updated kwarg name. Merging.

@jlstevens jlstevens merged commit af065b7 into master Oct 10, 2018
philippjfr added a commit that referenced this pull request Oct 25, 2018
# Conflicts:
#	holoviews/tests/teststreams.py
@philippjfr philippjfr deleted the no_kwarg_memoize branch November 12, 2018 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants