Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Fix reloading issues of the AG Grid #446

Merged
merged 18 commits into from May 13, 2024

Conversation

maxschulz-COL
Copy link
Contributor

@maxschulz-COL maxschulz-COL commented Apr 30, 2024

Description

This PR closes the following issues:

After some investigation, it looks like there is some confirmed buggy behaviour:

  • column size arguments not consistently rendering on page refresh or change (e.g. a user providing columnSize="autoSize" will not see his results consistently)
  • AG Grid filter persistence not working properly on page refresh

The identified two underlying reasons are:

  • not providing the full DF in the initial build method of the AG Grid (again, similar topic that https://github.com/McK-Internal/vizro-internal/issues/747 adresses)
  • providing defaults to the _dash_ag_grid functions that concern columns settings that could potentially conflict with user chosen values such as columnSize="autoSize"

It has to be noted that this behaviour is not always easy to investigate, as there are many moving pieces etc. This PR presents to options for investigation:

  • app.py - Vizro app setup to investigate different options.
  • app2.py (will be deleted later) Pure Dash App to test what "bugs" carry over

Proposed solution

Those two changes fix all observed problems for me. This is the current status of the code, and it would be good if reviewers could test out if the see the same with the various settings possible.

How to review

Run hatch run example and test the various options proposed in app.py. Particular focus should be on:

  • if I choose a column setting as a user, is that always reflected on screen, even after page change, and page refresh
  • same for persistence settings

app2.py and the additional files under pages is just there in case we want to try out things in a pure Dash app. I will delete once we agree on a solution.

Screenshot

Notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

    • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.
    • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorized to submit this contribution on behalf of the original creator(s) or their licensees.
    • I certify that the use of this contribution as authorized by the Apache 2.0 license does not violate the intellectual property rights of anyone else.
    • I have not referenced individuals, products or companies in any commits, directly or indirectly.
    • I have not added data or restricted code in any commits, directly or indirectly.

@maxschulz-COL maxschulz-COL marked this pull request as ready for review April 30, 2024 09:34
@maxschulz-COL maxschulz-COL added Status: Ready for Review ☑️ Issue/PR is ready for review - all tests have passed Issue: Bug Report 🐛 Issue/PR that report/fix a bug labels Apr 30, 2024
@huong-li-nguyen huong-li-nguyen changed the title [Bug] Fixing reloading issues of the AG Grid [Bug] Fix reloading issues of the AG Grid May 7, 2024
@petar-qb petar-qb self-requested a review May 7, 2024 11:31
Copy link
Contributor

@petar-qb petar-qb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxschulz-COL thank you for all your work on this PR. I know how hard it was to test all the cases and options and to find what was causing the persistence issues.

By returning the original data_frame fromfigure.build and with other changes (like the default dash_ag_grid configuration) you really solved all the mentioned issues.

I tried to find any inconsistency by altering arguments such as: persistence, persistence_type, persisted_props, columnSize and defaultColDef and found that the problem with the filterModel disappeared completely.

However columnSize doesn't work if configured in combination withsomething like defaultColDef={"flex": 1, "minWidth": 200},. This is really an edge case where the user can expect that the column size is auto-sized but that the width is never lower than 200. Also, if columnSize="autoSize" is set in the combination with persisted_props=["columnSize"], "autoSize" doesn't work at all. This seems strange to me since, columnSize and filerModel should behave same since they are both dag.AgGrid properties.

I would go with this solution (hence the approval from my side), but we should also create a new ticket to optimise the page load process since it doesn't seem like a perfect solution to return the original data_frame from figure.build and to overwrite it immediately afterwards with on-page-load.

@antonymilne
Copy link
Contributor

FYI @petar-qb since you were away at the time, just for reference see my comment here: #439 (review).

@maxschulz-COL
Copy link
Contributor Author

However columnSize doesn't work if configured in combination with something like defaultColDef={"flex": 1, "minWidth": 200},. This is really an edge case where the user can expect that the column size is auto-sized but that the width is never lower than 200. Also, if columnSize="autoSize" is set in the combination with persisted_props=["columnSize"], "autoSize" doesn't work at all. This seems strange to me since, columnSize and filerModel should behave same since they are both dag.AgGrid properties.

@petar-qb If I understand it correctly, you are essentially referring to user created AgGrid inconsistencies right? My point above was that if a user configures "contradicting" options, then it is ok that it fails, as long as hidden defaults are not the cause of it.

If this is what you also meant, then let's go with the proposed solution indeed. Any user question we can refer to the Dash AG Grid, because we are not altering that implementation in any way and thus the answer can only lie there.

@petar-qb
Copy link
Contributor

If I understand it correctly, you are essentially referring to user created AgGrid inconsistencies right? My point above was that if a user configures "contradicting" options, then it is ok that it fails, as long as hidden defaults are not the cause of it.

If this is what you also meant, then let's go with the proposed solution indeed.

I totally agree, and as I said: I would go with this solution (hence the approval from my side) 😄

@antonymilne antonymilne merged commit bfb31cd into main May 13, 2024
34 checks passed
@antonymilne antonymilne deleted the bug/ag_grid_default_resetting_670 branch May 13, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Bug Report 🐛 Issue/PR that report/fix a bug Status: Ready for Review ☑️ Issue/PR is ready for review - all tests have passed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants