Skip to content

Commit

Permalink
Do not sync parameters mapped to None (#7750)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Mar 2, 2025
1 parent 0d92338 commit a1b91cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions panel/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ def __init__(mcs, name: str, bases: tuple[type, ...], dict_: Mapping[str, Any]):
# Create model with unique name
ReactiveMetaBase._name_counter[name] += 1
model_name = f'{name}{ReactiveMetaBase._name_counter[name]}'
ignored = [p for p in Reactive.param if not issubclass(type(mcs.param[p].owner), ReactiveESMMetaclass)]
ignored = [
p for p in Reactive.param
if not issubclass(type(mcs.param[p].owner), ReactiveESMMetaclass)
]
mcs._data_model = construct_data_model(
mcs, name=model_name, ignore=ignored, extras={'esm_constants': param.Dict}
)
Expand Down Expand Up @@ -426,10 +429,10 @@ def _get_properties(self, doc: Document | None) -> dict[str, Any]:
]
for k, v in self.param.values().items():
p = self.param[k]
is_viewable = is_viewable_param(p)
if (k in ignored and k != 'name') or ((p.precedence or 0) < 0) or is_viewable:
if is_viewable and k in props:
props.pop(k)
if is_viewable_param(p) or type(self)._property_mapping.get(k, "") is None:
props.pop(k, None)
continue
elif (k in ignored and k != 'name') or ((p.precedence or 0) < 0):
continue
if k in props:
props.pop(k)
Expand Down Expand Up @@ -486,7 +489,7 @@ def _get_children(self, data_model, doc, root, parent, comm) -> dict[str, list[U
children = {}
for k, v in self.param.values().items():
p = self.param[k]
if not is_viewable_param(p):
if not is_viewable_param(p) or type(self)._property_mapping.get(k, "") is None:
continue
children[k] = self._get_child_model(v, doc, root, parent, comm)
return children
Expand Down
2 changes: 1 addition & 1 deletion panel/io/datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def construct_data_model(parameterized, name=None, ignore=[], types={}, extras={
ptype = types.get(pname, type(p))
prop = PARAM_MAPPING.get(ptype)
if isinstance(parameterized, Syncable):
pname = parameterized._rename.get(pname, pname)
pname = parameterized._property_mapping.get(pname, pname)
if pname == 'name' or pname is None:
continue
nullable = getattr(p, 'allow_None', False)
Expand Down

0 comments on commit a1b91cd

Please sign in to comment.