Skip to content

Commit

Permalink
add show_socket_depth
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 committed Dec 2, 2024
1 parent d437895 commit 460ae41
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions aiida_workgraph/task.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from node_graph.node import Node as GraphNode
from aiida_workgraph import USE_WIDGET
from aiida_workgraph.properties import property_pool
Expand Down Expand Up @@ -56,6 +58,7 @@ def __init__(
self._widget = None
self.state = "PLANNED"
self.action = ""
self.show_socket_depth = 0

def to_dict(self) -> Dict[str, Any]:
from aiida.orm.utils.serialize import serialize
Expand Down Expand Up @@ -172,14 +175,18 @@ def _repr_mimebundle_(self, *args: Any, **kwargs: Any) -> any:
print(WIDGET_INSTALLATION_MESSAGE)
return
# if ipywdigets > 8.0.0, use _repr_mimebundle_ instead of _ipython_display_
self._widget.from_node(self)
self._widget.from_node(self, show_socket_depth=self.show_socket_depth)
if hasattr(self._widget, "_repr_mimebundle_"):
return self._widget._repr_mimebundle_(*args, **kwargs)
else:
return self._widget._ipython_display_(*args, **kwargs)

def to_html(self, output: str = None, show_socket_depth: int = 0, **kwargs):
def to_html(
self, output: str = None, show_socket_depth: Optional[int] = None, **kwargs
):
"""Write a standalone html file to visualize the task."""
if show_socket_depth is None:
show_socket_depth = self.show_socket_depth
if self._widget is None:
print(WIDGET_INSTALLATION_MESSAGE)
return
Expand Down

0 comments on commit 460ae41

Please sign in to comment.