flatironinstitute / stan-playground

Run Stan models in the browser
Apache License 2.0
36 stars 1 forks source link

Prevent running of model with non-parseable data.json. #230

Closed jsoules closed 1 month ago

jsoules commented 1 month ago

Fix #226.

This PR makes the handleRun callback (defined in RunPanel.tsx and used as a parameter to the CompiledRunPanel component) nullable. The callback will be undefined if the data.json does not parse successfully.

In turn, in the CompiledRunPanel component, the Run Sampling button will be disabled if the handleRun parameter is undefined. This prevents a downstream error in model execution caused by the failed parse.

I've added a tooltip to the "Run sampling" button that explains to the user why it is disabled in the data-did-not-parse case, and describes the function in the success case. (I also covered the cases where the model is loading or sampling is already in progress.

jsoules commented 1 month ago

On further conversation with @WardBrian, it's desirable to allow an empty string in data.json. See updated PR.