Skip to content
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

Hide metadata inputs for tasks in HTML visualization. #346

Merged
merged 8 commits into from
Dec 2, 2024

Conversation

GeigerJ2
Copy link
Contributor

@GeigerJ2 GeigerJ2 commented Nov 19, 2024

Fixes #119.

Copy link
Member

@superstar54 superstar54 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @GeigerJ2 , instead of handling metadata specially, it would be good to also handle other namespace ports. I suggest to use a parameter to control it.
For example, we can add an attribute to the node, e.g., show_socket_level, and the default value is 0 to only the top level, if it is 1, then show all root.sub, and so on.

@GeigerJ2
Copy link
Contributor Author

Hi @GeigerJ2 , instead of handling metadata specially, it would be good to also handle other namespace ports. I suggest to use a parameter to control it. For example, we can add an attribute to the node, e.g., show_socket_level, and the default value is 0 to only the top level, if it is 1, then show all root.sub, and so on.

Nice idea, I like it! Will implement it!

@GeigerJ2
Copy link
Contributor Author

Hi, @superstar54, I generalized it in my latest commit. The namespace nesting depth for the shown sockets can now be controlled by a parameter of the to_html method of a Task. I assumed this nesting only applies to top-level keys, and I'm not sure if this covers all use cases. So please let me know if something else comes to mind here. I'll add tests then afterwards.

@superstar54
Copy link
Member

Thanks for the update!
apart from the HTML, it also good to add show_socket_depth as a attribute of Task, and then use it in the widget, as follow:

def _repr_mimebundle_(self, *args: Any, **kwargs: Any) -> any:

        if self._widget is None:
            print(WIDGET_INSTALLATION_MESSAGE)
            return
        # if ipywdigets > 8.0.0, use _repr_mimebundle_ instead of _ipython_display_
+        self._widget.from_node(self, show_socket_depth=self.show_socket_depth)
-        self._widget.from_node(self)
        if hasattr(self._widget, "_repr_mimebundle_"):
            return self._widget._repr_mimebundle_(*args, **kwargs)
        else:
            return self._widget._ipython_display_(*args, **kwargs)

This way, the user can control the widget.

@superstar54 superstar54 self-requested a review December 2, 2024 13:00
Copy link
Member

@superstar54 superstar54 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@superstar54 superstar54 merged commit 512d1a8 into aiidateam:main Dec 2, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hide all unnecessary metadata input sockets from Task visualization
2 participants