Skip to content

Commit 729c6a6

Browse files
authored
RC for initial CRAN release (#47)
* Update DESCRIPTION * Make README shorter, mostly * Tiny change to docs * h2o function is now exported 🎉 * Update docs for torch. Related to #36. * Update title * Tiny doc changes * Tiny changes to docs * Redocument * Remove the progress bar removal, skip loooooong examples * Redocument * Skip if no tensorflow * Don't run examples + vignette on CRAN * Need tensorflow to check if... tensorflow is installed 😫 * Redocument * Better example checks * Redocument * Better title case * Can't check for tensorflow unless R package is installed * Don't use "native" to mean different things in the pkg * Light refining of main vignette * Redocument AGAIN * Return values for internal functions * Say "interface", not "API" * Use single quotes for 'R' * More carefully check for torch * Redocument * Ignore
1 parent 17e8c24 commit 729c6a6

29 files changed

+195
-191
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
^_pkgdown\.yml$
1111
^docs$
1212
^pkgdown$
13+
^CRAN-SUBMISSION$

DESCRIPTION

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: bundle
2-
Title: Serialize Objects With A Consistent Interface
3-
Version: 0.0.0.9200
2+
Title: Serialize Model Objects with a Consistent Interface
3+
Version: 0.1.0
44
Authors@R: c(
55
person("Julia", "Silge", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0002-3671-836X")),
@@ -9,11 +9,11 @@ Authors@R: c(
99
person("Max", "Kuhn", , "[email protected]", role = "aut"),
1010
person("RStudio", role = c("cph", "fnd"))
1111
)
12-
Description: R holds most objects in memory. However, some models store
13-
their data in locations that are not included when one uses `save()`
14-
or `saveRDS()`. bundle provides a common API to capture this
15-
information, situate it within a portable object, and restore it for
16-
use in new settings.
12+
Description: Typically, models in 'R' exist in memory and can be saved via
13+
regular 'R' serialization. However, some models store information in
14+
locations that cannot be saved using 'R' serialization alone. The goal of
15+
'bundle' is to provide a common interface to capture this information,
16+
situate it within a portable object, and restore it for use in new settings.
1717
License: MIT + file LICENSE
1818
URL: https://github.com/rstudio/bundle, https://rstudio.github.io/bundle/
1919
BugReports: https://github.com/rstudio/bundle/issues
@@ -43,6 +43,7 @@ Suggests:
4343
rmarkdown,
4444
stacks,
4545
testthat (>= 3.0.0),
46+
tensorflow,
4647
torch,
4748
torchvision,
4849
uwot,

R/bundle.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
#'
55
#' @description
66
#' `bundle()` methods provide a consistent interface to serialization
7-
#' methods for statistical model objects. The outputted bundle can be saved,
8-
#' re-loaded into a new R session, and `unbundle()`d in a new R session for
9-
#' use in prediction.
7+
#' methods for statistical model objects. The created bundle can be saved,
8+
#' then re-loaded and `unbundle()`d in a new R session for use in prediction.
109
#'
1110
#' @templateVar outclass referencing the modeling function
1211
#' @templateVar default . If a bundle method is not defined for the supplied object, `bundle.default` is the identity function.

R/bundle_caret.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#' `train_model_object$finalModel`. See the class of the output of that
1414
#' slot for more details on the bundling method for that object.
1515
#' @template butcher_details
16-
#' @examplesIf rlang::is_installed("caret")
16+
#' @examplesIf rlang::is_installed("caret") && identical(Sys.getenv("NOT_CRAN"), "true")
1717
#' # fit model and bundle ------------------------------------------------
1818
#' library(caret)
1919
#'

R/bundle_h2o.R

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#' @template param_unused_dots
1717
#' @seealso These methods wrap [h2o::h2o.save_mojo()] and
1818
#' [h2o::h2o.saveModel()].
19-
#' @examplesIf rlang::is_installed("h2o") && rlang::is_installed("MASS")
19+
#' @examplesIf rlang::is_installed(c("h2o")) && identical(Sys.getenv("NOT_CRAN"), "true")
2020
#' # fit model and bundle ------------------------------------------------
2121
#' library(h2o)
2222
#'
@@ -80,9 +80,9 @@ bundle_h2o <- function(x, ...) {
8080
file_loc <- withr::local_tempdir(pattern = "bundle")
8181

8282
if (x@have_mojo) {
83-
file_loc <- with_no_progress(h2o::h2o.save_mojo(x, path = file_loc))
83+
file_loc <- h2o::h2o.save_mojo(x, path = file_loc)
8484
} else {
85-
file_loc <- with_no_progress(h2o::h2o.saveModel(x, path = file_loc))
85+
file_loc <- h2o::h2o.saveModel(x, path = file_loc)
8686
}
8787
raw <- readBin(file_loc, "raw", file.size(file_loc), endian = "little")
8888

@@ -92,9 +92,9 @@ bundle_h2o <- function(x, ...) {
9292
new_file <- withr::local_tempfile(pattern = "unbundle")
9393
writeBin(object, new_file, endian = "little")
9494
if (!!x@have_mojo) {
95-
res <- h2o:::with_no_h2o_progress(h2o::h2o.import_mojo(new_file))
95+
res <- h2o::h2o.import_mojo(new_file)
9696
} else {
97-
res <- h2o:::with_no_h2o_progress(h2o::h2o.loadModel(new_file))
97+
res <- h2o::h2o.loadModel(new_file)
9898
}
9999

100100
res
@@ -115,7 +115,3 @@ select_from_automl <- function(x, id = NULL, n = NULL) {
115115
}
116116
x
117117
}
118-
119-
with_no_progress <- function(expr) {
120-
rlang::eval_tidy(h2o:::with_no_h2o_progress(expr))
121-
}

R/bundle_keras.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#' @details This bundler does not currently support custom keras extensions,
1616
#' such as use of a [keras::new_layer_class()] or custom metric function.
1717
#' In such situations, consider using [keras::with_custom_object_scope()].
18-
#' @examplesIf FALSE
18+
#' @examplesIf rlang::is_installed(c("keras")) && identical(Sys.getenv("NOT_CRAN"), "true")
1919
#' # fit model and bundle ------------------------------------------------
2020
#' library(keras)
2121
#'

R/bundle_stacks.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#' @details This bundler wraps [bundle.model_fit()] and [bundle.workflow()].
1414
#' Both the fitted members and the meta-learner (in `x$coefs`) are bundled.
1515
#'
16-
#' @examplesIf rlang::is_installed(c("stacks"))
16+
#' @examplesIf rlang::is_installed(c("stacks")) && identical(Sys.getenv("NOT_CRAN"), "true")
1717
#' # fit model and bundle ------------------------------------------------
1818
#' library(stacks)
1919
#'

R/bundle_torch.R

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515
#' via the luz package, "a higher level API for torch providing
1616
#' abstractions to allow for much less verbose training loops."
1717
#'
18-
#' These bundlers rely on serialization methods from luz and torch,
19-
#' which are [described by the package authors][torch::torch_save]
20-
#' as "experimental" and not for "use for long term storage."
21-
#'
2218
#' @method bundle luz_module_fitted
2319
#' @rdname bundle_torch
24-
#' @seealso This method adapts [luz::luz_save()] and the internal luz function
25-
#' `model_to_raw()`, as well as [torch::torch_save()].
26-
#' @examplesIf FALSE
20+
#' @seealso This method wraps [luz::luz_save()] and [luz::luz_load()].
21+
#' @examplesIf rlang::is_installed(c("torch")) && identical(Sys.getenv("NOT_CRAN"), "true")
22+
#' if (torch::torch_is_installed()) {
2723
#' # fit model and bundle ------------------------------------------------
2824
#' library(torch)
2925
#' library(torchvision)
@@ -99,6 +95,7 @@
9995
#' mod_unbundled <- unbundle(mod_bundle)
10096
#'
10197
#' mod_unbundled_preds <- predict(mod_unbundled, test_dl)
98+
#' }
10299
#'
103100
#' @aliases bundle.luz_module_fitted
104101
#' @export

R/package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' bundle: Serialize Objects With A Consistent Interface
1+
#' bundle: Serialize Model Objects With A Consistent Interface
22
#'
33
#' @docType package
44
#' @name bundle_description

R/utils.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#' These functions are not user-facing and are only exported for developer
66
#' extensions.
77
#'
8+
#' @return The two `_constr()` functions are constructors that return a bundle
9+
#' and a situater, respectively. `swap_element()` returns `x` after swapping
10+
#' out the specified element.
11+
#'
812
#' @rdname internal_functions
913
#' @keywords internal
1014
#' @export

0 commit comments

Comments
 (0)