Closed hkoppen closed 3 years ago
A small example using the example in the docs any my regression data:
[...] # Some packages
from explainerdashboard import RegressionExplainer, ExplainerDashboard
from explainerdashboard.custom import *
[...] # Load data & model
explainer = RegressionExplainer(dec_tree, X_small, y_small, cats=['Day_of_week', 'Hour', 'Vehicle', 'Position'])
class CustomDashboard(ExplainerComponent):
def __init__(self, explainer, **kwargs):
super().__init__(explainer, title="Custom Dashboard")
self.contrib = ShapContributionsGraphComponent(explainer,
hide_selector=True, hide_cats=True, hide_depth=True, hide_sort=True,)
self.register_components()
def layout(self):
return dbc.Container([
dbc.Row([
dbc.Col([
self.contrib.layout(),
])
])
])
db = ExplainerDashboard(explainer, CustomDashboard)
returns basically the same error as above.
Ah, yes, I can see what went wrong here. You can fix it by adding name=None
to the __init__
of your custom tab.
Basically in order to get rid of the random uuid names which cause trouble when you deploy with a docker swarm, I give every tab an incremental name, so the first tab gets name='1'
, the second name='2'
, etc. But this only works ofcourse when the init actually takes the name parameter. Which is true for the default composites, but not always for custom ones.
So I can either:
although in the second example you actually accept **kwargs
, so then it should have worked, no?
It actually seems that somehow _store_child_params
is no longer storing parameters to attributes, which is why self.name
cannot be found. Am investigating!
Just pushed v0.2.19.1 which should fix your issue. Also is now respectful of ExplainerComponents that do not take **kwargs
:
if inspect.isclass(component) and issubclass(component, ExplainerComponent):
init_argspec = inspect.getargspec(component.__init__)
if not init_argspec.keywords:
kwargs = {k:v for k,v in kwargs.items() if k in init_argspec.args}
if "name" in init_argspec.args:
component = component(explainer, name=name, **kwargs)
else:
print(f"ExplainerComponent {component} does not accept a name parameter, "
f"so cannot assign name={name}!"
"Make sure to set name explicitly yourself if you want to "
"deploy across multiple workers or a cluster, as otherwise "
"each instance in the cluster will generate its own random "
"uuid name!")
component = component(explainer, **kwargs)
return component
It did!
After updating to the most recent version, my custom dashboard isn't working anymore, neither after "inplace construction" nor after loading from disk. More precisely:
works fine but
yields
Offtopic: I am going to deploy the dashboard using Docker in one or two weeks, hopefully I am able to give some feedback on the respective issue then.