You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Install from GitHubdevtools::install_github("thecartercenter/erifunctions")
# Pin the version in your analysis project (recommended)renv::install("thecartercenter/erifunctions")
renv::snapshot()
Setup
Add the following to your project .Renviron (usethis::edit_r_environ(scope = "project")):
# Azure storage
ERIFUNCTIONS_TENANT_ID=<Azure tenant ID>
ERIFUNCTIONS_APP_ID=<Azure app registration ID>
ERIFUNCTIONS_RESOURCE_ENDPOINT=<storage account endpoint URL>
ERIFUNCTIONS_STORAGE_NAME=projects
ERIFUNCTIONS_DATA_STORAGE_NAME=data
# Service principal — for scripted/automated use only
ERIFUNCTIONS_SP_CLIENT_ID=<SP client ID>
ERIFUNCTIONS_SP_CLIENT_SECRET=<SP client secret>
# Your analyst identity (appears in approval and access logs)
ERI_ANALYST_ID=firstname.lastname
# ODK Central
ODK_URL=https://rblf.tccodk.org/
ODK_USER=your.email@cartercenter.org
ODK_PASS=<ODK password>
Restart R after editing .Renviron.
Daily workflow
Two templates ship with the package. Pull either one with eri_template_pull():
eri_approve() is the explicit human gate. Nothing reaches processed/ without it.
Data catalog
Every file promoted by eri_approve() is automatically registered in _catalog/data_catalog.yaml. Query it to see what data exists on the system:
# What processed Uganda oncho data do we have?
eri_catalog_query(country="uga", disease="oncho", layer="processed")
# Is everything in the catalog still in Azure?
eri_catalog_verify()
Function reference
Connections
Function
What it does
get_azure_storage_connection()
Authenticate with Azure (browser or service principal)
init_odk_connection()
Authenticate with ODK Central
Reading and writing data
Function
What it does
eri_read(file_loc)
Read a file from Azure (parquet, csv, xlsx, rds)
eri_write(obj, file_loc)
Write an object to Azure
eri_upload(local_path, file_loc)
Upload any local file to Azure
eri_list(file_loc)
List files in an Azure directory
eri_file_exists(file_loc)
Check whether a file exists
eri_data_path(country, disease, data_type, layer)
Build a canonical blob path
Data pipeline
Function
What it does
eri_approve(country, disease, data_type, period)
Promote staged files to processed (human gate)
eri_stage(pipeline, country, disease)
Pull pipeline output from projects blob into staged
eri_ingest(path, country, disease)
DQ-check a local file and dual-write to both blobs