Search code examples
python-3.xpython-3.10ubuntu-22.04taipy

Empty session id on taipy-gui


I run the following code on a ubuntu-22.04 with python3.10 and taipy 2.0:

from taipy.gui import Gui
from math import cos, exp 

page = """
#This is **Taipy** GUI 

A value: <|{decay}|>.

A slider: <br/>
<|{decay}|slider|>

My chart: 
<|{data}|chart|>
"""

def compute_data(decay):
    return [cos(i/16) * exp(-i*decay/6000) for i in range(720)]

def on_change(state, var_name, var_value):
    if var_name == 'decay':
        state.data = compute_data(var_value)

decay = 10
data = compute_data(decay) 

Gui(page=page).run(title='Taipy Demo GUI', dark_mode=False)

But I get the following warning:

UserWarning: Empty session id, using global scope instead
  warnings.warn("Empty session id, using global scope instead")

What can I do about it?


Solution

  • This warning is generated by Taipy GUI. It occurs when you connect to your Web application for the first time using your Web browser, or if the Web browser cache has been cleared.

    Taipy has been designed with multi-user support in mind. It creates a new session for you with initialized values (from the Global Scope) when you connect to your application on another machine for example. Here, decay=10 in your slider even if you changed it in another session.

    You can suppress it using the warnings module in Python. Add the following lines at the beginning of your code:

    import warnings
    
    # Filter the specific UserWarning
    warnings.filterwarnings("ignore", message="Empty session id, using global scope instead")