datur is a safe, typed R interface to datum, the command-line data update checker. It executes datum directly without shell interpolation, validates its JSON protocol, and returns stable R objects for interactive work and automation.
Installation
Install the development version of datur:
# install.packages("pak")
pak::pak("jprybylski/datur")Then explicitly download the latest datum release for the current operating system and CPU architecture:
download <- datum_download()
if (download$downloaded) {
options(datur.datum_path = download$path)
}Reuse the resolved release and pin the destination when reproducibility requires it:
datum_download(
version = download$version,
destination = "~/bin/datum",
overwrite = TRUE
)The archive is verified against the release’s published SHA-256 checksum before installation. If GitHub times out, datum_download() prints and returns the appropriate manual release link and expected asset name instead of failing.
You may also install any supported datum release separately. Configure a nonstandard executable location with any of:
datum_path(executable = "/opt/datum/bin/datum")
options(datur.datum_path = "/opt/datum/bin/datum")
Sys.setenv(DATUM_PATH = "/opt/datum/bin/datum")First check
With .data.yaml and .data.lock.yaml in the working directory:
library(datur)
datum_available()
datum_version()
result <- datum_check(quiet = TRUE)
print(result)With a compatible installed datum, datur can also build and safely edit .data.yaml from R using the schema and source requirements embedded in that binary:
http_source <- datum_source("http", url = "https://example.com/data.csv")
datum_dataset_add("example", "Example data", "data/example.csv", http_source)
datum_dataset_update("example", policy = "update")
datum_audit()With datum 1.6.0 or newer, initialize a new project directly from R:
datum_init(empty = TRUE)
datum_init(
id = "example",
type = "http",
source = "https://example.com/data.csv",
target = "data/example.csv",
ignore = TRUE
)HTTP sources can also include a request body and named headers. These values are validated against the schema embedded in the installed executable:
datum_source(
"http",
url = "https://api.example.com/export",
headers = list(Authorization = "Bearer ${API_TOKEN}"),
body = '{"format":"csv"}'
)Secrets (datum 1.5.0+)
With datum 1.5.0 or newer, any string value in .data.yaml can reference an environment variable using ${NAME}. This keeps credentials and machine-specific values out of version-controlled configuration:
source:
type: http
url: "https://api.example.com/export?token=${API_TOKEN}"
target: "${DATA_DIR}/export.csv"Set the variables in the environment inherited by datum before calling datum_check() or datum_run(). An unset variable is a configuration error; an explicitly empty variable is allowed. Use $${NAME} for a literal ${NAME} and note that plain $NAME is not expanded.
Substituted values are not written to the lockfile. They can still appear in a downstream URL, command, or error message, so prefer a source handler’s purpose-built authentication environment variable when one is available and avoid printing secrets. See vignette("data-yaml", package = "datur") for the complete behavior.
Changed data is represented as data, including when datum uses exit status 1 for a fail policy:
result$changed
result$status
as.data.frame(result)Each data-frame row represents one configured datum dataset. The normalized columns are id, status, message, lock_fingerprint, remote_fingerprint, and a list-column of fallback warnings.
Automation
result <- datum_check(quiet = TRUE)
if (result$changed) {
changed <- subset(as.data.frame(result), status %in% c("updated", "stale", "fail"))
message("Rebuild required for: ", paste(changed$id, collapse = ", "))
}Partial failures preserve usable results in a typed condition:
tryCatch(
datum_check(quiet = TRUE),
datur_cli_error = function(error) {
if (!is.null(error$result)) {
print(error$result)
}
stop(error)
}
)Low-level execution
Use datum_run() when you intentionally need raw CLI arguments:
Arguments remain separate process tokens and never pass through a shell. Sensitive argument values and values supplied through named env entries are redacted from public process metadata and captured output.
Important behavior
datum check always updates lockfile timestamps. A dataset using the update policy may also fetch and replace target files. datur does not modify datum configuration, download executables implicitly, or change the R working directory. datum_download() only acts when called.
See vignette("datur", package = "datur") for a complete, output-rich workflow and docs/datum-cli-contract.md for the reviewed CLI boundary.
