-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add local folder support #13
Comments
@georgestagg Is this something that webr should do? I could imagine bundling all the files via base64 encoding and adding them to a shinylive editor, but I don't see a clear path when exporting the app to a folder (even if the files were copied). |
@schloerke Do both the shinylive editor case and the exporting to a folder case, both use app.json? If so, is it just the same? |
There is some internal overlap, but I'd look at them as separate processes |
I think this is something webR could handle, in that there are ways to make specific URLs or data files available in the Emscripten VFS though webR's JS API. We should ensure anything we do can be replicated in Python/Pyodide. Is there already a solution in place for accessing local files/directories in a Shinylive for Python app? |
Not that I'm aware of. From what I remember, most python driven development / testing was within a shinylive editor which can create files within the browser. Where many R users are already have their local apps and want to immediately export them, skipping the editor entirely. |
Currently, there are two use cases: Exported app and quarto app Exported appCurrent shallow dir structure
Questions:
So theoretical format:
... Might be better to put everything inside a folder to avoid collision...
Quarto AppThe quarto extension can attach dependencies via I have no problem auto uploading the www folder. Maybe due to the nature of it being public, we should only allow for the We'd need to get the mapping of what is here / local dir to an isolated app dependencies.. Ex map html dependency @georgestagg ... Can webr mount a url to here's file system within the R process. Both situations could be solved if we can do this. |
Yes, in principle Emscripten's FS.createLazyFile() can be used to do this so that when a certain file in the R process's virtual filesystem is read, the file is fetched from the network from a given URL. The URL must be CORS permitted. If we are using relative URLs I think it should always work. WebR does not yet expose For the moment manually creating the file from R works, by running the following inside the R session: webr::eval_js("
Module.FS.createLazyFile(
'/home/web_user',
'data.RData',
'https://raw.githubusercontent.com/topepo/shinylive-in-book-test/main/grid_pred.RData',
true, false
)
") Then again inside R, you can read > load("data.RData")
> ls()
[1] "grid_pred" If we do expose |
Thank you for the workarounds! |
To keep similar things co-located... @georgestagg , is there a similar incantation for |
In principle, I think something like this could work: from pyodide import code
code.run_js("""
pyodide.FS.createLazyFile(
'/home/pyodide',
'data.csv',
'https://media.githubusercontent.com/media/datablist/sample-csv-files/main/files/people/people-100.csv',
true, false
)
""") But, I can't see an easy way to get to the
|
Proposals
This should resolve both approaches.
All files can be read and can not be overwritten / deleted. Export app
Shinylive ext
|
Update For exporting an app, this should already work. The files in the app's folder will automatically be included in The difficulty comes in the quarto document. The quarto document has access to the file system, so we should be able to add the folders via a This could be done in https://github.com/posit-dev/shinylive/blob/0cd59dce79a5c980943bba1c8a4af208e462f67b/src/parse-codeblock.ts#L95 and it could add the file results to |
So users can load data from folders!
Maybe it could be done through a yaml comment?
Ex:
The text was updated successfully, but these errors were encountered: