EsgStore manages a local DuckDB manifest and a fixed directory layout for
query result snapshots, dictionaries, source files, downloaded NetCDF files,
Parquet regional extracts, and generated outputs.
pathStore directory.
manifestDuckDB manifest path.
is_openWhether the manifest connection is open.
new()Create or open a local store.
EsgStore$new(path = NULL, create = TRUE, overwrite = FALSE)pathStore directory. Default: store_dir().
createIf TRUE, create the store directory when it does not
exist. Default: TRUE.
overwriteIf TRUE, remove an existing store directory before
creating a new store. Default: FALSE.
close()Close the DuckDB connection.
set_download_layout()Configure how store-managed ESGF downloads are placed under
downloads/.
layoutDownload layout. "flat" stores files directly under
downloads/; "dataset" groups by dataset; "drs" uses a
CMIP6-style DRS path; "template" uses template.
templateOptional subdirectory template for layout = "template", using placeholders such as {source_id}.
include_versionWhether DRS paths include the ESGF version.
Default: TRUE.
collisionHow to handle different logical files that map to
the same local path. Default: "error".
missingHow to handle missing layout fields. Default:
"fallback".
register_artifact()Register a file artifact in the store manifest.
EsgStore$register_artifact(
kind,
path,
role = NULL,
project = NULL,
status = "available",
checksum = NULL,
checksum_type = "sha256",
size = NULL,
query_id = NULL,
file_key = NULL,
dict_id = NULL,
source_url = NULL,
source_repo = NULL,
source_tag = NULL,
source_commit = NULL,
metadata = list()
)kindArtifact kind.
pathArtifact path. Absolute paths must be inside the store root.
roleArtifact role. If NULL, a role is inferred from kind.
projectOptional ESGF project.
statusArtifact status. Default: "available".
checksumExpected checksum. If NULL and path exists, it is
calculated with checksum_type.
checksum_typeChecksum algorithm. Default: "sha256".
sizeArtifact size in bytes. If NULL and path exists, it is
read from the file.
query_id, file_key, dict_idOptional manifest links.
source_url, source_repo, source_tag, source_commitOptional source provenance.
metadataOptional metadata list encoded as JSON.
add_query()Add an ESGF query to the long-lived store query registry.
queryAn EsgQuery object.
labelOptional label.
trackWhether to mark the query as tracked. Default: FALSE.
tag_query()Add tags to a stored ESGF query.
untag_query()Remove tags from a stored ESGF query.
unrequire_query()Remove query dependency edges.
query_graph()List stored query dependency edges.
EsgStore$query_graph(
query_id = NULL,
direction = c("children", "parents", "both"),
recursive = TRUE
)preview_update_queries()Preview tracked ESGF query updates without changing the store.
EsgStore$preview_update_queries(
query_id = NULL,
tracked = TRUE,
tag = NULL,
children = FALSE,
detail = FALSE,
all = TRUE,
limit = FALSE,
fields = "*",
...
)query_idOptional query ID. If NULL, tracked queries are
previewed by default.
trackedTracked-state filter used when query_id is NULL.
tagOptional query tag filter used when query_id is NULL.
childrenWhether to include dependency children of selected queries.
detailWhether to return per-file changes together with the
summary. Default: FALSE.
all, limit, fieldsArguments passed to EsgQuery$collect().
...Additional File query filters passed to EsgQuery$collect().
update_queries()Refresh stored ESGF queries and link their current File records.
EsgStore$update_queries(
query_id = NULL,
tracked = TRUE,
tag = NULL,
children = FALSE,
enqueue = FALSE,
downloader = NULL,
replica = "auto",
session_label = NULL,
service = "HTTPServer",
probe = TRUE,
probe_concurrency = NULL,
probe_cache_seconds = 3600L,
strategy = c("fastest", "first", "stable"),
all = TRUE,
limit = FALSE,
fields = "*",
...
)query_idOptional query ID. If NULL, tracked queries are
updated by default.
trackedTracked-state filter used when query_id is NULL.
tagOptional query tag filter used when query_id is NULL.
childrenWhether to include dependency children of selected queries.
enqueueWhether to enqueue current files after updating.
Default: FALSE.
downloaderOptional Downloader used when enqueue = TRUE.
replicaReplica policy passed to $download_plan() when
enqueuing.
session_labelOptional download session label.
serviceESGF URL service used for the download plan.
probeWhether to probe candidate URLs before ranking.
probe_concurrencyMaximum concurrent URL probes when
probe = TRUE. Default comes from the downloader worker count
when enqueue = TRUE.
probe_cache_secondsSeconds to reuse fresh data-node probe
history before probing a URL again. Default: 3600.
strategyCandidate ranking strategy.
all, limit, fieldsArguments passed to EsgQuery$collect().
...Additional File query filters passed to EsgQuery$collect().
download_preflight()Preview a tracked query download without changing the store.
EsgStore$download_preflight(
query_id,
downloader = NULL,
replica = "auto",
service = "HTTPServer",
probe = TRUE,
probe_concurrency = NULL,
probe_cache_seconds = 3600L,
strategy = c("fastest", "first", "stable"),
all = TRUE,
limit = FALSE,
fields = "*",
...
)query_idQuery ID returned by $add_query().
downloaderOptional Downloader used only for node history, network policy, and cooldown policy.
replicaReplica policy passed to $download_plan().
service, probe, strategyDownload plan arguments.
probe_concurrencyMaximum concurrent URL probes when
probe = TRUE. Default comes from downloader when supplied.
probe_cache_secondsSeconds to reuse fresh data-node probe
history before probing a URL again. Default: 3600.
all, limit, fieldsArguments passed to EsgQuery$collect().
...Additional File query filters passed to EsgQuery$collect().
download_query()Refresh, enqueue, and optionally run downloads for a stored ESGF query.
EsgStore$download_query(
query_id,
downloader = NULL,
replica = "auto",
dry_run = FALSE,
run = TRUE,
background = FALSE,
mode = c("process", "daemon"),
session_label = NULL,
service = "HTTPServer",
probe = TRUE,
probe_concurrency = NULL,
probe_cache_seconds = 3600L,
strategy = c("fastest", "first", "stable"),
progress = TRUE,
overwrite = FALSE,
resume = TRUE,
all = TRUE,
limit = FALSE,
fields = "*",
...
)query_idQuery ID returned by $add_query().
downloaderOptional Downloader. Default: $downloader().
replicaReplica policy passed to $download_plan().
dry_runWhether to return a download preflight without
changing the store, enqueueing, or downloading. Default:
FALSE.
runWhether to run the queued session immediately. Default:
TRUE.
backgroundWhether to run the queued session in the background.
Default: FALSE.
modeBackground execution mode. "process" starts a detached
Rscript; "daemon" submits the job to a running downloader
daemon.
session_labelOptional download session label.
service, probe, strategyDownload plan arguments.
probe_concurrencyMaximum concurrent URL probes when
probe = TRUE. Default comes from the downloader worker count.
probe_cache_secondsSeconds to reuse fresh data-node probe
history before probing a URL again. Default: 3600.
progress, overwrite, resumeRun arguments.
all, limit, fieldsArguments passed to EsgQuery$collect().
...Additional File query filters passed to EsgQuery$collect().
download_status()Return downloader tasks linked to stored query files.
query_idOptional stored query ID.
session_idOptional downloader session ID.
downloaderOptional Downloader. Default: $downloader().
query_status()Summarise tracked ESGF query file and download status.
query_idOptional stored query ID vector. If NULL, all
stored ESGF queries are summarised.
downloaderOptional Downloader. Default: $downloader().
query_updates()List tracked query update runs.
query_changes()List per-file changes recorded by tracked query updates.
workflow_status()Summarise query, download, local, and extraction status together.
query_idOptional stored query ID filter.
downloaderOptional Downloader. Default: $downloader().
workflow_report()Return a compact ESGF query workflow health report.
query_idOptional stored query ID filter.
downloaderOptional Downloader. Default: $downloader().
remove_query()Remove stored ESGF queries and optionally delete orphaned local files.
EsgStore$remove_query(query_id, delete = c("none", "orphaned"))remove_files()Remove ESGF file records and optionally delete local artifacts.
prune_orphans()Report or remove file records no longer linked to any query.
storage_report()Summarise store download storage, registered local assets, temporary files, and cleanup candidates.
validate_files()Validate store-managed NetCDF downloads against the manifest.
repair_files()Repair safe store download inconsistencies reported by
$validate_files().
cleanup_downloads()Report or remove download cleanup candidates.
EsgStore$cleanup_downloads(
scope = c("tmp", "orphan_records", "untracked_files", "missing_records"),
dry_run = TRUE,
older_than = NULL
)scopeCleanup scopes. Supported values are "tmp",
"orphan_records", "untracked_files", and
"missing_records".
dry_runWhether to only report cleanup candidates. Default:
TRUE.
older_thanOptional age filter for file scopes. A numeric value
is interpreted as seconds before now; a POSIXct value is used
as an absolute mtime cutoff.
retry_downloads()Requeue retryable downloader tasks linked to stored query files.
EsgStore$retry_downloads(
query_id = NULL,
session_id = NULL,
downloader = NULL,
status = c("error", "cancelled"),
run = TRUE,
...
)query_idOptional stored query ID.
session_idOptional downloader session ID.
downloaderOptional Downloader. Default: $downloader().
statusRetryable statuses. Default: c("error", "cancelled").
runWhether to run requeued tasks immediately. Default: TRUE.
...Additional arguments passed to Downloader$run().
add_files()Add File or Aggregation query results to the local file catalog.
download_files()Enqueue and optionally download ESGF file records through the store downloader.
EsgStore$download_files(
files = NULL,
query_id = NULL,
replica = "auto",
downloader = NULL,
run = TRUE,
background = FALSE,
mode = c("process", "daemon"),
session_label = NULL,
service = "HTTPServer",
probe = TRUE,
probe_concurrency = NULL,
probe_cache_seconds = 3600L,
strategy = c("fastest", "first", "stable"),
progress = TRUE,
overwrite = FALSE,
resume = TRUE,
...
)filesOptional EsgResultFile or EsgResultAggregation object. If supplied, it is cataloged before the download plan is created.
query_idOptional file collection query IDs to enqueue when
files is NULL. If NULL, all cataloged files missing local
paths are considered.
replicaReplica policy passed to $download_plan().
downloaderOptional Downloader. Default: $downloader().
runWhether to run the queued session immediately. Default: TRUE.
backgroundWhether to run the queued session in the background.
Default: FALSE.
modeBackground execution mode. "process" starts a detached
Rscript; "daemon" submits the job to a running downloader
daemon.
session_labelOptional download session label.
serviceESGF URL service to download from. Default:
"HTTPServer".
probeWhether to lightly probe URLs before ranking them.
probe_concurrencyMaximum concurrent URL probes when
probe = TRUE. Default comes from the downloader worker count.
probe_cache_secondsSeconds to reuse fresh data-node probe
history before probing a URL again. Default: 3600.
strategyCandidate ranking strategy.
progressWhether to show per-file download progress.
overwriteWhether to overwrite existing final files.
resumeWhether to resume interrupted .part files.
...Additional arguments passed to $download_plan() and
Downloader$run().
sync_downloads()Register completed downloader tasks as local store artifacts.
downloaderOptional Downloader. Default: $downloader().
plan_region()Plan regional extraction jobs from cataloged files.
EsgStore$plan_region(
query_id,
lon,
lat,
time,
site_id = "site-1",
variable_id = NULL,
filters = list(),
method = "nearest"
)query_idQuery ID returned by $add_files().
lon, latTarget longitude and latitude.
timeLength-2 time range.
site_idSite identifier. Default: "site-1".
variable_idOptional variable IDs. If NULL, all cataloged
variables in the query are used.
filtersNamed list of exact-match file catalog filters.
methodGrid extraction method. One of "nearest", "idw",
"bilinear", or "mean". Default: "nearest".
extract()Execute pending or failed regional extraction plans.
plan_idOptional plan IDs to run.
statusPlan statuses to run when plan_id is NULL.
Default: c("pending", "failed").
fallbackWhat to do when OPeNDAP is unavailable. "auto"
downloads through HTTPServer when possible; "error" marks
the plan failed without downloading. Default: "auto".
overwriteIf TRUE, overwrite existing Parquet outputs.
Default: FALSE.
resumeWhether to reuse complete existing extraction outputs.
Default: TRUE.
summarise()Summarise extracted Parquet outputs by manifest columns.
EsgStore$summarise(
by = c("source_id", "experiment_id", "variant_label", "frequency", "variable_id",
"site_id", "year")
)