Skip to content

Commit

Permalink
Merge pull request #61 from lindeloev/dev
Browse files Browse the repository at this point in the history
Submitted dev to CRAN
  • Loading branch information
lindeloev authored May 4, 2024
2 parents a8297fd + e9c1f56 commit e498179
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.Rproj.user
.Rhistory
TODO.md
revdep

docs
6 changes: 3 additions & 3 deletions R/call_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ save_env = function(vars, env, code_str) {
vars = ls_varnames[ls_varnames %in% all.names(parse(text = code_str))]
} else if (length(vars) == 1 && vars == "all") {
vars = ls(envir = env, all.names = TRUE)
} else if (vars[1] == "c") {
vars = vars[-1]
} else if (is.character(vars)) {
# Stay character vector
} else {
stop("`import` must be one of 'all', 'auto', NULL, or a c(vector, of, variables).")
stop("`import` must be one of 'all', 'auto', NULL, c(unquoted, variables), or c('quoted', 'variables').")
}

# Show import size
Expand Down
10 changes: 5 additions & 5 deletions R/job.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#' * `"auto"` (default): Detect which objects are used in the code and import
#' those.
#' * `c(foo, bar, ...)`: A vector of unquoted variables to import into the job.
#' * `c("foo", "bar", ...)`: A vector of quoted variables to import into the job.
#' * `NULL`: import nothing.
#' @param packages Character vector of packages to load in the job. Defaults to
#' all loaded packages in the calling environment. `NULL` loads only default
Expand Down Expand Up @@ -161,11 +162,12 @@ job = function(..., import = "all", packages = .packages(), opts = options(), ti
##########
# IMPORT #
##########
if (is.call(import) == FALSE)
import = substitute(import)
# Handle quoted vars etc.
if (is.character(import) == FALSE)
import = as.character(substitute(import))[-1]

import_summary = save_env(
vars = as.character(import),
vars = import,
env = parent.frame(),
code_str = code_str
)
Expand All @@ -184,8 +186,6 @@ job = function(..., import = "all", packages = .packages(), opts = options(), ti
suppressWarnings(saveRDS(.__jobsettings__, .__jobsettings__$file, compress = FALSE)) # Ignore warning that some package may not be available when loading




########################
# BUILD R CODE FOR JOB #
########################
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ job::job({

# Continue working in your console
cat("I'm free now! Thank you.
Sincerely, Console.")
Yours truly, Console.")
```

Now you can follow the progress in the jobs pane and your console is free in the meantime.
Now you can follow the progress in the jobs pane and your console is free in the meantime.


## Tweak your job(s)
Expand Down
21 changes: 20 additions & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# job 0.3.1

## Notes for the reviewer

* This package is RStudio-specific so automated R CMD Checks cannot test the functionality. It does have an extensive `testthat` test suite which has been run manually in the following RStudio environments with no ERRORs or WARNINGs:

## Manual test environments
* Windows 10, R 4.3.3 RStudio 2024.04.0
* Ubuntu 24.04, R 4.3.3 RStudio 2024.04.0
* Mac OS, R 4.0.5 RStudio 1.4.1106

## Downstream dependencies
We checked 3 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 0 packages



# Resubmission 2
This is a resubmission. For this version, I have:

Expand All @@ -14,13 +33,13 @@ jobs (if `rstudioapi::isAvailable() == TRUE & getOption("is.job", FALSE) == TRUE




# Resubmission
This is a resubmission. For this version, I have:

* Changed the README.md link that triggered a NOTE. The original link was https and valid, though, but no problem.



# job 0.3.0

## Notes for the reviewer
Expand Down
1 change: 1 addition & 0 deletions man/job.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 13 additions & 9 deletions tests/testthat/test_job.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ if (rstudioapi::isAvailable()) {
# Set env
a = 123
b = list(a = a, goat = "baah")
inner_func = function(x) x^2
outer_func = function(x) sum(inner_func(x))

# Launch job
job::job(default = {
Expand All @@ -43,21 +45,23 @@ if (rstudioapi::isAvailable()) {
a = 123 # same value as imported; do not return
b = list(a = a, goat = "peep") # imported, but new value; return
na_classed_works = is.character(NA_character_) # Test that NA_character_ is not converted to NA
inner_outer = outer_func(c(0, 2, 4)) # Tests https://github.com/lindeloev/job/issues/49
attached_rstudioapi = exists("isAvailable")
opts = options()
print("output!")
})

# Check result
helpers$wait_for_job("default")
expect_identical(default$vars, c(".__jobsettings__", "a", "b"))
expect_identical(default$vars, c(".__jobsettings__", "a", "b", "inner_func", "outer_func"))
expect_identical(default$pkgs, c("testthat", "rstudioapi", helpers$pkgs))
expect_identical(default$searchpaths_job, searchpaths()[searchpaths() != "devtools_shims"])
expect_identical(default$a_copy, a)
expect_identical(default$b_copy, b)
expect_true(default$na_classed_works)
expect_true(default$inner_outer == 20)
expect_true(default$attached_rstudioapi)
expect_identical(names(default), c("b_copy", "pkgs", "b", ".jobcode", "opts", "a_copy", "vars", "searchpaths_job", "attached_rstudioapi", "na_classed_works"))
expect_identical(names(default), c("inner_func", "b_copy", "pkgs", "b", ".jobcode", "outer_func", "opts", "a_copy", "vars", "searchpaths_job", "inner_outer", "attached_rstudioapi", "na_classed_works"))
expect_true(is.null(default$opts$job.mainsession) == FALSE & default$opts$device == options("device"))

# Cleanup
Expand All @@ -66,9 +70,9 @@ if (rstudioapi::isAvailable()) {



#############
# TEST ARGS #
#############
######################
# TEST UNQUOTED ARGS #
######################
test_that("Set arguments in job::job()", {
# Set env
a = 123
Expand Down Expand Up @@ -102,9 +106,9 @@ if (rstudioapi::isAvailable()) {



##############################
# TEST empty() WITH ARGS #
##############################
#################################
# TEST empty() WITH QUOTED ARGS #
#################################
test_that("Set arguments in job::empty()", {
# Set env
a = 123
Expand All @@ -120,7 +124,7 @@ if (rstudioapi::isAvailable()) {
attached_rstudioapi = exists("isAvailable")
opts = options()
print("output!")
}, import = c(b, q), packages = c("job"), title = "something weird: #/(¤", opts = list(job.newopt = 59))
}, import = c("b", "q"), packages = c("job"), title = "something weird: #/(¤", opts = list(job.newopt = 59))

# Check result
helpers$wait_for_job("with_args2")
Expand Down

0 comments on commit e498179

Please sign in to comment.