coatless / quarto-webr

Community developed Quarto Extension to Embed webR for HTML Documents, RevealJS, Websites, Blogs, and Books.
https://quarto-webr.thecoatlessprofessor.com/
385 stars 19 forks source link

[Bug]: tidyverse/readr progress bar shows "gibberish" before description #206

Closed ElijahMeyer3 closed 1 month ago

ElijahMeyer3 commented 4 months ago

Bug description

When reading in data by clicking Run Code, "gibberish" output is given before expected output.

webR_example

Steps to reproduce

The data are stored in a data folder in the same repo as the Bechdel + data visualization qmd.

---
title: "Bechdel + data visualization"
order: 2
webr:
  packages: ['tidyverse', 'scales']
---

```{webr-r}
#| echo: false
bechdel <- read_csv("bechdel.csv")


### Your environment

RStudio 2023.12.1+402 
Windows 11

### Quarto check output

Quarto 1.4.530 
Pandoc version 3.1.11
Dart Sass version 1.69.5
Deno version 1.37.2

Quarto installation
Version: 1.4.530
coatless commented 4 months ago

Couple of quick clarifying statements:

  1. I think this is the data:

https://github.com/ElijahMeyer3/Coursera/blob/main/bechdel.csv

  1. Is the "gibberish" output the following:
[1mindexing bechdel.csv [====================================] 109.28MB/s, eta:  0s

Or is it that echo: false didn't suppress the standard error output?


For the cell suppression, we only have limited support for disabling STDERR messages (red text) via messages: false or warnings: false. c.f. Code Cell Options. We don't currently implement an echo: false option.

For the progress bar, I think that's related to {readr}/{rlang} showing a progress bar while not being exactly in an interactive mode. The gibberish that is generated is a side effect of not being able to reset a writing buffer. We need to handle this part upstream at webR (set a non-interactive flag under our use of captureR) and/or tweak detection in readr::show_progress()/rlang::is_interactive().

The quickest way forward would be to set in a setup context:

```{webr-r}
#| context: setup
# Disable progress bar
options(readr.show_progress = FALSE)

Or, within the above code cell using:

````md
```{webr-r}
bechdel <- read_csv("bechdel.csv", progress = FALSE)
ElijahMeyer3 commented 4 months ago

Thank you for the clarification questions.

The "gibberish" output is indeed the

[1mindexing�[0m �[34mbechdel.csv�[0m [====================================] �[32m109.28MB/s�[0m, eta: �[36m 0s�[0m

That is the data being referenced yes.

This issue isn't specific to this data set. I see this issue across any data set I try and read in this way.

ElijahMeyer3 commented 4 months ago

Couple of quick clarifying statements:

  1. I think this is the data:

https://github.com/ElijahMeyer3/Coursera/blob/main/bechdel.csv

  1. Is the "gibberish" output the following:
[1mindexing�[0m �[34mbechdel.csv�[0m [====================================] �[32m109.28MB/s�[0m, eta: �[36m 0s�[0m

Or is it that echo: false didn't suppress the standard error output?

For the cell suppression, we only have limited support for disabling STDERR messages (red text) via messages: false or warnings: false. c.f. Code Cell Options. We don't currently implement an echo: false option.

For the progress bar, I think that's related to {readr}/{rlang} showing a progress bar while not being exactly in an interactive mode. The gibberish that is generated is a side effect of not being able to reset a writing buffer. We need to handle this part upstream at webR (set a non-interactive flag under our use of captureR) and/or tweak detection in readr::show_progress()/rlang::is_interactive().

The quickest way forward would be to set in a setup context:

```{webr-r}
#| context: setup
# Disable progress bar
options(readr.show_progress = FALSE)

Or, within the above code cell using:
bechdel <- read_csv("bechdel.csv", progress = FALSE)

This is perfect. Thank you!

coatless commented 4 months ago

I filed a ticket upstream in the main webR repo: https://github.com/r-wasm/webr/issues/426

Going forward, we'll likely set a flag that disables the session in quarto-webr being registered as interactive by rlang::is_interactive(). I can't promise any kind of resolution timeline due to multiple pieces being in play.

ElijahMeyer3 commented 4 months ago

[heart] Elijah Meyer, Ph.D. reacted to your message:


From: James J Balamuta @.> Sent: Tuesday, May 21, 2024 7:28:28 PM To: coatless/quarto-webr @.> Cc: Elijah Meyer, Ph.D. @.>; Author @.> Subject: Re: [coatless/quarto-webr] [Bug]: Additional "gibberish" output when reading in data using webR (Issue #206)

I filed a ticket upstream in the main webR repo: r-wasm/webr#426https://urldefense.com/v3/__https://github.com/r-wasm/webr/issues/426__;!!OToaGQ!tKHvtqVyna0Lmk8go7rNwGRu6lRluuSUTIE8RQ9vc0BCBOM8AxYHZlHkbHSLAyeRUpBbDWgmxanlLwRyEdtrh9eL$

Going forward, we'll likely set a flag that disables the session in quarto-webr being registered as interactive by rlang::is_interactive(). I can't promise any kind of resolution timeline due to multiple pieces being in play.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/coatless/quarto-webr/issues/206*issuecomment-2123301261__;Iw!!OToaGQ!tKHvtqVyna0Lmk8go7rNwGRu6lRluuSUTIE8RQ9vc0BCBOM8AxYHZlHkbHSLAyeRUpBbDWgmxanlLwRyEXx7xRwe$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AHT5VNZE325UWRR773WRGOLZDON5ZAVCNFSM6AAAAABIB5W356VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRTGMYDCMRWGE__;!!OToaGQ!tKHvtqVyna0Lmk8go7rNwGRu6lRluuSUTIE8RQ9vc0BCBOM8AxYHZlHkbHSLAyeRUpBbDWgmxanlLwRyEaju0ORA$. You are receiving this because you authored the thread.Message ID: @.***>

coatless commented 3 months ago

George modified Shelter.captureR() in the latest webR build so that non-interactive status at the R level has now been set. This should mean that in webR v0.3.4 or v0.4.0 the need to disable progress via a setup cell is no longer required.

ElijahMeyer3 commented 3 months ago

[celebrate] Elijah Meyer, Ph.D. reacted to your message:


From: James J Balamuta @.> Sent: Wednesday, June 19, 2024 8:12:11 PM To: coatless/quarto-webr @.> Cc: Elijah Meyer, Ph.D. @.>; Author @.> Subject: Re: [coatless/quarto-webr] [Bug]: tidyverse/readr progress bar shows "gibberish" before description (Issue #206)

George modified Shelter.captureR() in the latest webR build so that non-interactive status at the R level has now been set. This should mean that in webR v0.3.4 or v0.4.0 the need to disable progress via a setup cell is no longer required.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/coatless/quarto-webr/issues/206*issuecomment-2179403025__;Iw!!OToaGQ!qEvccyY-KY2Ux9msYv_BJ-1jLR1h_QgnS07MB_WDiQB9ws-MxKvDdKpHJmnXQ3y5h914BjKG4ITau9OzYadowGt2$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AHT5VNYGK2LOPYFACWTP6K3ZIHQZXAVCNFSM6AAAAABIB5W356VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZZGQYDGMBSGU__;!!OToaGQ!qEvccyY-KY2Ux9msYv_BJ-1jLR1h_QgnS07MB_WDiQB9ws-MxKvDdKpHJmnXQ3y5h914BjKG4ITau9OzYYcXoAVV$. You are receiving this because you authored the thread.Message ID: @.***>