@@ -150,7 +150,7 @@ def __new__(self, name: str, bases: Tuple[type], namespaces: Dict[str, Any], **k
150150
151151
152152class BaseModel (PydanticBaseModel , _RegistryMixin , metaclass = _SerializeAsAnyMeta ):
153- """BaseModel is a base class for all pydantic models within the cubist flow framework.
153+ """BaseModel is a base class for all pydantic models within the ccflow framework.
154154
155155 This gives us a way to add functionality to the framework, including
156156 - Type of object is part of serialization/deserialization
@@ -241,6 +241,34 @@ def get_widget(
241241 # Can't use self.model_dump_json or self.model_dump because they don't expose the fallback argument
242242 return JSON (self .__pydantic_serializer__ .to_python (self , ** kwargs ), ** (widget_kwargs or {}))
243243
244+ def __panel__ (self ):
245+ """Return a Panel viewable for this model.
246+
247+ Requires ccflow UI dependencies (panel, panel_material_ui).
248+ """
249+ try :
250+ from ccflow .ui .model import ModelViewer
251+ except ImportError :
252+ raise ImportError (
253+ "panel and other optional dependencies must be installed to use ModelViewer. Pip install ccflow[full] to install all optional dependencies."
254+ ) from None
255+
256+ return ModelViewer (model = self )
257+
258+ def get_panel (self ):
259+ """Get a Panel pane for this model.
260+
261+ Requires panel to be installed.
262+ """
263+ try :
264+ import panel as pn
265+ except ImportError :
266+ raise ImportError (
267+ "panel and other optional dependencies must be installed to use get_panel(). Pip install ccflow[full] to install all optional dependencies."
268+ ) from None
269+
270+ return pn .panel (self )
271+
244272 @model_validator (mode = "wrap" )
245273 def _base_model_validator (cls , v , handler , info ):
246274 if isinstance (v , str ):
@@ -400,6 +428,15 @@ def models(self) -> MappingProxyType:
400428 """Return an immutable pointer to the models dictionary."""
401429 return MappingProxyType (self ._models )
402430
431+ def __panel__ (self ):
432+ """Return a Panel viewable for this registry.
433+
434+ Requires ccflow UI dependencies (panel, panel_material_ui).
435+ """
436+ from ccflow .ui .registry import ModelRegistryViewer
437+
438+ return ModelRegistryViewer (self )
439+
403440 @classmethod
404441 def root (cls ) -> Self :
405442 """Return a static instance of the root registry."""
0 commit comments