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

Fix pattern matching in side updates (running/progress/set_props) #2876

Merged
merged 9 commits into from
Jun 12, 2024

Conversation

T4rk1n
Copy link
Contributor

@T4rk1n T4rk1n commented Jun 5, 2024

Fix #2863

Fixes for cases where the given id has a MATCH, ALL, ALLSMALLER wildcard in callback running argument, progress for background callbacks and set_props.

@T4rk1n T4rk1n changed the title [WIP] Fix pattern matching in side updates (running/progress/set_props) Fix pattern matching in side updates (running/progress/set_props) Jun 6, 2024
@T4rk1n T4rk1n requested review from emilykl, AnnMarieW and gvwilson June 6, 2024 15:46
Copy link
Contributor

@gvwilson gvwilson left a comment

Choose a reason for hiding this comment

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

thank you

toPairs(outputs).forEach(([id, value]) => {
let componentId = id,
propName;
function parsePMCId(id: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a lot of magic numbers in this function (+2, +1) -- could you add a comment explaining some of the string manipulations here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just the indexes of the strings, I think it's pretty readable if you know the format:
{"key":"value"}.propName or just the dictionary, so index refers to position of }, if the index + 2 < id.length means there is more data after the index and ., the propname starts at index + 2 and componentId is 0 to index + 1.

Copy link
Contributor

Choose a reason for hiding this comment

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

got it, that makes sense, thanks! Could you add that format as a comment in the code?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks duplicative of:

export function splitIdAndProp(idAndProp) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This handle case where the prop name is not attached to the key, which comes with set_props so it searches for } instead of a dot.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK - can we at least put these in the same location - maybe move them both to a new file so it's easier to find them and we avoid making any more of them?

My main concern with doing this in slightly different ways is accidentally introducing additional constraints on what constitutes a valid ID, and/or causing an error with certain IDs. I think your logic here is OK, as you only get to searching for } after you already know the ID starts with { which is an invalid character for string IDs - but that's something we need to check carefully every time we modify the ID handling code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for putting the new function in a new file. The existing function is still in its old location though, so at some point please let's bring that one into the new file too.

prevent_initial_call=True,
)
def on_click(_) -> str:
time.sleep(1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we do this with a lock instead of a delay?

@T4rk1n
Copy link
Contributor Author

T4rk1n commented Jun 10, 2024

I notice the running is not available/working with clientside callbacks, it could be working with a bit of refactor and I think could be useful when the clientside callback returns a promise.

Copy link
Member

@ndrezn ndrezn left a comment

Choose a reason for hiding this comment

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

💃 🚀

@T4rk1n T4rk1n merged commit efb9d32 into dev Jun 12, 2024
3 checks passed
@T4rk1n T4rk1n deleted the fix/pmc-side-updates branch June 12, 2024 13:04
@gvwilson
Copy link
Contributor

💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] running does not support wildcards in ids
5 participants