Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # 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.

@GeigerJ2 GeigerJ2 requested a review from superstar54 November 19, 2024 10:56
Co-authored-by: Xing Wang <xingwang1991@gmail.com>
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
@superstar54 superstar54 force-pushed the fix/119/metadata-task-vis branch from c2ace09 to 09af3e2 Compare December 2, 2024 13:04
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
@GeigerJ2 GeigerJ2 deleted the fix/119/metadata-task-vis branch December 3, 2024 10:58
# for free to join this conversation on GitHub. Already have an account? # 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