Skip to content

Cache engine for reticulate using dill #1210

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

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
228624b
added unit tests that cover knitr #1505
tmastny Feb 26, 2018
b52ecaa
added cache_eng_python to add Python session caching between chunks. …
tmastny Feb 26, 2018
c345ce2
dill caching engine for knitr, with tests
tmastny Feb 28, 2018
ff39889
changes from feedback on knitr #1518 with updated tests
tmastny Apr 18, 2018
8e07779
fixed testing utils source in dill tests
tmastny Apr 19, 2018
638a4e7
Merge 'rstudio/main' with 'tmastny/master' into branch 'cache-engine'
leogama May 13, 2022
9753870
cache engine: update 'r' object identification logic
leogama Apr 14, 2022
02c1771
fix 'cache_path' when 'output.dir' is different from 'knitr:::input_d…
leogama Apr 20, 2022
dbebab3
cache loading should run in the input directory
leogama Apr 20, 2022
bd29f84
remove duplicated conversion functions
leogama May 26, 2022
f8497a0
Merge branch 'main' into cache-engine
leogama Sep 3, 2022
fe4cd9f
remove trailing whitespaces and empty line
leogama Sep 3, 2022
5d6f7a7
First version of cache implementation with new knitr API
leogama Sep 13, 2022
a33ed39
Expose the cache$available() method to knitr
leogama Sep 14, 2022
266463c
Use the same warning for missing and old dill module cases
leogama Sep 15, 2022
445a5ca
Set environment() as default argument in eng_python_initialize()
leogama Sep 15, 2022
c6a88ad
Basic test for knitr engine cache
leogama Sep 17, 2022
975c1b0
minor
leogama Sep 17, 2022
401b1ba
Workflows: install module dill in the testing virtualenv
leogama Sep 17, 2022
62c77d8
Docs: remove @params from cache_eng_python, add it to pkgdown index
leogama Sep 17, 2022
f487b52
Correctly initialize Python in knitr, honoring 'engine.path'
leogama Sep 19, 2022
cb9ee1f
Implement the 'cache.vars' chunk option; some style changes
leogama Sep 19, 2022
7d4eeec
Remove unused 'envir' parameter from 'eng_python_initialize*' functions
leogama Sep 20, 2022
395627e
update cache engine docs
leogama Dec 13, 2022
55d1e03
cache: adapt code and tests to dill package v0.3.6
leogama Dec 13, 2022
d43b593
fix typo, update generated documentation
leogama Dec 13, 2022
f354f60
Workflow: use PR branch from knitr for testing
leogama Dec 16, 2022
38ef3ce
fix typo
leogama Dec 20, 2022
79b9732
Merge branch 'main' into cache-engine
t-kalinowski Jun 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'main' into cache-engine
  • Loading branch information
t-kalinowski authored Jun 21, 2023
commit 79b97327c38c6d341564c6de62da25d10497ed0f
7 changes: 5 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: rcmdcheck remotes yihui/knitr#2170
extra-packages: rcmdcheck remotes local::.
cache-version: 2
upgrade: 'TRUE'


- name: setup r-reticulate venv
shell: Rscript {0}
Expand All @@ -70,7 +73,7 @@ jobs:
reticulate::virtualenv_create("r-reticulate", Sys.which("python"))
reticulate::virtualenv_install("r-reticulate",
c("docutils", "pandas", "scipy", "matplotlib", "ipython",
"tabulate", "plotly", "psutil", "kaleido", "dill"))
"tabulate", "plotly", "psutil", "kaleido", "wrapt", "dill"))
python <- reticulate::virtualenv_python("r-reticulate")
writeLines(sprintf("RETICULATE_PYTHON=%s", python),
Sys.getenv("GITHUB_ENV"))
Expand Down
39 changes: 39 additions & 0 deletions tests/testthat/test-python-knitr-engine.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,42 @@ test_that("An R Markdown document can be rendered using reticulate", {

expect_true(file.exists(output), "example.Rmd rendered successfully")
})



test_that("In Rmd chunks, comments and output attach to code correctly", {

skip_on_cran()
skip_if_not_installed("rmarkdown")
skip_if(py_version() < "3.8") # end_lineno attr added in 3.8

local_edition(3) # needed for expect_snapshot_file()
# TODO: update the full testsuite to testthat edition 3

owd <- setwd(test_path("resources"))
rmarkdown::render("test-chunking.Rmd")

expect_snapshot_file("test-chunking.md")
setwd(owd)

})


test_that("knitr 'warning=FALSE' option", {

skip_on_cran()
skip_if_not_installed("rmarkdown")

local_edition(3) # needed for expect_snapshot_file()

owd <- setwd(test_path("resources"))
rmarkdown::render("knitr-warn.Rmd")
setwd(owd)

rendered <- test_path("resources", "knitr-warn.md")
res <- paste0(readLines(rendered), collapse = "\n")

expect_snapshot_file(rendered)
expect_no_match(res, "UserWarning", fixed = TRUE)

})
You are viewing a condensed version of this merge commit. You can view the full changes here.