Giter Club home page Giter Club logo

Comments (9)

philippjfr avatar philippjfr commented on May 21, 2024 2

Thanks for the report. I'll look into but as a quick aside:

For deploying I have downloaded the notebook as a python file and edited Test().show() to Test().show().server_doc().

This shouldn't be necessary, you can have the "app" work both in the notebook and on bokeh server by using Test().show().servable(). That will render in a notebook and work when you use panel serve notebook.ipynb --show.

Also when you want to test bokeh server from a notebook you could do Test().show().show()

from panel.

philippjfr avatar philippjfr commented on May 21, 2024

Okay, so this is a pretty central part of how bokeh server works, changing a parameter value will schedule a so called next_tick_callback, which won't be processed while the "heavy_calculation" is being processed. Ordinarily you could also schedule the calculation as a next_tick_callback and we could consider exposing that mechanism in an easy way. However it would of course be a lot nicer if we could somehow make the naive approach work, I'll have to read a bit more about tornado and bokeh server to see if that's feasible.

from panel.

MHC03 avatar MHC03 commented on May 21, 2024

Thank you very much for looking into all of the issues. For me personally either way is fine, if it is too hard to make it work the naive way, I can try with the next_tick_callback. (But I have to look into how this works)

from panel.

philippjfr avatar philippjfr commented on May 21, 2024

@MHC03 So there's probably nothing we can do automatically, however you can do it by using the tornado IOLoop, in your example you'd do something like:

    def _button_click(self, clicks):
        self.txt.value = 'Start heavy calculation...'
        ioloop = tornado.ioloop.IOLoop.current()
        ioloop.add_callback(self._heavy_calculation)
        
    def _heavy_calculation(self):
        heavy_calculation()
        self.txt.value = 'Heavy calculation finished.'

from panel.

MHC03 avatar MHC03 commented on May 21, 2024

For me the above approach does not fully work, the second change to the textinput value does not occur. It is stuck with 'Start heavy calculation...'. If I change the code to following it works in a server but not in a Jupyter Notebook as intended:

def _button_click(self, clicks):
        self.txt.value = 'Start heavy calculation...'
        ioloop = tornado.ioloop.IOLoop.current()
        ioloop.add_callback(heavy_calculation)
        self.txt.value = 'Heavy calculation finished.'

With this I get the expected behaviour in a server, in a Jupyter Notebook it directly jumps to the last line without waiting for the callback to finish. If I have several heavy calculations it gets a bit more complicated through this method.

from panel.

jbednar avatar jbednar commented on May 21, 2024

This code would be a bit less confusing if you changed your show() method to view(), to avoid confusion with Panel's .show() method.

from panel.

philippjfr avatar philippjfr commented on May 21, 2024

For me the above approach does not fully work, the second change to the textinput value does not occur. It is stuck with 'Start heavy calculation...'.

Yeah, it's not quite clear to me what's going on here, it's definitely not working right in this case but I've used it successfully in other examples.

from panel.

MHC03 avatar MHC03 commented on May 21, 2024

This code would be a bit less confusing if you changed your show() method to view(), to avoid confusion with Panel's .show() method.

Changed it, maybe @philippjfr can also edit his comment.

Yeah, it's not quite clear to me what's going on here, it's definitely not working right in this case but I've used it successfully in other examples.

I will try some workaround with the ioloop callback for now. Thanks a lot for looking into this stuff.

from panel.

philippjfr avatar philippjfr commented on May 21, 2024

Thanks a lot for looking into this stuff.

No problem, I'm encountering the same issues so this is fairly high priority. Still searching for a better solution, but my knowledge of tornado is lacking a bit.

from panel.

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.