Git Product home page Git Product logo

Comments (23)

joouha avatar joouha commented on May 25, 2024 1

Interesting. Feels like we're getting closer!

The kitty graphics protocol allows you to do more complex things with images then sixel graphics, such as hide & show, duplicate, and move images. Currently I'm not making full use of it's capabilities - I'm just clearing all images from a notebook and re-drawing them every time the display is drawn.

I'm already aware of some issues with with the way I implemented this (one is that images are cleared per notebook, which means that if you have multiple notebooks, only the images from one notebook will be displayed). I suspect the problem you are having may be related.

Rewriting the euporie's kitty graphics code so images are shown, hidden, and moved without re-drawing them is on my to-do list.

from euporie.

joouha avatar joouha commented on May 25, 2024 1

The "colinear!" text you are seeing is OS-level standard error output from the kernel (reportlab prints directly to stderr in it's c-extensions - see here).

The same thing happens with JupyterLab - output is printed to the terminal where the kernel was started rather than being displayed in the notebook:

image

There is an old IPython issue about this I remember from years ago: ipython/ipython#1230

The issue mentions a nice IPython extension wurlitzer you can use to work around this:

image

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

For what it's worth: just tried to run using a direct install from master (0.1.11), didn't work either

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

This doesn't seem to be matplotlib related, the following causes the same error (works well in ipython)

from prompt_toolkit import print_formatted_text, HTML

print_formatted_text(HTML('<b>This is bold</b>'))

from euporie.

joouha avatar joouha commented on May 25, 2024

Hi,

I'm a bit surprised you were still experiencing this with 0.1.11, as after 76d7831 TextArea is no longer used to display any outputs. Do you mind checking again you were actually using 0.1.11 or newer?

I've been working on fixing the display of ansi output containing carriage returns (which includes print_formatted_text output). A tentative fix for this is in 1d4884e.

The two code snippets you posted look currently give the following output with master in kitty terminal:

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

Yeah I mean I showed you the pip install output directly copy pasted so unless something with poetry is wonky it should've been 0.1.11.

I just tried to reinstall it (I have no experience with poetry, just doing poetry install), however I'm running into this:

python-poetry/poetry#3628

I tried uninstalling poetry, and deleting the git project and reinstalling everything twice but to no avail so unfortunately I can help debug because I can't install euporie anymore and pip is still at 0.1.9.

from euporie.

joouha avatar joouha commented on May 25, 2024

Forgive me if I'm telling you what you already know.

It appears you might still have 0.1.9 installed on your main python distribution. To upgrade euporie to the latest version, you can run:

pip install --upgrade euporie

This should update euporie to 0.1.11 or later.


If you want to run euporie from master, you'll need to run something like:

git clone https://github.com/joouha/euporie.git
cd euporie
poetry install
poetry run euporie

Running poetry install from the cloned repo makes poetry install euporie as a development install (along with its dependencies) into a virtual environment, which is isolated from your system python installation. Running euporie without activating the virtual environment first will still run the version installed installed on your system distribution with pip.

You can run euporie from this virtual environment using poetry run euporie, or you can launch a shell with the virtual environment activated using poetry shell, and run euporie from there.

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

thanks a ton for the help with debugging here! We're making progress:
so installing the new 0.1.11 from pip got rid of the error messages (I did however make sure that there is no 0.1.9 pip install in any of my envs before, however at time of my previous writing pip installs still installed 0.1.9 even for fresh installs, so now it's pulling correctly)

Now I'm not getting any errors, but also no outputs for the plotting

image

If you want to run euporie from master, you'll need to run something like:

git clone https://github.com/joouha/euporie.git
cd euporie
poetry install
poetry run euporie

Running poetry install from the cloned repo makes poetry install euporie as a development install (along with its dependencies) into a virtual environment, which is isolated from your system python installation. Running euporie without activating the virtual environment first will still run the version installed installed on your system distribution with pip.

You can run euporie from this virtual environment using poetry run euporie, or you can launch a shell with the virtual environment activated using poetry shell, and run euporie from there.

Thanks this is very helpful! However, unfortunately, like the issue I've linked, I can't run any poetry commands right now, even after wiping it from my system/fresh install. The linked issue mentiones potential to delete the cache folder fixing it, however, this cache isn't created on my machine (no ~/.cache/pypoetry or similar). There is osx specific caches in ~/Library/caches/pypoetry and I did try deleting that but to no avail). So unfortunately any poetry command (poetry show, poetry install right now results in

❯ poetry install

  TypeError

  expected string or bytes-like object

  at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/utils/helpers.py:27 in canonicalize_name
       23│ _canonicalize_regex = re.compile(r"[-_]+")
       24│
       25│
       26│ def canonicalize_name(name):  # type: (str) -> str
    →  27│     return _canonicalize_regex.sub("-", name).lower()
       28│
       29│
       30│ def module_name(name):  # type: (str) -> str
       31│     return canonicalize_name(name).replace(".", "_").replace("-", "_")
❯ pwd
/Users/yingzhu_/euporie

from euporie.

joouha avatar joouha commented on May 25, 2024

If you install timg do you get ansi images when you try plotting?

You can install it as an optional dependency of euporie with:

pip install --upgrade euporie[images-timg]

Have you tried upgrading poetry? You appear to be running 1.10.0b or similar.

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

poetry is/was on 1.16 according to it's CLI. timg doesn't seem to help

image

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

I solved the poetry issue (was a package installed somehow with invalid metadata file). However, on the master branch's version of 0.1.12 the display issues still persist

from euporie.

joouha avatar joouha commented on May 25, 2024

I'm a bit perplexed!

This could be a bug with kitty image rendering. I know the way I have implemented kitty image rendering needs work. What version of kitty are you using? (Unfortunately I do not have access to a Mac).

If you create a cell with an image output then scroll so the cell is partially off-screen, do you see the image rendered as text?

Are you able to get text-mode image output in another terminal?

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

Using kitty 0.19.3

both timg and the matplotlib kitty backend work well

image

Again thanks a lot for helping debugging this.

wrt to Mac: I know a lot of co's use https://www.macstadium.com/ for their CI to test things.

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

Just noticed something odd - if I open a notebook that contains images, the images are displayed correctly.

2021-05-21 at 8 53 AM

and indeed, when i scroll it half off the page, they become text like

image

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

Yes I had realized that this actually occurs in other frontends as well (which is why I had deleted the comment). Thanks a lot this is super helpful though

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

@joouha I think this isn't a png specific issue btw - also occurs for svg's - just no output created when printing them.

image

from euporie.

joouha avatar joouha commented on May 25, 2024

The reason this occurs with SVGs is because euporie converts them to PNG format to render them.

Could you try upgrading to 0.1.14 and printing a notebook with the --dump command line flag? I'd be interested to see if you get image output.

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

Unfortunately doesn't
image

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

Also just updated kitty to 0.20.3, didn't help either :/

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

FYI @joouha - i finally had time to dig deeper here and now see where the opening of another NB with image works vs local fails. Appears to have something todo with the kernel's response. Here is the msg returned when executing a command

message {'header': {'msg_id': '7fb602e6-758acaed5578b6bb8bb27ea9_9', 'msg_type': 'status', 'username': 'yingzhu', 'session': '7fb602e6-758acaed5578b6bb8bb27ea9', 'date': datetime.datetime(2021, 6, 20, 4, 14, 13, 446180, tzinfo=tzutc()), 'version': '5.3'}, 'msg_id': '7fb602e6-758acaed5578b6bb8bb27ea9_9', 'msg_type': 'status', 'parent_header': {'msg_id': 'db07f97c-9ee867c0ccc2844ddf569eaa_1', 'msg_type': 'execute_request', 'username': 'yingzhu', 'session': 'db07f97c-9ee867c0ccc2844ddf569eaa', 'date': datetime.datetime(2021, 6, 20, 4, 14, 13, 413123, tzinfo=tzutc()), 'version': '5.3'}, 'metadata': {}, 'content': {'execution_state': 'busy'}, 'buffers': []}
message {'header': {'msg_id': '7fb602e6-758acaed5578b6bb8bb27ea9_10', 'msg_type': 'execute_input', 'username': 'yingzhu', 'session': '7fb602e6-758acaed5578b6bb8bb27ea9', 'date': datetime.datetime(2021, 6, 20, 4, 14, 13, 446630, tzinfo=tzutc()), 'version': '5.3'}, 'msg_id': '7fb602e6-758acaed5578b6bb8bb27ea9_10', 'msg_type': 'execute_input', 'parent_header': {'msg_id': 'db07f97c-9ee867c0ccc2844ddf569eaa_1', 'msg_type': 'execute_request', 'username': 'yingzhu', 'session': 'db07f97c-9ee867c0ccc2844ddf569eaa', 'date': datetime.datetime(2021, 6, 20, 4, 14, 13, 413123, tzinfo=tzutc()), 'version': '5.3'}, 'metadata': {}, 'content': {'code': "%matplotlib inline\nimport matplotlib.pyplot as plt\nplt.plot([1, 2, 3, 4])\nplt.ylabel('some numbers')\nplt.show()", 'execution_count': 2}, 'buffers': []}
message {'header': {'msg_id': '7fb602e6-758acaed5578b6bb8bb27ea9_12', 'msg_type': 'status', 'username': 'yingzhu', 'session': '7fb602e6-758acaed5578b6bb8bb27ea9', 'date': datetime.datetime(2021, 6, 20, 4, 14, 13, 491437, tzinfo=tzutc()), 'version': '5.3'}, 'msg_id': '7fb602e6-758acaed5578b6bb8bb27ea9_12', 'msg_type': 'status', 'parent_header': {'msg_id': 'db07f97c-9ee867c0ccc2844ddf569eaa_1', 'msg_type': 'execute_request', 'username': 'yingzhu', 'session': 'db07f97c-9ee867c0ccc2844ddf569eaa', 'date': datetime.datetime(2021, 6, 20, 4, 14, 13, 413123, tzinfo=tzutc()), 'version': '5.3'}, 'metadata': {}, 'content': {'execution_state': 'idle'}, 'buffers': []}

You can see that

        elif msg_type == "stream":
        elif msg_type in ("error", "display_data", "execute_result"):

are never hit so it'll never render.

I'm not too familiar w/ the jupyter message protocol but will debug further

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

Fixed it!
image

poetry made this extra difficult to debug as it had a lot of issues I never encountered with normal pip repos, ran into a lot of open issues on the repo, just my 2cents, you might want to consider to switch to pip (I appreciate the design decision of poetry and the problem it tries to solve, but in practice it didn't solve it for me while the conda/pip combo with pinned versions in requirements works good enough).

from euporie.

joouha avatar joouha commented on May 25, 2024

Awesome - I'm so pleased you fixed this!

What actually was the problem in the end?

from euporie.

yingzhu146 avatar yingzhu146 commented on May 25, 2024

from euporie.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.