wa_seed_example_models: Seed example model files in a temporary directory

View source: R/seed_example_helpers.R

wa_seed_example_modelsR Documentation

Seed example model files in a temporary directory

Description

This helper writes a minimal model file to a subdirectory of 'dir' (default: 'tempdir()'), and sets the option 'writeAlizer.mock_dir' to that location so examples can run without downloads or network access.

Usage

wa_seed_example_models(model = c("example"), dir = tempdir())

Arguments

model

Character scalar. Only '"example"' is currently supported.

dir

Directory in which to create the example model (default: 'tempdir()').

Details

Creates an ultra-tiny model artifact used in examples and points the package loader to it via a temporary option.

- Writes under the supplied 'dir' (by default 'tempdir()') and returns the path. - The example predicts a constant 1.5; it is not a writing assessment. - Sets 'options(writeAlizer.mock_dir = <path>)'; callers should restore prior options when appropriate (see Examples).

Value

(Invisibly) the path to the created example model directory.

Examples

local({
  old <- options(writeAlizer.mock_dir = NULL)
  on.exit(options(old))
  parent <- tempfile("wa-example-")
  ex <- wa_seed_example_models(dir = parent)
  on.exit(unlink(parent, recursive = TRUE), add = TRUE)
  predict_quality("example", data.frame(ID = c("text1", "text2")))
})


writeAlizer documentation built on Sept. 17, 2026, 1:08 a.m.