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

How to reference / access data resources from a cell #53

Closed
Analect opened this issue Aug 29, 2024 · 2 comments
Closed

How to reference / access data resources from a cell #53

Analect opened this issue Aug 29, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Analect
Copy link

Analect commented Aug 29, 2024

Thanks for your efforts with this tooling.

I was playing around with generating some additional meta-data from a rendered quarto site. Per the resources setting in the _quarto.yml file here, I'm able to ensure my data is available in the rendered docs.

Then, for this *.qmd file, I'm passing through those resources. I'm not sure the second resources under pyodide is strictly necessary.

format: live-html
resources:
  - "../../data/"
pyodide:
  resources:
    - "../../data/"

It's unclear how I should reference that data folder. Is it relative to where my *.qmd file sits relative to the root of the quarto directory. This is why I use ../../data, as my file sits in <root>/docs/demo. This relative location in gh-pages artifacts is the same. I have played around with this, but to no avail. I notice that if I include these resource references, then the rendered document somehow doesn't resolve. If I remove them, it at least resolves, although I'm not able to access the data from a cell.

The other thing of note is that the data folder is empty on the main branch. It only gets populated as part of a pre-render script.

Could you offer some guidance on how I should be doing this correctly? Should the data folder then be accessible within a pyodide cell under some web_user folder? Would be great to get a better understanding of how this works. Thanks.

@georgestagg
Copy link
Member

Hi @Analect, thanks for reporting this! There were some bugs in the way the virtual filesystems structure was built as the WebAssembly engine loads. Sorry about that! I've made some commits to try and correct the problems.


The way this is supposed to work is that when written to the Wasm filesystem, the parent subdirectory structure should be collapsed (i.e. no leading '../../..'), but the remaining file structure (e.g. 'data/...') remains.

In your case, you should first update Quarto Live to the latest development build to get the changes I've just made:

$ quarto add r-wasm/quarto-live

Then, in your {pyodide} block, you would read your files from the data subdirectory, which should now exist in the Pyodide working directory:

print(listdir("data"))
pd.read_csv('data/core_meta-data.csv')

Please let me know if this is not the case, as it means some more work is still required.


As far as your document YAML header goes, since you already load the data directory into your resources in _quarto.yml, you likely don't need to include the top-level resources key again. You should only need the one under the pyodide key which tells Quarto Live to make those particular resources available in the VFS:

pyodide:
  resources:
    - "../../data/"

@georgestagg georgestagg added the bug Something isn't working label Aug 30, 2024
@Analect
Copy link
Author

Analect commented Aug 31, 2024

@georgestagg ... thanks for that fix. It seems to be working better, per here. Cells are set to be activated manually. Still working through things with another collaborator around why connecting to the embedded graph database is not working. Will close this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants