-
Notifications
You must be signed in to change notification settings - Fork 240
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
Make data/
directory automatically accessible to exercises
#539
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great start! I really like how the interface is coming together and I think it will benefit many tutorial authors.
We'll need to think through and account for all of the various ways the underlying options can be set and that files can be added to an exercise. To help with that, I think the next step would be to add several small test tutorials in a folder at tests/testthat/exercise-files
. Each one can demonstrate an expected use case. Actually writing the tests is going to be a little tricky, but we can work through that step together. In the mean time it will be helpful to have a few examples to test out interactively.
… options overlap
Conflicts: R/exercise.R tests/testthat/test-exercise.R
@rossellhayes I had a few small changes to propose and in the process I merged main into this branch. It turns out that our options-protection work misses options that are options(thing = NULL)
withr::with_options({
options(thing = "bad")
})
getOption("thing")
#> "bad" To be fair, this same issue will happen with the standard base R pattern too:
We'll have to write a custom |
It looks like this is a known issue: r-lib/withr#57 Edit: fixed in 6b32eeb |
Merge branch 'data-files' of https://github.com/rossellhayes/learnr into data-files # Conflicts: # sandbox/data_dir/file_test/file_test.Rmd
…rs, including `NULL` and `""`, to their original state on exit
…ions()` and envvars, including `NULL` and `""`, to their original state on exit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great and I'm really excited for this feature to land in learnr. I'm approving the PR but we have a little bit more to do in terms of documentation.
- Add an entry in NEWS under New Features
- Document the new behavior in the learnr docs webpage. I think it makes sense to add a new section in
docs/exercises.Rmd
after Exercise Setup. - Once the above are done and the PR is merged, we'll need to follow up in any related issues to let everyone know about the new feature.
Documents new `data/` directory features
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM given cosmetic suggestions!
Co-authored-by: Barret Schloerke <barret@rstudio.com>
Co-authored-by: Barret Schloerke <barret@rstudio.com>
Co-authored-by: Barret Schloerke <barret@rstudio.com>
Co-authored-by: Barret Schloerke <barret@rstudio.com>
This adds two interfaces for making files available to
learnr
tutorials.data/
directory in the same directory as the tutorial Rmd document will be accessible to the tutorial.use_remote_files()
in thesetup
chunk will cache files into a temporary directory and make them available to the tutorial as if they were in thedata/
directory.