-
-
Notifications
You must be signed in to change notification settings - Fork 531
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
Add ParamRef baseclass for ParamFunction and ParamMethod #6392
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6392 +/- ##
===========================================
+ Coverage 39.59% 83.63% +44.04%
===========================================
Files 305 305
Lines 45650 45682 +32
===========================================
+ Hits 18075 38207 +20132
+ Misses 27575 7475 -20100
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will merge, if anyone doesn't like the name please chime in soon so it can be renamed before an RC.
There's likely some follow up work on |
The class hierarchy for ParamFunction and ParamMethod has been quite confusing since their inception. Specifically
ParamMethod
was a subclass ofParamFunction
, which conceptually makes no sense. Additionally, since we added generalized support and the concept of non-function references, there was no component in Panel that could take a generic reference and resolve it. Therefore we introduce the newParamRef
component in the class hierarchy, which forms a base class for bothParamMethod
andParamFunction
. Not only is this organization now conceptually correct, but it also patches a hole in the Panel API which is to provide a component that can simply render the current value of a reference such as a parameter, widget, or reactive expression. UnlikeParamFunction
,ParamRef
will not have any display priority, i.e. a parameter will still be rendered using theParam
pane, i.e. as a widget, but if e.g. we want to display the output of a widget or reactive expression theParamRef
pane comes in helpful.Let's see an example:
Here the
backend
widget allows selecting between a few values while theParamRef
pane can be used to resolve and render the currently selected component.Alternatives
Currently there are some alternatives to this new API but they are either not general enough or cumbersome to use.
1. Reference binding
One alternative is passing the reference to some other pane to resolve, e.g. this works well if the type of the object is well defined, e.g.:
Here the
DataFrame
pane will resolve the value and correctly and efficiently update the output but in our example above there is no pane that can renderVega
,HoloViews
etc. types.2. Layout reference binding
In the case where the return value is a list of components we can once again use reference binding to render multiple objects, e.g.:
3. Reactive Expression pane
Lastly we do have the option of rendering the component as a reactive expression using the existing
ReactiveExpr
pane. This works but requires a few workarounds for the simpler cases, e.g. to render the value of a select widget we have to call.rx()
to turn our valid reference into a reactive expression and we also then have to disable rendering of the widgets:Future work
As I finish writing #6289 and the remaining tutorials mentioned in #6390 I will also finally try to work out how to correctly document this important, but as of yet under-explained portion of the Panel API.