Avaiga / taipy

Turns Data and AI algorithms into production-ready web applications in no time.
https://www.taipy.io
Apache License 2.0
10.94k stars 775 forks source link

BUG- Dataframe not refreshing properly #682

Open FlorianJacta opened 7 months ago

FlorianJacta commented 7 months ago

Description The behavior between a local run and a run done with Docker and Gevent is different. In this example, the table is not updated properly. Refreshing the page solves the refresh of the page. invoke_long_callback is used so the code should work.

How to reproduce app.py

from taipy import Gui
import pandas as pd
import time
from taipy.gui import(
    Markdown,
    notify,
    get_state_id,
    invoke_long_callback,
)

calculate_label = "Calc"
calculate_label_active = True
df = pd.DataFrame({"V": [21], "W": [22], "X": [23],"Y": [24],"Z": [25]})

def calculate_action(state):
    state.calculate_label = "0"
    state.df = pd.DataFrame({"V": [21], "W": [22], "X": [23],"Y": [24],"Z": [25]})

    invoke_long_callback(state,
        user_function=do_calculate,
        user_function_args=[get_state_id(state)],
        user_status_function=get_status_calculate,
        period=1000)

def get_status_calculate(state, status, result):
    if isinstance(status, bool):
        if status:
            notify(state, "success", "Heavy set function finished!")
            state.df = result

            state.calculate_label = "Calc"
        else:
            notify(state, "error", "Something went wrong")

    else:
        state.calculate_label = str(int(state.calculate_label)+1)

def do_calculate(state_id):
    time.sleep(15)
    df_old = pd.DataFrame({"A": [1], "B": [2], "C": [3], "D": [4], "E": [5]})
    df_new = pd.DataFrame({"A": [12], "B": [14], "C": [16], "D": [18], "E": [20]})
    try:
        df_result = df_new.subtract(df_old, fill_value=0)
    except Exception as ex:
        raise ex

    return df_result

calc_md = Markdown(
    """
<|{calculate_label}|button|on_action=calculate_action|active={calculate_label_active}|>

<|{df}|table|>
"""
)

pages = {"Calculate": calc_md}

if __name__=="__main__":
    port = 8080
    Gui(pages=pages).run(title="Test", dark_mode=True, port=port, host="0.0.0.0")

else:
    app = Gui(pages=pages).run(title="Test", dark_mode=True, run_server=False)

docker-compose.yml

version: "3.9"
services:
  taipy:
    build: ""
    ports:
       - "8080:8080"

Dockerfile

FROM python:3.9-slim
RUN apt update
RUN apt upgrade -y
RUN pip uninstall setuptools --yes

EXPOSE 8080

RUN groupadd -r userr && useradd -r -m -g userr userr
RUN chown -R userr:userr /home/
USER userr

ENV PATH="${PATH}:/home/userr/.local/bin"

WORKDIR /home

ADD ./requirements.txt /home/requirements.txt
ADD ./app.py /home/app.py

RUN pip install --upgrade pip

RUN pip install -r requirements.txt

RUN pip install gunicorn gevent-websocket

ENTRYPOINT ["gunicorn", "-k", "geventwebsocket.gunicorn.workers.GeventWebSocketWorker", "-w", "1", "--threads", "3", "--bind=0.0.0.0:8080", "--timeout", "1800", "--keep-alive", "1800"]
CMD ["app:app"]

requirements.txt

taipy

Expected behavior

The behavior should be the same.

Runtime environment Please specify relevant indications.

Acceptance Criteria

dinhlongviolin1 commented 5 months ago

I tried to replicate the issue on both local and docker. The provided code does not work on both environment. I suspect that this is not an environment issue but a dataframe reload issue.

dinhlongviolin1 commented 5 months ago

Related to #1054

FredLL-Avaiga commented 5 months ago

not related to #1054 (which is a regression that appeared after 3.1)

FredLL-Avaiga commented 5 months ago

@FlorianJacta can you confirm that your issue is still present in develop ?

FlorianJacta commented 5 months ago

When I run the code in the develop version locally, it works.

FlorianJacta commented 5 months ago

I tested it with Docker on 3.1, and it doesn't work. I have the same issue

The behavior between a local run and a run done with Docker and Gevent is different. In this example, the table is not updated properly. Refreshing the page solves the refresh of the page. invoke_long_callback is used so the code should work.

jrobinAV commented 3 months ago

Up

github-actions[bot] commented 3 months ago

This issue has been labelled as "🥶Waiting for contributor" because it has been inactive for more than 14 days. If you would like to continue working on this issue, please add another comment or create a PR that links to this issue. If a PR has already been created which refers to this issue, then you should explicitly mention this issue in the relevant PR. Otherwise, you will be unassigned in 14 days. For more information please refer to the contributing guidelines.

github-actions[bot] commented 2 months ago

This issue has been unassigned automatically because it has been marked as "🥶Waiting for contributor" for more than 14 days with no activity.

github-actions[bot] commented 1 month ago

This issue has been labelled as "🥶Waiting for contributor" because it has been inactive for more than 14 days. If you would like to continue working on this issue, please add another comment or create a PR that links to this issue. If a PR has already been created which refers to this issue, then you should explicitly mention this issue in the relevant PR. Otherwise, you will be unassigned in 14 days. For more information please refer to the contributing guidelines.

github-actions[bot] commented 1 month ago

This issue has been unassigned automatically because it has been marked as "🥶Waiting for contributor" for more than 14 days with no activity.

dinhlongviolin1 commented 1 month ago

@FlorianJacta I did tested it again with Fred using the develop branch. Please help me retest it on your side. I did change 2 things.

FlorianJacta commented 2 weeks ago

I tried but there are problems with Taipy dependencies. I will try again when this is fixed

taipy-1  |   File "/home/userr/.local/lib/python3.9/site-packages/taipy/config/_config_comparator/_config_comparator.py", line 16, in <module>
taipy-1  |     from deepdiff import DeepDiff
taipy-1  | ModuleNotFoundError: No module named 'deepdiff'

It seems to be related to https://github.com/Avaiga/taipy/issues/1668

dinhlongviolin1 commented 2 weeks ago

@FlorianJacta You can try again with the commit on Taipy.

pip install "taipy@git+https://git@github.com/Avaiga/taipy.git@b126c80726e814aff219ecd8456dd4378f36b270"

dinhlongviolin1 commented 2 weeks ago

equivalent to this inside requirements.txt taipy @ git+https://github.com/Avaiga/taipy.git@b126c80726e814aff219ecd8456dd4378f36b270#egg=taipy

FlorianJacta commented 2 weeks ago

How did you change the Dockerfile?

The installation of Taipy was not successful as I don't have node/npm installed in the dockerfile. I have tried to install it but this leads to another error.

github-actions[bot] commented 3 days ago

This issue has been labelled as "🥶Waiting for contributor" because it has been inactive for more than 14 days. If you would like to continue working on this issue, please add another comment or create a PR that links to this issue. If a PR has already been created which refers to this issue, then you should explicitly mention this issue in the relevant PR. Otherwise, you will be unassigned in 14 days. For more information please refer to the contributing guidelines.