flatironinstitute / stan-playground

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

Make data.json available in analysis scripts #238

Closed WardBrian closed 3 weeks ago

WardBrian commented 3 weeks ago

It is often useful to analyze the results in the context of the data. The example we provide for the SIR model already does this by re-installing the package the data came from, but a more general solution would be to have the data.json available in the script. This style would also compose well with #179

We can do this with virtual file systems:

jsoules commented 3 weeks ago

Would moving to virtual file systems suggest that we should also revise the state model for those files in the reducer? Instead of keeping 2 copies in memory?

WardBrian commented 3 weeks ago

This would be something which is local to the runtime environment set-up for the scripts (e.g., inside the pyodide worker).

It arguably would be the wrong thing to do to unify this with the state model, since we explicitly would not want edits in the data to be visible in the analysis script if the sampler isn't re-run first

magland commented 3 weeks ago

Why not make it available as a data variable, as in the data generation scripts? Maybe I'm missing exactly what you are proposing.

WardBrian commented 3 weeks ago

We could try. I think that solution would require more work, for ultimately not much gain.

  1. We'd have to decide how to parse it into an R/Python object. If the user wanted something else, they're going to have to write more code anyway. If it's a lot of data, parsing it when they don't need it would also be a bummer
  2. The next feature I'm working on is #179, and the less 'magic' we have the better. The user loading it from ./data.json would mirror exactly what they'd do when running locally.
magland commented 3 weeks ago

Okay makes sense.