5.Templates#

In addition to previous methods, items can be added to the OSC through a simplified workflow:

  1. Generate a yaml template of the item you want to add

  2. Edit the template with the details

  3. Pass the template to generate an entry inside the OSC repo

This can be achieved both in terminal with a CLI command available after installation or in a notebook/script by calling the equivalent functions.

Step 1: Generate YAML Templates#

The command can be run with the following parameters:

  -h, --help            show this help message and exit
  -p, --project         If present generate a project template with the same name
  -w, --workflow        If present generate a workflow template with the same name
  -e, --experiment      If present generate an experiment template
  -o, --product         If present generate a product template
  -t TARGET, --target TARGET
                        The target location where the templates will be generated.
                        If empty the CWD will be used
earthcode_template_gen -p -w -e -o -t targetdir

or by importing the equivalent function:

from earthcode import generate_template

generate_template(project=True, workflow=True, experiment=True, product=True, target="targetdir")
# Example with PROJECT
!earthcode_template_gen -p
WARNING:root:No target folder specified, the templates will be generated in the PWD
INFO:root:Generating Project template at "/Users/dean/Documents/EarthCODE/earthcode-library/guide"
from earthcode import generate_template

generate_template(project=True)
INFO:root:Generating Project template at "/Users/dean/Documents/EarthCODE/earthcode-library/guide"

Step 2: Edit Template#

Now a project.yaml file should be present in the chosen target directory or in the cwd. Simply edit all the fields in this file with the new project informations and details.

Step 3: Generate Stac from Template#

To add a new OSC entry we need to pass the location of the edited yaml file and of the OSC repo to the following command/function:

  -h, --help            show this help message and exit
  -p PROJECT, --project PROJECT
                        Project YAML template location
  -w WORKFLOW, --workflow WORKFLOW
                        Workflow YAML template location
  -e EXPERIMENT, --experiment EXPERIMENT
                        Experiment YAML template location
  -o PRODUCT, --product PRODUCT
                        Product YAML template location
  -m OSCM, --oscm OSCM  REQUIRED The target OSC location where the STAC jsons will be created.
earthcode_stac_gen -p ./project.yaml -w ./workflow.yaml -e ./experiment.yaml -o ./product.yaml -m ../open-science-catalog-metadata

or with function:

from earthcode import generate_stac

generate_stac(project="./project.yaml", workflow="./workflow.yaml", experiment="./experiment.yaml", product="./product.yaml", osc_path="../open-science-catalog-metadata")
#Example with PROJECT
!earthcode_stac_gen -p ./project.yaml -m ../open-science-catalog-metadata
INFO:root:Generating Project STAC json in OSC @ "../open-science-catalog-metadata"
from earthcode import generate_stac

generate_stac(project="./project.yaml", osc_path="../open-science-catalog-metadata")
INFO:root:Generating Project STAC json in OSC @ "../open-science-catalog-metadata"