Code Monkey home page Code Monkey logo

gvmagic's People

Contributors

cjdrake avatar gaperez64 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mcwehner inducer

gvmagic's Issues

SVG should be returned as String for Jupyter Lab

Hi

I am running Jupyter Lab Version 1.2.4. I recently cranked up a Jupyter Notebook that was about two years old, and %%dot didn't work :( ( I got the broken object icon, instead of the rendered SVG).

I found the fix was to convert the dot output (svg script) from a byte array to a string, like so in the function run_graphviz :

    dot = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE,  shell=True)
    stdoutdata, stderrdata = dot.communicate(s.encode('utf-8'))
    status = dot.wait()
    if status == 0:
        # convert byte array into string
        return stdoutdata.decode('utf-8')

I guess iPython has become more strict in what it accepts (or has dropped support for Python 2.*)

happy to supply more info if needed
Don

Two fixes for gvmagic

I'm attaching two patch files for gvmagic.py, which you should be able to apply using git. They do the following:

  1. Find the dot executable in the user's shell, and invoke it by absolute pathname. This addresses #1
  2. Ensure that run_graphviz returns a string. Under at least some conditions it will return a bytearray instead of a string, and then jupyter won't properly display the SVG image.

0001-Fix-invocation-of-dot-executable.patch.txt
0002-Ensure-run_graphviz-returns-string.patch.txt

shell=True required in subprocess Popen()?

Hi

I am running Jupyterlab Version 0.31.8 in Python 3.6 (3.6.3 | packaged by conda-forge | (default, Nov 4 2017, 10:10:42) [MSC v.1900 64 bit (AMD64)]), running on windows 10 (Windows-10-10.0.16299-SP0)

I installed graphviz 2.38.0 and python-graphviz 0.8.2 via anaconda navigator.

The dot shell command reports the dot version as:
dot - graphviz version 2.38.0 (20140413.2041)

I downloaded gvmagic.py from:
https://raw.githubusercontent.com/cjdrake/ipython-magic/master/gvmagic.py

on 7th March 2018

The magic commands:
%reload_ext gvmagic

%%dot

graph{
a -- b;
b -- c;
a -- c;
d -- c;
e -- c;
e -- a;
}

then fail with a Windows 'File not found' on the subprocess.Popen call that runs dot.

If I add the parameter shell=True to this call, then it all works fine:
IE dot = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)

happy to run more tests, if needed

Cheers
Don

Image Nodes not displayed in %%dot output in Jupyterlab?

I am running Jupyterlab Version 0.31.8 in Python 3.6 (3.6.3 | packaged by conda-forge | (default, Nov 4 2017, 10:10:42) [MSC v.1900 64 bit (AMD64)]), running on windows 10 (Windows-10-10.0.16299-SP0)

I installed graphviz 2.38.0 and python-graphviz 0.8.2 via anaconda navigator.

The dot shell command reports the dot version as:
dot - graphviz version 2.38.0 (20140413.2041)

Jupyterlab is running in Microsoft Edge 41.16299.248.0

the simple %%dot file

 %%dot

 graph {

  server1 [image="server.bmp", label="", shape=none]
  server2

  server1--server2
  }

fails to display the image in the output cell, and converting the notebook to HTML also yields an empty node (with no image).

Running the equivalent dot command from the command line works fine (image is displayed in node).

The format of the image (bmp, png, etc) does not seem to affect the result (all fail to display inside the node in the diagram in the notebook output cell).

Please note that I am setting shell=True in the gvmagic Popen call, as per issue previously raised.

happy to run more tests

Don

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.