A.2. Conformance Class “Application Staged Inputs”
A.3. Conformance Class “Application Staged Outputs”
A.4. Conformance Class “Application Package”
A.5. Conformance Class “Application Package Staged Inputs”
A.6. Conformance Class “Application Package Staged Outputs”
The following conformance classes are left out, as they pose requirements to the executing platform which is out of scope of the demonstration:
A.7. Conformance Class “Platform”
A.8. Conformance Class “Platform Staged Inputs”
A.9. Conformance Class “Platform Staged Outputs”
The numbering, naming and requirements are reproduced verbatim from the OGC Best Practice Document which is the authoritative source in case of any discrepancies with this document.
In the following, the applicable requirements are stated with a short description how adherence to each requirement is demonstrated for the Heatwise EOAPs. For a description of the tools referenced in the demonstration, see Table 1.2.
2.1 Requirement 1: req/app/cmd-line
The Application SHALL be a non-interactive executable as a command-line application.
The demonstration contains a command-line call to the docker container containing the application. Successfully executing the container image with no interactive inputs demonstrates this requirement.
2.2 Requirement 2: req/app/container
The environment, libraries, binaries, executable and configuration files necessary to execute the Application SHALL be bundled in a container image.
The demonstration contains a command-line call to the docker container containing the application. Successfully executing the container image demonstrates this requirement.
2.3 Requirement 3: req/app/registry
The Application container image SHALL be accessible in a container registry.
skopeo is used to query the metadata of each container image. If an image is not available in a registry, skopeo will fail.
Script
The skopeo call is wrapped in a script check-container-registry.sh:
#!/bin/env bash# Skopeo inspects the manifest in a docker registry.# The command fails, if the image is not available.# The latest version of skopeo on conda-forge has an issue with its configuration, we overwrite# it here with a minimal configuration to avoid that error:REGISTRIES_CONF_V2=/tmp/test-registries.confecho"unqualified-search-registries = [\"docker.io\"]">$REGISTRIES_CONF_V2exportCONTAINERS_REGISTRIES_CONF=$REGISTRIES_CONF_V2# We do not want to see the full output in case of successskopeo inspect "docker://$1">> /dev/nullstatus=$?if[["$status"== 0 ]];thenecho"SUCCESS: Image $1 found on registry"elseecho"FAILURE: Image $1 not found on registry"fiexit$status
Example:
The script fails when the container image is not found:
FATA[0000] Error parsing image name "docker://quay.io/does-not-exist:1.0": reading manifest 1.0 in quay.io/does-not-exist: StatusCode: 404, "<!doctype html>\n<html lang=en>\n<title>404 Not Foun..."
FAILURE: Image quay.io/does-not-exist:1.0 not found on registry
2.4 Requirement 4: req/app/stac-input
An Application input argument that requires staged EO product files SHALL be defined as an argument that points to a folder where a STAC Catalog, named catalog.json, contains a list of one or more STAC Items and associated STAC Assets referencing the files.
The inputs passed to the processor are shown to be directories containing a catalog.json and the CWL document is shown to process these inputs as type Directory. The script to extract the inputs is shown in Section 2.12.
How the catalog.json is processed internally is not shown in the demonstration and can be inspected in the source code of each repository if required.
2.5 Requirement 5: req/app/stac-out
An Application that creates EO product files to be stage-out SHALL generate a valid STAC Catalog, named catalog.json, and include the STAC Item(s) and corresponding STAC Assets pointing to the results of the processing.
The STAC catalog and item produced by each EOAP are shown to be valid STAC with the stac-validator tool.
2.6 Requirement 6: rec/app/stac-out-metadata
The STAC Catalog created by the Application SHALL include metadata elements for each STAC Item with at least their spatial (geometry, box) and temporal (datetime) properties.
yq is used to extract the geometry, bbox and datetime properties from the STAC item produced by the EOAP.
Script
The script fails, if any of geometry, bbox or datetime are not present.
#!/bin/env bash# Fails, if there required keys are not presentstatus_a=1status_b=1# yq arguments:# -M: No color# -e: Fail if nothing is foundyq-y-M-e' { geometry: { type: .geometry.type, coordinates: "[...truncated...]" }, bbox: .bbox, properties: { datetime: .properties.datetime, start_datetime: .properties.start_datetime, end_datetime: .properties.end_datetime } } '$1status_a=$?found_keys=$(yq-M-e'(has("geometry") and (.geometry | has("coordinates"))) and (.geometry != null and .bbox != null) and (.properties | (has("datetime") and .datetime != null) or ((has("start_datetime") and .start_datetime != null) and (has("end_datetime") and .end_datetime != null)))'$1)status_b=$?echo""echo"Required keys present: $found_keys"[[$status_a-eq 0 &&$status_b-eq 0 ]]
2.7 Requirement 7: req/app-pck/cwl
The Application Package SHALL be a valid CWL document with a “Workflow” class and one or more “CommandLineTool” classes.
The CWL document is validated using cwltool which provides a --validate option for this purpose.
yq is used to extract the classes present in the CWL graph. The requirement is satisfied, if there is exactly one Workflow CWL object and one or more CommandLineTool CWL objects.
Script
#!/bin/env bashstatus=1# yq arguments:# -y: Output in yaml format (not json)# -M: No color# -e: Fail if nothing is foundyq-y-M-e\' # Select the top-level key "$graph" .["$graph"] # Iterate over the entries in "$graph" .[] # Extract keys "class" and "id" | { class: .class, id: .id } '$1status=$?exit"$status"
2.8 Requirement 8: req/app-pck/clt
The Application Package CWL CommandLineTool classes SHALL contain the following elements:
Identifier (“id”)
Command line name (“baseCommand”)
Input parameters (“inputs”)
Environment requirements (“requirements”)
Docker information (“DockerRequirement”)
yq is used to extract the keys mandated by this requirement.
Script
The script fails if not all required keys are present.
#!/bin/env bashstatus_a=1status_b=1yq-y-M-e'# Select the CommandLineTool(s) from the graph ( # From the top-level graph .["$graph"] # iterate over all entries (these are the Workflows and CommandLine Tools) [] # Select the entries of type CommandLineTool | select(.class == "CommandLineTool") ) # Check for presence of fields required by EOAP best practice | { "id": .id, "baseCommand": .baseCommand, "requirements": .requirements }'$1status_a=$?# All CommandLineTools must have the required keys. "requirements" may be given as a# mapping (class name as key) or as a list of objects with a "class" field.found_keys=$(yq-M-e' [ .["$graph"][] | select(.class == "CommandLineTool") | has("id") and has("baseCommand") and has("inputs") and has("requirements") and (.requirements | if type == "array" then any(.[]; .class == "DockerRequirement") else has("DockerRequirement") end) ] | length > 0 and all'$1)status_b=$?echo Required keys present: $found_keys[[$status_a-eq 0 &&$status_b-eq 0 ]]
2.9 Requirement 9: req/app-pck/wf
The Application Package CWL Workflow class SHALL contain the following elements:
Identifier (“id”)
Title (“label”)
Abstract (“doc”)
yq is used to extract the keys mandated by this requirement.
Script
The script fails if not all required keys are present.
#!/bin/env bashstatus_a=1status_b=1yq-y-M-e'# Select the Workflow from the graph ( # From the top-level graph .["$graph"] # iterate over all entries (these are the Workflows and CommandLine Tools) [] # Select the entries of type workflow (just one) | select(.class == "Workflow") ) # Check for presence of fields required by EOAP best practice | { "id": .id, "label": .label, "doc": .doc, }'$1status_a=$?found_keys=$(yq-M-e' [ .["$graph"][] | select(.class == "Workflow") | has("id") and has("label") and has("doc") ] | length > 0 and all'$1)status_b=$?echo Required keys present: $found_keys[[$status_a-eq 0 &&$status_b-eq 0 ]]
2.10 Requirement 10: req/app-pck/wf-inputs
The Application Package CWL Workflow class “inputs” fields SHALL contain the following elements:
Identifier (“id”)
Title (“label”)
Abstract (“doc”)
yq is used to extract the inputs field of the CWL workflow and validate that the keys mandated by this requirement are present.
Script
The script fails if not all required keys are present.
#!/bin/env bashstatus=1yq-y-M-e'# Select the Workflow from the graph ( # From the top-level graph .["$graph"] # iterate over all entries (these are the Workflows and CommandLine Tools) [] # Select the entries of type workflow (just one) | select(.class == "Workflow") ) .inputs # Convert to normalized format (CWL allows explicit id or using the id as the key for a mapping instead) | to_entries # Check for presence of fields required by EOAP best practice | { inputs: map({ "id": .key, "label": .value.label, "doc": .value.doc, }) }'$1status=$?exit$status
2.11 Requirement 11: req/app-pck/metadata
The Application Package CWL Workclass classes SHALL include additional metadata as defined in Table 1
Required in table 1: version
yq is used to extract the s:version field of the CWL document. version is the only mandatory field in the table 1 of the best practice document. Here, s is a shorthand for "https://schema.org/", set as a namespace. The version field may also appear with the namespace expanded, so we check for that too.
All input parameters of the CWL ComandLineTool that require the staging of EO products SHALL be of type Directory.
yq is used to extract all inputs with type Directory from the CWL CommandLineTool object. This shows that each processor indeed processes EO data inputs. These inputs should match those provided with a catalog.json in the demonstration of Section 2.4.
Script
The script accepts as a first parameter the class of the CWL object (Workflow or CommandLineTool) to be checked. This is done, so that the same script can be used for Section 2.13.
#!/bin/env bash# Fails, if there are no directory typed inputs in the workflowecho"Running"status=1# yq arguments:# -M: No color# -e: Fail if nothing is foundCWL_CLASS=${1:Workflow}yq-y-M-e" # Select the workflow from the graph ( # From the top-level graph .[\"\$graph\"] # iterate over all entries (these are the Workflows and CommandLine Tools) [] # Select the entries of type workflow (just one) | select(.class == \"${CWL_CLASS}\") ) # Iterate over all entries of the \"inputs\" array .inputs # Select those that have type Directory | map(select(.type == \"Directory\")) # Wrap into an object with directory type | {\"inputs_with_directory_type\": .} "$2status=$?exit"$status"
2.13 Requirement 13: req/app-pck-stage-in/wf-stac
Input parameters of the CWL Workflow that require the staging of EO products SHALL be of type Directory.
yq is used to extract all inputs with type Directory from the CWL Workflow object. This shows that each processor indeed processes EO data inputs. These inputs should match those provided with a catalog.json in the demonstration of Section 2.4.
The same script used for Section 2.12 is used to verify this requirement.
The outputs field of the CommandLineTool that requires the stage-out of EO products SHALL retrieve all the files produced in the working directory.
The outputs field of the CWL CommandLineTool are extracted and shown to output all contents of the working directory with a glob filter of "." (representing the current directory). All outputs of type Directory (the staged-out EO products) are checked; outputs of other types, such as single intermediate files passed between workflow steps, are not concerned by this requirement.
yq is used to extract the fields of interest from the CWL document.
Script
The first call to yq extracts the outputs field, the second one makes sure the script fails if the outputs field does not extract the entire contents of the working directory.
#!/bin/env bashstatus_a=1status_b=1yq-y-M-e'# Select the CommandLineTool(s) from the graph ( # From the top-level graph .["$graph"] # iterate over all entries (these are the Workflows and CommandLine Tools) [] # Select the entries of type CommandLineTool | select(.class == "CommandLineTool") ) # Check for presence of fields required by EOAP best practice | .outputs'$1status_a=$?# Every output of type Directory (i.e. staged-out EO products) must retrieve the entire# working directory ("glob": "."). Outputs of other types (e.g. single intermediate# files passed between workflow steps) are not concerned by the requirement.all_dirs=$(yq-M-e' [ .["$graph"][] | select(.class == "CommandLineTool") | .outputs[] | select(.type == "Directory") | .outputBinding.glob == "." ] | length > 0 and all'$1)status_b=$?echo Extracts all items from Working directory: $all_dirs[[$status_a-eq 0 &&$status_b-eq 0 ]]