Skip to content

limit lines in html repr of dataset attrs #7653

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ostheer
Copy link
Contributor

@Ostheer Ostheer commented Mar 21, 2023

Truncates the amount of lines output by _html_repr_ for DataSet/DataArray objects.

Motivation is that currently, if an attribute has a larger number of line breaks, it will pollute your Jupyter (etc) view.
For example, I like to append the measurement script source file to all my measurement results. When I then load the netcdf file, the attributes will contain a file with potentially hundreds of lines. I don't want all these lines to be shown in my output cells when viewing the html representation.

In the suggested edit, max_lines defines above which amount of lines the output should be truncated, while min_lines defines how many should still be shown (like a preview). The current values of 15 and 10 are somewhat arbitrary.

@Ostheer
Copy link
Contributor Author

Ostheer commented Mar 21, 2023

Uh, the macos-latest py3.11 test was cancelled after a few hours (it was 95% done):

The job running on runner GitHub Actions 6 has exceeded the maximum execution time of 360 minutes.

@dcherian
Copy link
Contributor

Since this is the HTML repr, it'd be nice to allow the user to "click to expand" long entries. Do you know how to do that? (ping @benbovy )

I think a corresponding change to truncate the text repr would be fine.

@Ostheer
Copy link
Contributor Author

Ostheer commented Mar 23, 2023

I may be able to implement that, hopefully some time in the upcoming days.

@benbovy
Copy link
Member

benbovy commented Mar 23, 2023

For the html repr an option that is easy to implement would be to add max-height and overflow-y: scroll CSS properties here:

.xr-attrs dt {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding-right: 10px;
}

I don't think the default browser scrollbar will look very pretty inside the repr, but it might be OK if we don't set max-height to a too small value.

A "click to expand" UI would certainly look prettier, but I doubt it would be easy to implement that in pure-CSS. "Expand on hover" is easier but that would be quite annoying UX I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants