How to troubleshoot a bokeh server using console

I have an bokeh application I’m trying to build that imports bank statements and allows updating and viewing of that information via a DataTable. But currently there is a module I have built and execute in a function of the script I run with bokeh serve that won’t execute but if i run that same script in a notebook and adjust the call to display it the function executes just fine.

I have the following versions of the main libraries I’m using:

Python = 3.4.2

Bokeh = 0.12.5

sqlalchemy = 1.1.9

The function I’m calling on looks like this with the import of my own module:

···

from models.Data_Import import Import_Statements

def cb_import_statements():

Import_Statements().import_statements()

cb_import_statements()


I can even try executing the Import_Statements().import_statements() on it’s own and it won’t execute. I also confirmed the function itself is called if I put another line to execute inside the function. This is supposed to execute at time of running the bokeh server and when a button is clicked.

Now while my dilemma is that it’s not running, the bigger issue is I get no errors outputted to the bokeh server console. Even when I do a print function I don’t see anything on the bokeh server console. What is the best way to troubleshoot something like this when the bokeh server is running?

Can you confirm that this code:

  # test.py
  from bokeh.io import curdoc
  from bokeh.models import Button
  b = Button()
  b.on_click(lambda: print("CLICK!"))
  curdoc().add_root(b)

run with

  bokeh serve --show test.py

does not print "CLICK!" for you when the button is pressed? If not, please provide more information about your platform. On OSX, I cannot reproduce any issue. This code prints "CLICK!" on every button press (as expected).

Thanks,

Bryan

···

On May 1, 2017, at 13:08, [email protected] wrote:

I have an bokeh application I'm trying to build that imports bank statements and allows updating and viewing of that information via a DataTable. But currently there is a module I have built and execute in a function of the script I run with bokeh serve that won't execute but if i run that same script in a notebook and adjust the call to display it the function executes just fine.

I have the following versions of the main libraries I'm using:

Python = 3.4.2
Bokeh = 0.12.5
sqlalchemy = 1.1.9

The function I'm calling on looks like this with the import of my own module:
-------------------------------------

from models.Data_Import import Import_Statements

def cb_import_statements():
    Import_Statements().import_statements()

cb_import_statements()

----------------------------------
I can even try executing the Import_Statements().import_statements() on it's own and it won't execute. I also confirmed the function itself is called if I put another line to execute inside the function. This is supposed to execute at time of running the bokeh server and when a button is clicked.

Now while my dilemma is that it's not running, the bigger issue is I get no errors outputted to the bokeh server console. Even when I do a print function I don't see anything on the bokeh server console. What is the best way to troubleshoot something like this when the bokeh server is running?

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/971094e4-fcc6-425f-bd31-5e07939e33a2%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

I did some quick tests and what you had worked fine as did me putting a print statement inside of a class that I import. I’ll have to do some more thorough testing with my other application and see if I can identify the difference between these two things.

I couldn’t do --show by the way as it’s running on a headless machine. I’ll come back with an update with what my findings are.

Thanks,

Dan

···

On Tuesday, 2 May 2017 17:08:45 UTC+10, Bryan Van de ven wrote:

Can you confirm that this code:

    # test.py

    from [bokeh.io](http://bokeh.io) import curdoc
    from bokeh.models import Button
    b = Button()
    b.on_click(lambda: print("CLICK!"))
    curdoc().add_root(b)

run with

    bokeh serve --show test.py

does not print “CLICK!” for you when the button is pressed? If not, please provide more information about your platform. On OSX, I cannot reproduce any issue. This code prints “CLICK!” on every button press (as expected).

Thanks,

Bryan

On May 1, 2017, at 13:08, [email protected] wrote:

I have an bokeh application I’m trying to build that imports bank statements and allows updating and viewing of that information via a DataTable. But currently there is a module I have built and execute in a function of the script I run with bokeh serve that won’t execute but if i run that same script in a notebook and adjust the call to display it the function executes just fine.

I have the following versions of the main libraries I’m using:

Python = 3.4.2

Bokeh = 0.12.5

sqlalchemy = 1.1.9

The function I’m calling on looks like this with the import of my own module:


from models.Data_Import import Import_Statements

def cb_import_statements():

Import_Statements().import_statements()

cb_import_statements()


I can even try executing the Import_Statements().import_statements() on it’s own and it won’t execute. I also confirmed the function itself is called if I put another line to execute inside the function. This is supposed to execute at time of running the bokeh server and when a button is clicked.

Now while my dilemma is that it’s not running, the bigger issue is I get no errors outputted to the bokeh server console. Even when I do a print function I don’t see anything on the bokeh server console. What is the best way to troubleshoot something like this when the bokeh server is running?


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/971094e4-fcc6-425f-bd31-5e07939e33a2%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Apologies about the delay in response. But I did some more testing and have identified what scenario I’m in (not that I understand why) I was unable to print to the console. I was running ‘bokeh serve /foldername/’ trying to structure it like an app rather than ‘bokeh serve /foldername/app.py’. When I run it with the later the print statement does output to the console but it also makes the callback function associated with the button not write to the database, but if I remove the print statement the callback function writes to the database without any issue. Any idea why you can’t have both in the same function. Doesn’t matter where I put the print statement in the function, it will execute but won’t apply the changes to the database.

So the short of it is the print statement seems to break writing to my sql database and doesn’t display anything on the console when run as an application (I realise this is probably by design and I’m overlooking something with how an application folder functions in bokeh) rather than a specific script.

I’m also running the platform on Debian with kernel 3.16.4-4-amd64.

import string

import pandas as pd

from bokeh.plotting import Figure

from bokeh.models import ColumnDataSource, TextInput, Button, Panel, Tabs, Label, DataTable, TableColumn, StringEditor

from bokeh.layouts import Row, Column, widgetbox

from bokeh.io import curdoc, show, output_notebook, gridplot

from sqlalchemy import create_engine

from models.Data_Import import Import_Statements

connection string adjusted to reflect structure only for this post

engine = create_engine(‘postgresql+psycopg2://user:[email protected]:5432/Test_app’)

def retreive_categories():

df = pd.read_sql(sql=‘SELECT DISTINCT category from public.“Description_Categories” WHERE category<>‘Unknown’’, con=engine)

if len(df) == 0:

return

return list(df[‘category’].unique())

def retreive_desc_cat():

df = pd.read_sql(sql=‘SELECT description, category from public.“Description_Categories” WHERE category=‘Unknown’’, con=engine)

cds = ColumnDataSource(df)

cds.remove(‘index’)

columns = [TableColumn(field=‘description’, title=‘Description’),TableColumn(field=‘category’, title=‘Category’, editor=StringEditor(completions=retreive_categories()))]

tab_desc_cat = DataTable(source=cds, columns=columns, editable=True)

return tab_desc_cat

def cb_update_category():

conn = engine.connect()

df = category_update.source.to_df()

df_write = df[df[‘category’] != “Unknown”]

for r in df_write.iterrows():

sql_comm = ‘’‘UPDATE public.“Description_Categories” SET category = %s WHERE description = %s’’’

conn.execute(sql_comm, (string.capwords(r[1][0]),r[1][1]))

conn.close()

new_data = df[df[‘category’] == ‘Unknown’]

category_update.source.data = {‘description’: new_data[‘description’], ‘category’: new_data[‘category’]}

print(“Applying Updates to DB”)

category_update = retreive_desc_cat()

apply_button = Button(label=“Apply Changes”)

apply_button.on_click(cb_update_category)

tab1 = Panel(child=Column(apply_button,category_update), title=‘Category Updates’)

layout = Tabs(tabs=[tab1])

curdoc().add_root(layout)

Hi Bryan,

The below code snippet does NOT print CLICK!

This is making server callbacks extremely hard to debug…

Bokeh 0.12.6

···

On Tuesday, May 2, 2017 at 12:08:45 AM UTC-7, Bryan Van de ven wrote:

Can you confirm that this code:

    # test.py

    from [bokeh.io](http://bokeh.io) import curdoc
    from bokeh.models import Button
    b = Button()
    b.on_click(lambda: print("CLICK!"))
    curdoc().add_root(b)

run with

    bokeh serve --show test.py

does not print “CLICK!” for you when the button is pressed? If not, please provide more information about your platform. On OSX, I cannot reproduce any issue. This code prints “CLICK!” on every button press (as expected).

Thanks,

Bryan

On May 1, 2017, at 13:08, [email protected] wrote:

I have an bokeh application I’m trying to build that imports bank statements and allows updating and viewing of that information via a DataTable. But currently there is a module I have built and execute in a function of the script I run with bokeh serve that won’t execute but if i run that same script in a notebook and adjust the call to display it the function executes just fine.

I have the following versions of the main libraries I’m using:

Python = 3.4.2

Bokeh = 0.12.5

sqlalchemy = 1.1.9

The function I’m calling on looks like this with the import of my own module:


from models.Data_Import import Import_Statements

def cb_import_statements():

Import_Statements().import_statements()

cb_import_statements()


I can even try executing the Import_Statements().import_statements() on it’s own and it won’t execute. I also confirmed the function itself is called if I put another line to execute inside the function. This is supposed to execute at time of running the bokeh server and when a button is clicked.

Now while my dilemma is that it’s not running, the bigger issue is I get no errors outputted to the bokeh server console. Even when I do a print function I don’t see anything on the bokeh server console. What is the best way to troubleshoot something like this when the bokeh server is running?


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/971094e4-fcc6-425f-bd31-5e07939e33a2%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

Well, just triple checking that at the command line, you ran:

  bokeh server --show test.py

And then in the the browser page of the app, you clicked the button?

And specifically, you did NOT run simply:

  python test.py

Bokeh server scripts are not normal python scripts, they have to be run with "bokeh serve" and not "python". I don't mean to belabor this point but it's recently been a point of confusion for some people.

If it is the case that you ran with "bokeh serve" and then clicked the button, and then nothing printed, then it would seem you have found some kind of bug. I can't reproduce any problem with the code below, so please make a GitHub issue with as much information as possible to try and reproduce this (versions, OS, browser, platform, etc)

Thanks,

Bryan

···

On Jun 26, 2017, at 20:36, [email protected] wrote:

Hi Bryan,

The below code snippet does NOT print CLICK!

This is making server callbacks extremely hard to debug...

Bokeh 0.12.6

On Tuesday, May 2, 2017 at 12:08:45 AM UTC-7, Bryan Van de ven wrote:
Can you confirm that this code:

        # test.py
        from bokeh.io import curdoc
        from bokeh.models import Button
        b = Button()
        b.on_click(lambda: print("CLICK!"))
        curdoc().add_root(b)

run with

        bokeh serve --show test.py

does not print "CLICK!" for you when the button is pressed? If not, please provide more information about your platform. On OSX, I cannot reproduce any issue. This code prints "CLICK!" on every button press (as expected).

Thanks,

Bryan

> On May 1, 2017, at 13:08, [email protected] wrote:
>
> I have an bokeh application I'm trying to build that imports bank statements and allows updating and viewing of that information via a DataTable. But currently there is a module I have built and execute in a function of the script I run with bokeh serve that won't execute but if i run that same script in a notebook and adjust the call to display it the function executes just fine.
>
> I have the following versions of the main libraries I'm using:
>
> Python = 3.4.2
> Bokeh = 0.12.5
> sqlalchemy = 1.1.9
>
> The function I'm calling on looks like this with the import of my own module:
> -------------------------------------
>
> from models.Data_Import import Import_Statements
>
> def cb_import_statements():
> Import_Statements().import_statements()
>
> cb_import_statements()
>
>
> ----------------------------------
> I can even try executing the Import_Statements().import_statements() on it's own and it won't execute. I also confirmed the function itself is called if I put another line to execute inside the function. This is supposed to execute at time of running the bokeh server and when a button is clicked.
>
> Now while my dilemma is that it's not running, the bigger issue is I get no errors outputted to the bokeh server console. Even when I do a print function I don't see anything on the bokeh server console. What is the best way to troubleshoot something like this when the bokeh server is running?
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/971094e4-fcc6-425f-bd31-5e07939e33a2%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/dd9b9f3a-c706-416a-b8ad-93960b24fdda%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hey Bryan,

I figured out the issue. I was using git bash (Git for Windows) which for some reason doesn’t register printing to terminal with bokeh serve command?

Works completely fine with cmd.exe; also works perfect on my linux box too.

I can still submit an issue on GitHub for that if you see that as a valid bug report?

Bests,

–Michael

···

On Monday, June 26, 2017 at 6:41:59 PM UTC-7, Bryan Van de ven wrote:

Hi,

Well, just triple checking that at the command line, you ran:

    bokeh server --show test.py

And then in the the browser page of the app, you clicked the button?

And specifically, you did NOT run simply:

    python test.py

Bokeh server scripts are not normal python scripts, they have to be run with “bokeh serve” and not “python”. I don’t mean to belabor this point but it’s recently been a point of confusion for some people.

If it is the case that you ran with “bokeh serve” and then clicked the button, and then nothing printed, then it would seem you have found some kind of bug. I can’t reproduce any problem with the code below, so please make a GitHub issue with as much information as possible to try and reproduce this (versions, OS, browser, platform, etc)

Thanks,

Bryan

On Jun 26, 2017, at 20:36, [email protected] wrote:

Hi Bryan,

The below code snippet does NOT print CLICK!

This is making server callbacks extremely hard to debug…

Bokeh 0.12.6

On Tuesday, May 2, 2017 at 12:08:45 AM UTC-7, Bryan Van de ven wrote:

Can you confirm that this code:

    # test.py
    from [bokeh.io](http://bokeh.io) import curdoc
    from bokeh.models import Button
    b = Button()
    b.on_click(lambda: print("CLICK!"))
    curdoc().add_root(b)

run with

    bokeh serve --show test.py

does not print “CLICK!” for you when the button is pressed? If not, please provide more information about your platform. On OSX, I cannot reproduce any issue. This code prints “CLICK!” on every button press (as expected).

Thanks,

Bryan

On May 1, 2017, at 13:08, [email protected]mail.com wrote:

I have an bokeh application I’m trying to build that imports bank statements and allows updating and viewing of that information via a DataTable. But currently there is a module I have built and execute in a function of the script I run with bokeh serve that won’t execute but if i run that same script in a notebook and adjust the call to display it the function executes just fine.

I have the following versions of the main libraries I’m using:

Python = 3.4.2
Bokeh = 0.12.5
sqlalchemy = 1.1.9

The function I’m calling on looks like this with the import of my own module:

from models.Data_Import import Import_Statements

def cb_import_statements():
Import_Statements().import_statements()

cb_import_statements()


I can even try executing the Import_Statements().import_statements() on it’s own and it won’t execute. I also confirmed the function itself is called if I put another line to execute inside the function. This is supposed to execute at time of running the bokeh server and when a button is clicked.

Now while my dilemma is that it’s not running, the bigger issue is I get no errors outputted to the bokeh server console. Even when I do a print function I don’t see anything on the bokeh server console. What is the best way to troubleshoot something like this when the bokeh server is running?


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/971094e4-fcc6-425f-bd31-5e07939e33a2%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/dd9b9f3a-c706-416a-b8ad-93960b24fdda%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

I'm glad you were able to track it down. Unless you suspect there is something we can do to help on our end, then A GH issue is not necessary.

Thanks,

Bryan

···

On Jun 27, 2017, at 00:31, [email protected] wrote:

Hey Bryan,

I figured out the issue. I was using git bash (Git for Windows) which for some reason doesn't register printing to terminal with bokeh serve command?

Works completely fine with cmd.exe; also works perfect on my linux box too.

I can still submit an issue on GitHub for that if you see that as a valid bug report?

Bests,
--Michael

On Monday, June 26, 2017 at 6:41:59 PM UTC-7, Bryan Van de ven wrote:
Hi,

Well, just triple checking that at the command line, you ran:

        bokeh server --show test.py

And then in the the browser page of the app, you clicked the button?

And specifically, you did NOT run simply:

        python test.py

Bokeh server scripts are not normal python scripts, they have to be run with "bokeh serve" and not "python". I don't mean to belabor this point but it's recently been a point of confusion for some people.

If it is the case that you ran with "bokeh serve" and then clicked the button, and then nothing printed, then it would seem you have found some kind of bug. I can't reproduce any problem with the code below, so please make a GitHub issue with as much information as possible to try and reproduce this (versions, OS, browser, platform, etc)

Thanks,

Bryan

> On Jun 26, 2017, at 20:36, [email protected] wrote:
>
> Hi Bryan,
>
>
> The below code snippet does NOT print CLICK!
>
> This is making server callbacks extremely hard to debug...
>
> Bokeh 0.12.6
>
>
> On Tuesday, May 2, 2017 at 12:08:45 AM UTC-7, Bryan Van de ven wrote:
> Can you confirm that this code:
>
> # test.py
> from bokeh.io import curdoc
> from bokeh.models import Button
> b = Button()
> b.on_click(lambda: print("CLICK!"))
> curdoc().add_root(b)
>
> run with
>
> bokeh serve --show test.py
>
> does not print "CLICK!" for you when the button is pressed? If not, please provide more information about your platform. On OSX, I cannot reproduce any issue. This code prints "CLICK!" on every button press (as expected).
>
> Thanks,
>
> Bryan
>
>
> > On May 1, 2017, at 13:08, [email protected] wrote:
> >
> > I have an bokeh application I'm trying to build that imports bank statements and allows updating and viewing of that information via a DataTable. But currently there is a module I have built and execute in a function of the script I run with bokeh serve that won't execute but if i run that same script in a notebook and adjust the call to display it the function executes just fine.
> >
> > I have the following versions of the main libraries I'm using:
> >
> > Python = 3.4.2
> > Bokeh = 0.12.5
> > sqlalchemy = 1.1.9
> >
> > The function I'm calling on looks like this with the import of my own module:
> > -------------------------------------
> >
> > from models.Data_Import import Import_Statements
> >
> > def cb_import_statements():
> > Import_Statements().import_statements()
> >
> > cb_import_statements()
> >
> >
> > ----------------------------------
> > I can even try executing the Import_Statements().import_statements() on it's own and it won't execute. I also confirmed the function itself is called if I put another line to execute inside the function. This is supposed to execute at time of running the bokeh server and when a button is clicked.
> >
> > Now while my dilemma is that it's not running, the bigger issue is I get no errors outputted to the bokeh server console. Even when I do a print function I don't see anything on the bokeh server console. What is the best way to troubleshoot something like this when the bokeh server is running?
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> > To post to this group, send email to [email protected].
> > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/971094e4-fcc6-425f-bd31-5e07939e33a2%40continuum.io.
> > For more options, visit https://groups.google.com/a/continuum.io/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/dd9b9f3a-c706-416a-b8ad-93960b24fdda%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/28be4b57-0ae0-4c07-842d-b6b347f4b0a0%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.