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
Lazy html representation #2855
Lazy html representation #2855
Conversation
Good idea! Especially since the doing the "wrong" chunking in the wrong dimension can lead to some really slow processing, or the whole computer crashing due to lack of memory. I'll try to chip in some review-time! |
This looks very nice and informative! I like this representation much more than checking I think the representation is dense enough, and shouldn't contain much more information. Perhaps the "fast" axes can be bold? I'm not sure how many more new dependencies changing |
Good idea! I can easily make that change.
The widgets module was just added to help out with this kind of representations so I'm not sure you can install just dask.widgets. At least it isn't listed under packages https://github.com/dask/dask/blob/f5881891505b9a2ba2da195befb11ad7b4c7bb23/setup.py#L41-L50 I think that an optional download is probably the best case scenario for now. |
Codecov Report
@@ Coverage Diff @@
## RELEASE_next_minor #2855 +/- ##
======================================================
+ Coverage 77.10% 77.12% +0.02%
======================================================
Files 206 206
Lines 31821 31868 +47
Branches 7152 7161 +9
======================================================
+ Hits 24535 24579 +44
- Misses 5533 5534 +1
- Partials 1753 1755 +2
Continue to review full report at Codecov.
|
Regarding dask packages, I just did conda create -n dask-test python=3.9
conda activate dask-test
pip install dask[array]
python -c "from dask.widgets import TEMPLATE_PATH" which imported |
xref #1931.
Already testing that the code run is already good, even if the output is not checked. You could save the html code and compare to this, but it would mean that it is heavily dependent on the specific dask widgets implementation and therefore it is not good.
In my opinion, this is good as it is in the image of your summary. If users want more information about the dask graph and the source of the task, they should use dask directly - there are some widgets to visualise it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, I made some suggestions/comments.
Some alignments are a bit off, but this is not a big deal:
- the space about above "Title"
- "Navigation Axes` is misaligned with the chunks of the navigation space
Also, could you please rebase this branch to tidy up the history and remove some spurious files/commits?
b5246aa
to
da22d79
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good.
This doesn't work when the array contain only one single chunk. It doesn't raise an error because it falls back to non html display, but it is confusing and it should be made consistent
Example to reproduce and raise the error by calling _repr_html_
directly:
import dask.array as da
import hyperspy.api as hs
s = hs.signals.BaseSignal(da.random.random((500, 1000))).as_lazy()
s._repr_html_()
which raises:
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
/tmp/ipykernel_80943/4231446018.py in <module>
----> 1 s._repr_html_()
~/Dev/hyperspy/hyperspy/_signals/lazy.py in _repr_html_(self)
170 from dask.widgets import get_template
171 from dask.utils import format_bytes
--> 172 nav_grid = svg(chunks=self.get_chunk_size(axis=self.axes_manager.navigation_axes),
173 size=config.get("array.svg.size", 160))
174 sig_grid = svg(chunks=self.get_chunk_size(axis=self.axes_manager.signal_axes),
/opt/miniforge/lib/python3.9/site-packages/dask/array/svg.py in svg(chunks, size, **kwargs)
27 raise NotImplementedError("Can't generate SVG with 0-length dimensions")
28 if len(chunks) == 0:
---> 29 raise NotImplementedError("Can't generate SVG with 0 dimensions")
30 if len(chunks) == 1:
31 return svg_1d(chunks, size=size, **kwargs)
NotImplementedError: Can't generate SVG with 0 dimensions
9ff9c9a
to
e707707
Compare
0b1e000
to
4b03b14
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rebased to get the test suite to pass because of the ipython 8.0 issue and I tidy/fix minor issues with the doc and packaging.
This adds in an html representation for a lazy signal. I think this helps to visualize and understand higher dimensional data. It separates chunks into the signal and navigation axes.
A few sentences and/or a bulleted list to describe and motivate the change:
Progress of the PR
upcoming_changes
folder (see [upcoming_changes/README.rst
]readthedocs
doc build of this PR (link in github checks)Minimal example of the bug fix or the new feature
For anyone using lazy signals @ericpre @pc494 @magnunor @hakonanes I'm open to any suggestions as to what you think might be useful to add to the html representation.
Other Things to Consider:
Anything else?