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

Saved images are not updated #386

Open
novoselt opened this issue Feb 4, 2013 · 6 comments
Open

Saved images are not updated #386

novoselt opened this issue Feb 4, 2013 · 6 comments

Comments

@novoselt
Copy link
Member

novoselt commented Feb 4, 2013

@interact
def _(k=2):
    plot(sin(k*x)).save("p.png")
    html(r"""<img src='cell://p.png'/>""")

Changing k has no effect on the shown picture due to caching. I've found a trick to make it work by adding time in the end of the link:

@interact
def _(k=2):
    plot(sin(k*x)).save("p.png")
    html(r"""<img src='cell://p.png?%s'/>""" % walltime())
  • perhaps this has to happen automatically?
@jasongrout
Copy link
Member

If you are trying to display the image, can't you just do:

@interact
def _(k=2):
    plot(sin(k*x)).show()

You're right that if you specifically use the html, you'll probably also have to worry about caches. I hesitate to modify the url (beyond the cell://), but maybe we can have the server tell the client not to cache the file.

@novoselt
Copy link
Member Author

novoselt commented Feb 4, 2013

I wanted to display several images arranged neatly, so I was doing it via html table referring to saved files. It does work fine in the worksheet mode, so I think it is quite desirable to have it work for cell server as well. I agree that automatic decoration of links is non-trivial and it would be better to avoid it.

@jasongrout
Copy link
Member

@novoselt
Copy link
Member Author

novoselt commented Feb 4, 2013

That's definitely a more elegant solution for what I was doing! But the main issue as I see it is the discrepancy between different versions of interacts. I can imagine saving some files, running some external programs on them, and then trying to display the result stored as a file, which will return to the same problem.

Also I don't know how to correctly fix this issue, so if you are convinced that it is invalid - feel free to close it.

@novoselt
Copy link
Member Author

novoselt commented Feb 4, 2013

... and actually I cannot easily do what I want with html.table: I prepare the plots and then save them with a bunch of options, e.g. figsize. I don't see a public way to adjust it for an existing plot: SHOW_OPTIONS changes defaults, Graphics() does not take arguments (and in any case plot parameters don't behave very well under addition). Using save(<parameters>) and then explicit HTML reference to display them seems quite natural...

@jasongrout
Copy link
Member

I think it might be as easy as something like: http://stackoverflow.com/questions/12031007/disable-static-file-caching-in-tornado

I suppose a cell:// url will always be getting a file, so maybe there's no harm in appending an argument. I wonder how the notebook does it.

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

No branches or pull requests

2 participants