Skip to contents

Open or create an Icechunk repository

Usage

ic_repo_open(storage, containers = NULL, authorize = NULL)

ic_repo_create(
  storage,
  containers = NULL,
  authorize = NULL,
  spec_version = NULL,
  manifest_split = NULL
)

ic_repo_exists(storage)

ic_repo_save_config(repo)

ic_repo_config(repo)

Arguments

storage

an ic_storage object, or a local path.

containers

virtual chunk containers (ic_container()) to layer on the persisted config (use ic_repo_save_config() to persist).

authorize

virtual chunk prefixes this session may read: NULL (none), a character vector of prefixes (credentials inferred from the scheme: s3 from env, http(s) anonymous, file local), or a named list of prefix = ic_cred_s3() etc. Icechunk authorises whole virtual chunk containers (see ic_repo_containers()): a prefix that is a container's prefix, or broader than one (e.g. "https://"), authorises every declared container it covers, with those credentials; a prefix inside a container is an error naming the container; a prefix that covers no container is a warning listing the declared ones.

spec_version

format version for new repositories (1 or 2; NULL for the library default).

manifest_split

manifest splitting for new repositories: NULL (one manifest per array), a named integer vector of chunks per manifest along each dimension, by axis index or dimension name (e.g. c(time = 1) or c("0" = 30); "*" for any dimension), applied to every array, or a list of rules list(path = <regex or NULL>, dims = <as before>) tried in order. Split manifests let a read of a slab (see ic_to_byterefs(), the DBI refs_<array> tables) fetch only the manifests that cover it. Persist with ic_repo_save_config().

repo

an icechunk_repo.

Value

an icechunk_repo.

Examples

# create a repository, write a group, commit
path <- tempfile("ic-repo-open-")
repo <- ic_repo_create(path)
s <- ic_session_writable(repo, "main")
ic_set(s, "zarr.json", charToRaw('{"zarr_format":3,"node_type":"group","attributes":{}}'))
ic_commit(s, "an empty group")
#> [1] "GDMR5M788ERZR8NEMH60"
ic_repo_exists(path)
#> [1] TRUE

# open it again; a repository with virtual chunk containers needs them
# authorised before their chunks are read
ex <- ic_example_repo()
repo <- ic_repo_open(ex$path, authorize = ex$authorize)
repo
#> <icechunk_repo> spec v2
#>   storage: local: /tmp/RtmpVaRScy/icechunk-example-35c9297898f8/repo
#>   branches: main
#>   tags: v1
ic_repo_config(repo)$virtual_chunk_containers[[1]]$url_prefix
#> [1] "file:///tmp/RtmpVaRScy/icechunk-example-35c9297898f8/source/"
unlink(path, recursive = TRUE)