This R package provides a workflow and tools to manage and publish research datasets to online repositories. It includes functions to harvest metadata from a metadata database, or "Metabase", create EML documents, and publish datasets to the EDI data repository. The Metabase is expected to follow the LTER-core-metabase schema.
jerald depends on a few required R packages:
- MetaEgress to access the Metabase
- aws.s3
- EDIutils
It also requires credentials to use the Metabase and web resources.
The package was developed by the Jornada LTER, so jerald is a bit specific to LTER sites and their research data workflows. It should, however, be somewhat extensible for other sites and purposes.
Install the GitHub version with devtools.
devtools::install_github("jornada-im/jerald")
In some cases you might want the development version, but be careful and talk to the developer first.
devtools::install_github("jornada-im/jerald@dev")
The dependencies listed above should be pulled in at install time if you don't already have them.
Once jerald is installed you will need to make credentials available for accessing the metadata database and the necessary web resources, which include a data repository (usually EDI) and an s3 bucket. You do this with an .Renviron file that is read at R startup and adds credentials to your session environment. See the .Renviron.template file for an example of the proper format. Your .Renviron can live at either the project level (<project name>/.Renviron) or user level (in your home directory: $HOME/.Renviron) and should contain credentials for:
- A "Metabase", or metadata database, running on PostgreSQL.
- An S3 bucket at a cloud provider. Currently we use DigitalOcean and the
aws.s3client R package. - A repository to publish to. Currently we use EDI and authenticate via an API key (described here).
To get started, copy the template (.Renviron.template) to your project or home directory. You can also use usethis::edit_r_environ("user|project") to open (or edit) an .Renviron in one of those places. Once template values are there you will need to contact your lead IM or administrator for the correct credentials to fill in. Always restart R after making changes.
IMPORTANT NOTE: At the current time, EDI does not support API keys that work in both staging and production environments. You will need to supply one or the other in your .Renviron and switch between them (and restart R) to publish to staging, then production EDI. Toggling line comments in the file is an easy-enough way to do this.
jerald has several user-facing functions, described below, that will help accomplish most data management and publication tasks performed by information managers at the Jornada. A template script that uses these functions to update an example dataset (id=999) on EDI is provided when making a new dataset directory using the instructions below, or is available at inst/template/build_eml.999.R. This script gives a demonstration of a basic Jornada workflow.
NOTE: These methods are a little out of date at the moment!
jerald includes a number of templates (see inst/template/) for setting up a data management project directory and scripts. To create a new dataset directory and populate with recommended files and subdirectories, run:
template_dataset_dir(datasetid)
where datasetid is a unique identifier for the dataset in the Metabase and at EDI.
An existing dataset directory formatted for use with EMLassemblyline (EAL) can be migrated to jerald's template format using:
migrate_eal_dir(eal.dir, jerald.dir)
where eal.dir is the path to the EAL directory, and jerald.dir is the path to a new dataset directory created with template_dataset_dir. All metadata and data files from eal.dir should be copied into a new EAL_archive directory in jerald.dir. Be aware that there is the potential for data or metadata loss here, so check that all necessary metadata has been copied before deleting the old directory.
jerald doesn't do this directly yet, but there is a template script called build_dataset.999.R that demonstrates how to prepare a tabular data entity. This template script will be created in any new jerald dataset directory (using template_dataset_dir) or can be found in inst/template/.
NOTE: More recently for the Jornada, these dataset build scripts are being developed and stored in the juntar repositories in our GitHub organization (there are several).
To publish a dataset in a repository the publish_dataset function wraps up most of the functionality in jerald. You provide a datasetid, the destination repository (currently only EDI supported), and the path to the data entities.
publish_dataset(datasetid, "edi.staging", "./path/to/data" )
dry_runcontrols whether publication completes or is a dry run (as explained above).TRUEby default.s3_uploadcontrols whether the data entities will be pushed to the s3 bucket (TRUEby default). If the entities already exist at the URL specified in the EML this may be set toFALSE. Note that file identities (md5 hashes) are not checked.multi_partcontrols whether data entities are pushed to the s3 bucket with a multi-part upload (FALSEby default). This is useful for large files, and required beyond a certain filesize threshold.skip_checkscontrols whether congruence between attribute metadata and data files is checked (FALSEby default). When the data are not locally present, for example when they are hosted at ezEML, this can be set toTRUEto avoid a missing file error. Make sure congruence has been checked in the remote location first.
Working on this!
There are some lower-level functions that might occasionally be useful... (will document these later)
Generative AI has been used in parts of this repository for tasks including:
- Idea generation
- Development of experimental or research protocols
- Code optimization
The GAI tool used was: Claude Sonnet and Opus >= 4.6.