-
-
Notifications
You must be signed in to change notification settings - Fork 526
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
Panel 1.3.0: ReactiveHTML with custom param.Parameter broken. #5730
Comments
Can you report the param version? |
@philippjfr : Looks like something is pulling in a release candidate rather than a stable release:
I'll check to see which version is being pulled in under Panel 1.2.3. I just rebuilt my virtual environment a little while ago, so it's possible that another package is pulling in this dependency. |
Thanks, I can also reproduce. |
We should definitely fix this but you really shouldn't set a parameter value before calling super, i.e. this would be preferred: from panel.reactive import ReactiveHTML
from param import Parameter
class Kaboom( ReactiveHTML ):
foo = Parameter( )
def __init__( self, **params ):
params['foo'] = 1
super( ).__init__( **params ) |
Thankfully we haven't quite released Param 2.0 yet (you raised this just in time), so we can get a fix in before the release. |
Ah, okay. I was not aware of that preference/limitation. Moving the super invocation to the top of the initializer does indeed provide a workaround. Feels a bit Python-non-intuitive that the behavior of setting an attribute on an object would be linked to superclass initialization. Thanks for the quick response. |
For reference, there's a Param issue about deprecating this usage holoviz/param#815.
Agreeing with you, Param can do better there. |
@philippjfr the alternative to holoviz/param#876 is apply this change and release Panel 2.0.1. I assume you prefer patching Param before I release it today? diff --git a/panel/reactive.py b/panel/reactive.py
index 83f3017ed..f1705b811 100644
--- a/panel/reactive.py
+++ b/panel/reactive.py
@@ -542,7 +542,7 @@ class Reactive(Syncable, Viewable):
def __init__(self, refs=None, **params):
for name, pobj in self.param.objects('existing').items():
- if name not in self._param__private.explicit_no_refs:
+ if name not in type(self)._param__private.explicit_no_refs:
pobj.allow_refs = True
if refs is not None:
self._refs = refs |
Not sure, I wasn't actually aware that InstancePrivate and ClassPrivate differed so substantially. This does seem like a gotcha in general, especially since setting a parameter value will swap out the object. You might argue that only Param should access the private namespace but in practice there's probably a few places where Panel and maybe even users will want to access it. |
I'd prefer Param to provide a public API here if there's a need for one. Let's patch Param for now and release, and then:
|
Also, fix issue related to the order of 'param.Parameterized' attribute assignment and superclass initialization that was introduced in a 'param' package release candidate via the shiny new Panel 1.3.0 release. holoviz/panel#5730
Sounds fine to me. |
ALL software version info
(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc)
Description of expected behavior and the observed behavior
Successful execution (like in Panel 1.2.3) is the expected behavior.
In Panel 1.3.0, the observed behavior is an
AttributeError
exception.Complete, minimal, self-contained example code that reproduces the issue
Stack traceback and/or browser JavaScript console output
The text was updated successfully, but these errors were encountered: