Skip to content

Update apps for element filtering#577

Draft
ElliottKasoar wants to merge 14 commits into
ddmms:mainfrom
ElliottKasoar:add-app-filter
Draft

Update apps for element filtering#577
ElliottKasoar wants to merge 14 commits into
ddmms:mainfrom
ElliottKasoar:add-app-filter

Conversation

@ElliottKasoar
Copy link
Copy Markdown
Collaborator

Pre-review checklist for PR author

PR author must check the checkboxes below when creating the PR.

Summary

Continuation of #559.

This introduces the app changes needed to actually apply the element filter. This needs to be generalised and added to all apps. X23/DMC_ICE are a little out of date currently, and testing won't work until the analysis is updated and re-run.

@ElliottKasoar ElliottKasoar added the enhancement New feature or request label May 29, 2026
@joehart2001
Copy link
Copy Markdown
Collaborator

whats the curernt plan for this and #578 ?

@ElliottKasoar
Copy link
Copy Markdown
Collaborator Author

ElliottKasoar commented May 31, 2026

whats the curernt plan for this and #578?

If you ignore the changes to DMC_ICE/X23 apps (which were starting points for the full filtering), the main change each app needs is what's in app_si_defects.py, so actually very minimal. There should only really be two forms of set_elements, one where there's a single list, and one where there's a list of lists of elements.

So if you take a look at the NEB app changes + backend changes, and see what you think? I can work through the other app changes reasonably quickly.

#578 is where the bulk of the work is left, since we need to save the info.json that the apps read. I've basically written two forms of helper corresponding to the two forms of set_elements, but could use your help to go through the remaining analyses and adding these in.

It's not conceptually that difficult, but often not entirely trivial either. Most of the ones I've changed and pushed work, but a couple e.g. CPOSS209 aren't quite working yet, but the idea should be reasonably clear.

Comment thread ml_peg/app/base_app.py
"""Register callbacks with app."""
pass

def filter_table(self, filter_elements: list[str] | None) -> dict[str, dict]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i think this funciton mutating self.table.data is dangerous for the hosted app with multiple users. i think we should build from deepcopy(self.original_table.data)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hmm yes I think you're right, thanks, I'll fix this soon

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we should also be careful if theres anything else that could have a similar effect, as its less strightforward to spot when we test locally

Copy link
Copy Markdown
Collaborator Author

@ElliottKasoar ElliottKasoar Jun 3, 2026

Choose a reason for hiding this comment

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

Actually I don't think we have a problem with self.original_table.data. We only access specific floats from it, which are immutable, so it shouldn't be changed in this process. If it was, when we applied the filter, wouldn't the metrics all be set to None, and so we'd be unable to unfilter?

Still looking into self.table.data. I get the point, but surely we ultimately do change it through callbacks anyway? We set the user specific store first, but this is still propagated to the table data itself, and that's fine?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the callbacks are all user-side (client DOM) so theres no issue with those, but self.table.data is server side so its shared. i think its an issue as self.table.data is used for the initial render, so when its edited, later users will not all load the same app. if we build from teh deepcopy then we dont touch the original

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

like self.table.data is a python object on the server than exists once, so editing this will edit for any other users

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oh true, sorry yep, I forgot self.tables aren't the same as the DataTables we modify

Comment thread ml_peg/app/nebs/li_diffusion/app_li_diffusion.py Outdated
app = entry["app"]
outputs.extend(
[
Output(f"{app.table_id}-computed-store", "data"),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

allow duplicate needed here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants