Shell Script Exports¶
The configuration for a GPC container node includes an export field that is supported only for Python scripts.
If you want to execute shell scripts within a container node, you must use the following method to export values for use in tests.
Step 1: shell script commands¶
First, add echo commands in the shell script that will write value outputs to files in the node's docker-share directory.
echo -n "exportvalue_1" > "docker-share/file-out.csv"
echo -n "exportvalue_2" > "docker-share/script_output.txt"
Step 2: variable assignment¶
To reference the output values in tests, the values need to be associated with variables. Assign variables to the output files in the recipe's notebook.json.
"assign-variables": [
{
"name": "output_as_a_file",
"file": "file-out.csv"
}
,
{
"name": "output_as_a_file_script",
"file": "script_output.txt"
}
],
Step 3: tests configuration¶
The variables assigned in notebook.json can then be referenced in node tests.
{
"image-repo": "{{dockerhubConfig.image_repo.general_purpose}}",
"image-tag": "{{dockerhubConfig.image_tag.general_purpose}}",
"dockerhub-namespace": "{{dockerhubConfig.namespace.general_purpose}}",
"dockerhub-username": "{{dockerhubConfig.username}}",
"dockerhub-password": "{{dockerhubConfig.password}}",
"tests": {
"test-output-as-a-file-from-script": {
"test-variable": "output_as_a_file_script",
"action": "stop-on-error",
"type": "test-contents-as-string",
"test-logic": "output_as_a_file_script == 'cbergh'",
"keep-history": true,
"description": ""
}
}
}