Skip to contents

pin_module_config() saves a complete program, including nested modules, demonstrations and optimization results, to a pins board as an .rds pin. Read it back with pins::pin_read() and rebuild the program with restore_module_config().

Usage

pin_module_config(
  board,
  name,
  module,
  description = NULL,
  versioned = TRUE,
  ...,
  registry = list(),
  trusted = FALSE
)

Arguments

board

A pins board, such as pins::board_folder("pins").

name

Name of the pin.

module

The program to save.

description

Optional pin description. The default is "dsprrr program artifact: <name>".

versioned

Whether pins keeps earlier versions (default TRUE).

...

Further arguments passed to pins::pin_write().

registry

Named runtime registry; see program_artifact().

trusted

Whether runtime values may be embedded (default FALSE); see program_artifact().

Value

name, invisibly.

Details

The pin holds the program artifact described in program_artifact(): signatures, configuration, demonstrations, optimization results and the structure of composed programs. Chats, credentials, caches and traces are not saved. Functions such as tools or retrievers are saved only as names in registry, or embedded with trusted = TRUE.

Examples

classifier <- module(signature("text -> sentiment"))
trainset <- data.frame(
  text = c("I love it!", "Terrible experience", "It's okay"),
  sentiment = c("positive", "negative", "neutral")
)
compiled <- compile(classifier, LabeledFewShot(k = 2L), trainset)

board <- pins::board_temp()
pin_module_config(board, "sentiment-classifier", compiled)
#> Creating new version '20260930T174419Z-32d50'
#> Writing to pin 'sentiment-classifier'
#> ✔ Pinned program artifact: "sentiment-classifier"
#> ℹ Root module: <PredictModule>
#> ℹ Graph nodes: 1
#> ℹ Compiled: TRUE

# Later, or in another session
artifact <- pins::pin_read(board, "sentiment-classifier")
restored <- restore_module_config(artifact)
#> ✔ Restored program artifact
#> ℹ Root module: <PredictModule>
#> ℹ Artifact version: 6
length(restored$demos)
#> [1] 2