-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Conversation
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃 🚀
💯 |
Fix #2863
Fixes for cases where the given id has a
MATCH
,ALL
,ALLSMALLER
wildcard in callbackrunning
argument, progress for background callbacks andset_props
.