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

Allow scripts to be cancelable #274

Merged
merged 5 commits into from
Feb 12, 2025
Merged

Allow scripts to be cancelable #274

merged 5 commits into from
Feb 12, 2025

Conversation

WardBrian
Copy link
Collaborator

Closes #224.

This requires certain CORS settings. I've set it up so that the site should gracefully degrade when they are not set, this can be tested by commenting out the changes to the vite config during a vite dev run (might need to clear cache between changes)

@WardBrian WardBrian linked an issue Feb 7, 2025 that may be closed by this pull request
@WardBrian WardBrian requested a review from jsoules February 10, 2025 17:33
Copy link
Collaborator

@jsoules jsoules left a comment

Choose a reason for hiding this comment

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

Couple comments/questions.

I've noted two issues in running locally. First, canceling during pyodide initialization--specifically while loading modules--doesn't always exit cleanly; my first time out the gate I wound up with something half-loaded leading to a broken import on subsequent runs that could only be fixed by refreshing the page.

Second, I'm not sure if it's related to present changes or not, but I'm seeing situations where the "Run Sampling" button goes to a disabled state and the compiled stan program never loads. I'm not seeing anything in console about it and I'm not sure I can reproduce it super consistently--just refreshed and it's still going on with the stock linear regression model while connected to the public compile server...

gui/src/app/core/Scripting/webR/useWebR.ts Show resolved Hide resolved
gui/src/app/core/Scripting/webR/useWebR.ts Show resolved Hide resolved
Comment on lines +46 to +48
console.warn(
"SharedArrayBuffer is not available, interrupting the Pyodide worker will not work",
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like this message isn't quite right--as I understand you can still interrupt it, you're just killing the worker (and will have to reload pyodide in that case)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, I guess you can no longer cancel the R scripts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, though whether or not we even should provide this worker-killing fallback is an open question to me. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Eh, I don't mind it--if you're stuck in an infinite loop, or something just takes much longer than anticipated, it's nice to be able to terminate what's happening. Even if it means you have to start over next time.

@WardBrian
Copy link
Collaborator Author

Second, I'm not sure if it's related to present changes or not, but I'm seeing situations where the "Run Sampling" button goes to a disabled state and the compiled stan program never loads. I'm not seeing anything in console about it and I'm not sure I can reproduce it super consistently--just refreshed and it's still going on with the stock linear regression model while connected to the public compile server...

I have experienced this a couple times. It occurs to me that after #257, the same model is always being served from a certain URL, which means the browser wants to cache it, but I think something weird happens when the server gets updated/restarts?

Asking firefox to forget https://stan-wasm.flatironinstitute.org/ has generally fixed this for me, but obviously thats far from ideal for users. Not sure what our options are

@WardBrian
Copy link
Collaborator Author

First, canceling during pyodide initialization--specifically while loading modules--doesn't always exit cleanly; my first time out the gate I wound up with something half-loaded leading to a broken import on subsequent runs that could only be fixed by refreshing the page.

The easiest fix is just to restrict when the cancel is available to only during the "running" status. For the kill-the-worker version of cancel(), this is an over-restriction, but for normal interrupts I think interrupting the installation will only ever cause problems.

Copy link
Collaborator

@jsoules jsoules left a comment

Choose a reason for hiding this comment

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

I think this is in good shape. Feel free to merge.

@WardBrian WardBrian merged commit 1abf138 into main Feb 12, 2025
2 checks passed
@WardBrian WardBrian deleted the cancellable-scripts branch February 12, 2025 20:35
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.

Cancellable scripts
2 participants