mljar / mercury

Convert Jupyter Notebooks to Web Apps
https://RunMercury.com
GNU Affero General Public License v3.0
3.93k stars 250 forks source link

Dashboard is not updating the `Select` value changes when the sidebar does #383

Open ranggakd opened 10 months ago

ranggakd commented 10 months ago

I'm having a problem with the Select widget value that is not updating in the dashboard but it's updated in the sidebar.

I'm working with I believe Tex or KeTeX syntax. For example, take a look at these choices:

# dataset branching
dataset_mapping = {
    'Number Nature': {
        'Non-zero Real Numbers':{
            '$10 \cdot \cos(x) + 1$':{
                ('AutoReg', 'OffsetModel 1%'): 1
            },
            '$10 \cdot \sin(x) + 1$':{
                ('AutoReg', 'OffsetModel 1%'): 2
            }
        },
        'Real Numbers with Zeros':{ #TODO
            '$\\text{ int }(10 \cdot \cos(x))$':{
                ('AutoReg', 'OffsetModel 1%'): 1
            },
            '$\\text{ int }(10 \cdot \sin(x))$':{
                ('AutoReg', 'OffsetModel 1%'): 2
            }
        }
    }
}

When we navigate to Number Nature->Non-zero Real Numbers->$10 \cdot \cos(x) + 1$ or $10 \cdot \sin(x) + 1$ it will update both the sidebar and the dashboard but it is a different outcome when it comes to Number Nature->Real Numbers with Zeros->$\\text{ int }(10 \cdot \cos(x))$ or $\\text{ int }(10 \cdot \sin(x))$

The problem only occurred when I encountered \\ in the string of choices like Real Numbers with Zeros, Very Small Numbers, Very Large Numbers, Magnitude and Sigmoidal/Logistic Trend. Other than that it will work out just fine.

I provide my Notebook Gist for reproducible bugs. Go to the dataset_mapping for inquiry and look at how the same syntax is working just fine in the native markdown below it (summary part).

mercury_select_bugs

pplonski commented 10 months ago

Hi @ranggakd,

Thank you for reporting the issue. Your bug description is very good, we rarely get such good descriptions with steps and code for bug reproduction :+1: :1st_place_medal:

I will try to look into it in the next week, we are between conferences and presentations are still not ready ...

ranggakd commented 10 months ago

I'm letting you know now the other way to make it work as I did was to prevent the Python reserved characters like \t and \f. I escaped them by prefixing them with another \ so they turn to be \\t or \\f for \\times, \\text and \\frac.

The best I can do right now that worked are:

  1. Change \\times into \cdot when it actually means the same thing which is multiplication.
  2. Reduce \\text as many as possible.
  3. Change \\frac with the old syntax of \over for creating fractions.