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

Annotate HTML alignment broken in JupyterLab #4064

Open
cdeil opened this issue May 7, 2019 · 12 comments
Open

Annotate HTML alignment broken in JupyterLab #4064

cdeil opened this issue May 7, 2019 · 12 comments
Labels
bug - incorrect behavior Bugs: incorrect behavior

Comments

@cdeil
Copy link
Contributor

cdeil commented May 7, 2019

While trying out Numba Annotate (and after fixing #4063) I noticed that the alignment is broken in JupyterLab. It is right-aligned, but should be left-aligned. (I didn't try in Jupyter notebook)

See screenshot below.

@Carreau - Do you know what's wrong?


Another usability issue is that executing the cell with the example multiple times makes the HTML output grow and grow, showing the same annotated output multiple times. This looks like a bug, no? When re-executing a def statement with numba.jit decorator, a new numba.targets.registry.CPUDispatcher object should be created, and nothing should accumulate, no?


Screenshot 2019-05-07 at 10 22 12

@Carreau
Copy link
Contributor

Carreau commented May 7, 2019

That is likely an issue in JupyterLab itself; and diverging CSS with classic notebook; do you know with which version of JupyterLab. cc @jasongrout

@cdeil
Copy link
Contributor Author

cdeil commented May 7, 2019

I have JupyterLab version 0.35.5 and Numba git master (but probably the same as the last release, you should see this issue with Numba 0.43.1 as well).

@Carreau
Copy link
Contributor

Carreau commented May 7, 2019

you may want to try with Jupyterlab 1.0-alpha, using pip install --pre, I know the CSS was updated; but havent' been involved much.

@cdeil
Copy link
Contributor Author

cdeil commented May 7, 2019

I tried pip install -U --pre jupyterlab and got jupyterlab-1.0.0a3-py2.py3-none-any.whl. Still the same issue.

In Jupyter notebook the output looks fine.

If someone has time to try and reproduce and pinpoint the issue, here's the code snippet to copy & paste to reproduce the issue:

import numba
from numba.pretty_annotate import Annotate
@numba.jit
def test(q):
    res = 0
    for i in range(q):
        res += i
    return res
     
test(10)
Annotate(test)

@jasongrout
Copy link

Here is the classic notebook css:
Screen Shot 2019-05-07 at 11 48 32 AM

Here it is in JLab. You'll notice that there is some jlab css that is overriding the align left. The joys of the global css namespace!
Screen Shot 2019-05-07 at 11 48 51 AM

@jasongrout
Copy link

Looks like the striping also is a difference. Here is classic notebook:
Screen Shot 2019-05-07 at 12 00 49 PM

Here is JLab:
Screen Shot 2019-05-07 at 12 01 31 PM

@jasongrout
Copy link

(perhaps the striping should be with --jp-layout-color1 instead of --jp-layout-color0)

@cdeil
Copy link
Contributor Author

cdeil commented May 7, 2019

@jasongrout - Thanks for having a look!

What does it mean? Will something be changed to fix this on the JupyterLab side, or is a fix in the numba repo needed?

I see there's CSS with a comment "override JupyterLab style" here:

/* override JupyterLab style */
.annotation_table td {
text-align: left;
background-color: transparent;
padding: 1px;
}
.annotation_table tbody tr:nth-child(even) {
background: white;
}
.annotation_table code
{
background-color: transparent;
white-space: normal;
}
/* End override JupyterLab style */

@jasongrout
Copy link

Will something be changed to fix this on the JupyterLab side, or is a fix in the numba repo needed?

Good question. It's not clear to me which should change to make the annotation table css have higher precedence. I mean, in general we'd like to not cause users work, but custom css relies heavily on the dom and css structure, and that's not something we preserved from the classic notebook (and never really was a public api for users).

It's probably easiest to make the change in numba, as in there are far fewer moving parts that are all interconnected. It's not very clear if we change jlab to have less specific css for those tables how those changes will ripple through the jlab styling.

@jasongrout
Copy link

If you wanted to make sure your styling took precedence, you could hardcode style attributes in the tr and td elements. Those take precedence over the <style> tags you are embedding.

@esc
Copy link
Member

esc commented Sep 10, 2020

@cdeil hi! It has been over a year since the last activity on this ticket and I was wondering if this issue is perhaps resolved by now? Or perhaps you managed to discover a workaround?

@guilhermeleobas
Copy link
Collaborator

Hi all, I can still reproduce the error using latest Numba and Jupyterlab.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - incorrect behavior Bugs: incorrect behavior
Projects
None yet
Development

No branches or pull requests

6 participants