Skip to content

Commit 4353390

Browse files
committed
Update notebook to change inline text to reflect what the
unity-app-generator is doing. Add test scripts for running the now default modular app approach. Rename the old test scripts director to reflect it for the monolithic app approach.
1 parent af054f3 commit 4353390

11 files changed

+94
-42
lines changed

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ env/
77
# Jupyter temporary directory
88
.ipynb_checkpoints/
99

10-
# Output from process.ipynb
11-
summary_table.txt
12-
process_results.json
10+
# User created monolithic app job input file derived from template
11+
test/monolithic_app/cwl_job_input.yml
12+
13+
# Output from process.ipynb and test scripts
1314
test/process_results/
1415

1516
# Unity App Generator file

process.ipynb

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"\n",
3333
"The below cell is tagged as a 'paramter' cell. This enables us to overwrite the below values at runtime. There are some special values in the below cell.\n",
3434
"\n",
35-
"* `input` is a special name, and it also has the `# type: stage-in` annotation. This should be a directory, and at run time it will be populated with a STAC catalog that contains files that have been staged for your algorithm to reference.\n",
36-
"* `output` is a special name, and it also has the `# type: stage-out` annotation. This should be treated as a directory to which you write ALL of your output files along with a STAC catalog that references files you would like to persist outside of the algorithm run."
35+
"* `input_stac_catalog_dir` has the `# type: stage-in` annotation. This variable tells your algorithm the name of the directory where to read inputs from. At run time it will be populated with a STAC catalog and the files it references. The application generator process will connect your variable name to the special `input` parameter in automatically generated CWL files.\n",
36+
"* `output_stac_catalog_dir` has the `# type: stage-out` annotation. This is a directory where you write ALL of your output files along with a STAC catalog that references files you would like to persist outside of the algorithm run. The application generator process will connect your variable name to the special `output` parameter in automatically generated CWL files."
3737
]
3838
},
3939
{
@@ -51,8 +51,8 @@
5151
},
5252
"outputs": [],
5353
"source": [
54-
"input = 'test/stage_in/' # type: stage-in\n",
55-
"output = 'test/process_results/' # type: stage-out\n",
54+
"input_stac_catalog_dir = 'test/stage_in/' # type: stage-in\n",
55+
"output_stac_catalog_dir = 'test/process_results/' # type: stage-out\n",
5656
"\n",
5757
"# Filename written to the working directory\n",
5858
"summary_table_filename = \"summary_table.txt\"\n",
@@ -70,7 +70,7 @@
7070
},
7171
{
7272
"cell_type": "code",
73-
"execution_count": 8,
73+
"execution_count": 3,
7474
"id": "62471f5d-d898-46c1-89c1-b572851db551",
7575
"metadata": {},
7676
"outputs": [
@@ -83,7 +83,7 @@
8383
}
8484
],
8585
"source": [
86-
"input_catalog = os.path.join(input, \"catalog.json\")\n",
86+
"input_catalog = os.path.join(input_stac_catalog_dir, \"catalog.json\")\n",
8787
"print(\"reading {}\".format(input_catalog))"
8888
]
8989
},
@@ -99,7 +99,7 @@
9999
},
100100
{
101101
"cell_type": "code",
102-
"execution_count": 10,
102+
"execution_count": 4,
103103
"id": "2eeaa5d4",
104104
"metadata": {},
105105
"outputs": [
@@ -123,7 +123,7 @@
123123
"'<table>\\n<thead>\\n<tr><th>argument_name </th><th>type </th><th>value </th></tr>\\n</thead>\\n<tbody>\\n<tr><td>example_argument_int </td><td>&lt;class &#x27;int&#x27;&gt; </td><td>1 </td></tr>\\n<tr><td>example_argument_float </td><td>&lt;class &#x27;float&#x27;&gt; </td><td>1.0 </td></tr>\\n<tr><td>example_argument_string</td><td>&lt;class &#x27;str&#x27;&gt; </td><td>string </td></tr>\\n<tr><td>example_argument_bool </td><td>&lt;class &#x27;bool&#x27;&gt; </td><td>True </td></tr>\\n<tr><td>example_argument_empty </td><td>&lt;class &#x27;NoneType&#x27;&gt;</td><td> </td></tr>\\n</tbody>\\n</table>'"
124124
]
125125
},
126-
"execution_count": 10,
126+
"execution_count": 4,
127127
"metadata": {},
128128
"output_type": "execute_result"
129129
}
@@ -158,18 +158,18 @@
158158
},
159159
{
160160
"cell_type": "code",
161-
"execution_count": 11,
161+
"execution_count": 5,
162162
"id": "3a09d57c",
163163
"metadata": {},
164164
"outputs": [
165165
{
166166
"data": {
167167
"text/plain": [
168-
"['/Users/gangl/dev/unity/unity-OGC-example-application/test/stage_in/./SNDR.SS1330.CHIRP.20160822T0005.m06.g001.L1_AQ.std.v02_48.G.200425095850.nc',\n",
169-
" '/Users/gangl/dev/unity/unity-OGC-example-application/test/stage_in/./SNDR.SS1330.CHIRP.20160822T0011.m06.g002.L1_AQ.std.v02_48.G.200425095901.nc']"
168+
"['test/stage_in/SNDR.SS1330.CHIRP.20160822T0005.m06.g001.L1_AQ.std.v02_48.G.200425095850.nc',\n",
169+
" 'test/stage_in/SNDR.SS1330.CHIRP.20160822T0011.m06.g002.L1_AQ.std.v02_48.G.200425095901.nc']"
170170
]
171171
},
172-
"execution_count": 11,
172+
"execution_count": 5,
173173
"metadata": {},
174174
"output_type": "execute_result"
175175
}
@@ -178,7 +178,8 @@
178178
"inp_collection = Collection.from_stac(input_catalog)\n",
179179
"data_filenames = inp_collection.data_locations()\n",
180180
"\n",
181-
"data_filenames"
181+
"# Scrub base part of path so it is not displayed in Github with a home directory prefix\n",
182+
"[ os.path.relpath(fn, os.curdir) for fn in data_filenames ]"
182183
]
183184
},
184185
{
@@ -193,7 +194,7 @@
193194
},
194195
{
195196
"cell_type": "code",
196-
"execution_count": 12,
197+
"execution_count": 6,
197198
"id": "9fbac209",
198199
"metadata": {},
199200
"outputs": [],
@@ -213,7 +214,7 @@
213214
},
214215
{
215216
"cell_type": "code",
216-
"execution_count": 13,
217+
"execution_count": 7,
217218
"id": "d22c8670",
218219
"metadata": {},
219220
"outputs": [],
@@ -230,7 +231,7 @@
230231
},
231232
{
232233
"cell_type": "code",
233-
"execution_count": 14,
234+
"execution_count": 8,
234235
"id": "3344bd15",
235236
"metadata": {},
236237
"outputs": [
@@ -251,7 +252,7 @@
251252
"'<table>\\n<thead>\\n<tr><th>product_name </th><th>product_name_type_id </th><th>shortname </th><th>product_version </th><th>date_created </th><th>time_coverage_start </th><th>time_coverage_end </th><th style=\"text-align: right;\"> geospatial_lat_mid</th><th style=\"text-align: right;\"> geospatial_lon_mid</th></tr>\\n</thead>\\n<tbody>\\n<tr><td>SNDR.SS1330.CHIRP.20160822T0005.m06.g001.L1_AQ.std.v02_48.G.200425095850.nc</td><td>L1_AQ </td><td>SNDR13CHRP1</td><td>v02.48.00 </td><td>2021-04-25T05:59:08Z</td><td>2016-08-22T00:05:22Z </td><td>2016-08-22T00:11:22Z</td><td style=\"text-align: right;\"> -48.6062</td><td style=\"text-align: right;\"> 12.4563 </td></tr>\\n<tr><td>SNDR.SS1330.CHIRP.20160822T0011.m06.g002.L1_AQ.std.v02_48.G.200425095901.nc</td><td>L1_AQ </td><td>SNDR13CHRP1</td><td>v02.48.00 </td><td>2021-04-25T05:59:19Z</td><td>2016-08-22T00:11:22Z </td><td>2016-08-22T00:17:22Z</td><td style=\"text-align: right;\"> -69.3979</td><td style=\"text-align: right;\"> -1.98753</td></tr>\\n</tbody>\\n</table>'"
252253
]
253254
},
254-
"execution_count": 14,
255+
"execution_count": 8,
255256
"metadata": {},
256257
"output_type": "execute_result"
257258
}
@@ -263,14 +264,14 @@
263264
},
264265
{
265266
"cell_type": "code",
266-
"execution_count": 16,
267+
"execution_count": 9,
267268
"id": "014257f3",
268269
"metadata": {},
269270
"outputs": [],
270271
"source": [
271272
"# Write the table in text format\n",
272-
"pathlib.Path(output).mkdir(parents=True, exist_ok=True)\n",
273-
"output_filename = os.path.join(output, summary_table_filename)\n",
273+
"pathlib.Path(output_stac_catalog_dir).mkdir(parents=True, exist_ok=True)\n",
274+
"output_filename = os.path.join(output_stac_catalog_dir, summary_table_filename)\n",
274275
"with open(output_filename, \"w\") as summary_file:\n",
275276
" summary_file.write(tabulate(table_data, headers=column_names))"
276277
]
@@ -285,7 +286,7 @@
285286
},
286287
{
287288
"cell_type": "code",
288-
"execution_count": 18,
289+
"execution_count": 10,
289290
"id": "b4aa5d3b",
290291
"metadata": {
291292
"editable": true,
@@ -303,38 +304,30 @@
303304
"dataset = Dataset(\n",
304305
" name=summary_table_filename, \n",
305306
" collection_id=out_collection.collection_id, \n",
306-
" start_time=datetime.utcnow().replace(tzinfo=timezone.utc).isoformat(), \n",
307-
" end_time=datetime.utcnow().replace(tzinfo=timezone.utc).isoformat(),\n",
308-
" creation_time=datetime.utcnow().replace(tzinfo=timezone.utc).isoformat(),\n",
307+
" start_time=datetime.now(timezone.utc).isoformat(), \n",
308+
" end_time=datetime.now(timezone.utc).isoformat(),\n",
309+
" creation_time=datetime.now(timezone.utc).isoformat(),\n",
309310
")\n",
310311
"\n",
311312
"# Add output file(s) to the dataset\n",
312313
"dataset.add_data_file(DataFile(\"csv\", summary_table_filename, [\"data\"]))\n",
313314
"\n",
314315
"#when we run \"to_stac\" below, this file will be generated. this needs to be added to the stac file itself for future reference.\n",
315-
"dataset.add_data_file(DataFile(\"json\", output + \"/\" + summary_table_filename +'.json', [\"metadata\"] ))\n",
316+
"dataset.add_data_file(DataFile(\"json\", os.path.join(output_stac_catalog_dir, summary_table_filename + '.json'), [\"metadata\"] ))\n",
316317
"\n",
317318
"\n",
318319
"# Add the dataset to the collection\n",
319320
"#out_collection.add_dataset(dataset)\n",
320321
"out_collection._datasets.append(dataset)\n",
321322
"\n",
322-
"Collection.to_stac(out_collection, output)"
323+
"Collection.to_stac(out_collection, output_stac_catalog_dir)"
323324
]
324-
},
325-
{
326-
"cell_type": "code",
327-
"execution_count": null,
328-
"id": "14f240b6-b5ea-4bf8-8764-ecf12eee6c16",
329-
"metadata": {},
330-
"outputs": [],
331-
"source": []
332325
}
333326
],
334327
"metadata": {
335328
"celltoolbar": "Tags",
336329
"kernelspec": {
337-
"display_name": "Python 3 (ipykernel)",
330+
"display_name": "Python 3",
338331
"language": "python",
339332
"name": "python3"
340333
},
@@ -348,7 +341,7 @@
348341
"name": "python",
349342
"nbconvert_exporter": "python",
350343
"pygments_lexer": "ipython3",
351-
"version": "3.10.8"
344+
"version": "3.12.4"
352345
}
353346
},
354347
"nbformat": 4,

test/ogc_app/build_app.sh renamed to test/modular_app/build_app.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ cd $BASE_DIR
99
build_ogc_app init .
1010

1111
build_ogc_app build_docker
12-
build_ogc_app build_cwl
12+
build_ogc_app build_cwl

test/modular_app/cwl_job_input.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
input: # type 'Directory'
2+
class: Directory
3+
path: ../stage_in
4+
summary_table_filename: summary_table.txt # default value of type 'string'.
5+
output_collection: urn:nasa:unity:unity:dev:unity-example-application___1 # default value of type 'string'.
6+
example_argument_string: string # default value of type 'string'.
7+
example_argument_int: 1 # default value of type 'int'.
8+
example_argument_float: 1.0 # default value of type 'float'.
9+
example_argument_empty: a_string # type 'string'
10+
example_argument_bool: true # default value of type 'boolean'.

test/modular_app/test_cwl.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
SCRIPT_DIR=$(realpath $(dirname $0))
4+
BASE_DIR=$(realpath $(dirname $0)/../..)
5+
6+
WORKFLOW_FILENAME=$BASE_DIR/.unity_app_gen/cwl/process.cwl
7+
JOB_INP_FILENAME=$SCRIPT_DIR/cwl_job_input.yml
8+
RUN_DIR=$BASE_DIR/test/process_results
9+
10+
if [ ! -e $WORKFLOW_FILENAME ]; then
11+
echo "ERROR: Run $SCRIPT_DIR/build_app.sh first to generate CWL output"
12+
exit 1
13+
fi
14+
15+
if [ ! -e $JOB_INP_FILENAME ]; then
16+
echo "ERROR: Copy ${JOB_INP_FILENAME}.template to ${JOB_INP_FILENAME} and edit to include credentials"
17+
exit 1
18+
fi
19+
20+
mkdir -p $RUN_DIR
21+
cd $RUN_DIR
22+
23+
# Detect if using Podman
24+
if [ ! -z "$(which podman)" ]; then
25+
use_podman_arg="--podman"
26+
fi
27+
28+
cwltool \
29+
--debug --leave-tmpdir --no-read-only \
30+
$use_podman_arg \
31+
"$WORKFLOW_FILENAME" "$JOB_INP_FILENAME" \
32+
$* |& tee $RUN_DIR/test_modular_cwl.log

test/monolithic_app/build_app.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
BASE_DIR=$(realpath $(dirname $0)/../..)
6+
7+
cd $BASE_DIR
8+
9+
build_ogc_app init .
10+
11+
build_ogc_app build_docker
12+
build_ogc_app build_cwl --monolithic
File renamed without changes.

test/ogc_app/cwl_job_input.yml.template renamed to test/monolithic_app/cwl_job_input.yml.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ stage_out: # Anonymous record type.
2121
aws_region: us-west-2
2222
aws_session_token: null
2323
aws_secret_access_key: null
24-
aws_access_key_id: null
24+
aws_access_key_id: null

test/ogc_app/test_cwl.sh renamed to test/monolithic_app/test_cwl.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ BASE_DIR=$(realpath $(dirname $0)/../..)
55

66
WORKFLOW_FILENAME=$BASE_DIR/.unity_app_gen/cwl/workflow.cwl
77
JOB_INP_FILENAME=$SCRIPT_DIR/cwl_job_input.yml
8+
RUN_DIR=$BASE_DIR/test/process_results
89

910
if [ ! -e $WORKFLOW_FILENAME ]; then
1011
echo "ERROR: Run $SCRIPT_DIR/build_app.sh first to generate CWL output"
@@ -44,6 +45,9 @@ done
4445
echo "Using modified job input file $modified_job_inp_file:"
4546
cat $modified_job_inp_file
4647

48+
mkdir -p $RUN_DIR
49+
cd $RUN_DIR
50+
4751
# Detect if using Podman
4852
if [ ! -z "$(which podman)" ]; then
4953
use_podman_arg="--podman"
@@ -53,6 +57,6 @@ cwltool \
5357
--debug --leave-tmpdir --no-read-only \
5458
$use_podman_arg \
5559
"$WORKFLOW_FILENAME" "$modified_job_inp_file" \
56-
$*
60+
$* |& tee $RUN_DIR/test_monolithic_cwl.log
5761

5862
rm $modified_job_inp_file

0 commit comments

Comments
 (0)