Skip to contents

Read a schema.rtemis.org JSON config and return the appropriate rtemis object. Two families of config are supported: pipeline recipes that bundle a data path, algorithm config, and output directory (SuperConfig, DecomposeConfig, ClusterConfig), and the bare algorithm configs they wrap (DecompositionConfig, ClusteringConfig). The file is JSON, as written by write_config and consumed by rtemislive and the rtemis CLI.

Usage

read_config(file)

Arguments

file

Character: Path to input JSON config file.

Value

A SuperConfig, DecomposeConfig, ClusterConfig, DecompositionConfig, or ClusteringConfig object.

Details

The config family is taken from the instance's $schema, which must be one of the supported schemas; a missing or unrecognized $schema is an error.

A run record is rejected, and named as such. A record declares the same fields as the config it came from, so it would read as one – but every value in it is resolved, including values a run derived from data this call has never seen. Accepting it would silently pin settings the new call should decide for itself. Records are written by write_record and identify themselves with a record.json schema.

Validation is entirely rtemis's own: check_wire_keys() rejects an unknown key at every level of the document, and each setup_* then constructs an S7 object whose properties enforce their declared types, bounds, enums and arities. Those properties are the same PropertySpecs the published JSON Schemas are generated from, so reading a config in R applies the published contract by construction – there is nothing an external validator could add.

Author

EDG

Examples

# Create a SuperConfig object
x <- setup_SuperConfig(
  dat_training_path = "~/Data/iris.csv",
  hyperparameters = setup_LightRF()
)
# Write JSON config file
tmpdir <- tempdir()
tmpfile <- file.path(tmpdir, "rtemis_test.json")
write_config(x, tmpfile, overwrite = TRUE)
#> 2026-08-09 13:22:41 
#> ✔ Created file: /var/folders/cr/lgjpmnv97lg6qtnjt9kph7qw0000gn/T//RtmpdcJDNA/rtemis_test.json
#>  [write_lines]
# Read config back from JSON file
x_read <- read_config(tmpfile)