Skip to content

Commit 22d14f9

Browse files
committed
added workflow example, added output_collection parameter to example app
1 parent 8fa5d04 commit 22d14f9

5 files changed

+145
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ env/
1010
# Output from process.ipynb
1111
summary_table.txt
1212
process_results.json
13+
test/process_results/
1314

1415
# Unity App Generator file
1516
.unity_app_gen

process.ipynb

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"outputs": [],
99
"source": [
1010
"import os\n",
11+
"import pathlib\n",
1112
"\n",
1213
"# Application packages\n",
1314
"from tabulate import tabulate\n",
@@ -34,17 +35,21 @@
3435
"outputs": [],
3536
"source": [
3637
"input_stac_collection_file = 'test/stage_in/stage_in_results.json' # type: stage-in\n",
37-
"output_stac_catalog_dir = 'process_results/' # type: stage-out\n",
38+
"output_stac_catalog_dir = 'test/process_results/' # type: stage-out\n",
3839
"\n",
3940
"# Filename written to the working directory\n",
4041
"summary_table_filename = \"summary_table.txt\"\n",
4142
"\n",
43+
"#For eventual catalogging of this file in the unity environment\n",
44+
"output_collection=\"example-app-collection___1\"\n",
45+
"\n",
46+
"\n",
4247
"# Examples of optional arbitrary arguments of different data types\n",
4348
"example_argument_int = 1\n",
4449
"example_argument_float = 1.0\n",
4550
"example_argument_string = \"string\"\n",
4651
"example_argument_bool = True\n",
47-
"example_argument_empty = None # type: string Allow a null value or a string"
52+
"example_argument_empty = None # type: string Allow a null value or a string\n"
4853
]
4954
},
5055
{
@@ -125,8 +130,8 @@
125130
{
126131
"data": {
127132
"text/plain": [
128-
"['/home/mcduffie/Devel/unity/unity-example-application/test/stage_in/./SNDR.SS1330.CHIRP.20160822T0005.m06.g001.L1_AQ.std.v02_48.G.200425095850.nc',\n",
129-
" '/home/mcduffie/Devel/unity/unity-example-application/test/stage_in/./SNDR.SS1330.CHIRP.20160822T0011.m06.g002.L1_AQ.std.v02_48.G.200425095901.nc']"
133+
"['/Users/gangl/dev/unity/unity-example-application/test/stage_in/./SNDR.SS1330.CHIRP.20160822T0005.m06.g001.L1_AQ.std.v02_48.G.200425095850.nc',\n",
134+
" '/Users/gangl/dev/unity/unity-example-application/test/stage_in/./SNDR.SS1330.CHIRP.20160822T0011.m06.g002.L1_AQ.std.v02_48.G.200425095901.nc']"
130135
]
131136
},
132137
"execution_count": 4,
@@ -229,6 +234,7 @@
229234
"outputs": [],
230235
"source": [
231236
"# Write the table in text format\n",
237+
"pathlib.Path(output_stac_catalog_dir).mkdir(parents=True, exist_ok=True)\n",
232238
"output_filename = os.path.join(output_stac_catalog_dir, summary_table_filename)\n",
233239
"with open(output_filename, \"w\") as summary_file:\n",
234240
" summary_file.write(tabulate(table_data, headers=column_names))"
@@ -250,7 +256,7 @@
250256
"outputs": [],
251257
"source": [
252258
"# Create a collection\n",
253-
"out_collection = Collection(\"SNDR13CHRP1AQCal_rebin\")\n",
259+
"out_collection = Collection(output_collection)\n",
254260
" \n",
255261
"# Create a Dataset for the collection\n",
256262
"dataset = Dataset(\n",
@@ -264,12 +270,24 @@
264270
"# Add output file(s) to the dataset\n",
265271
"dataset.add_data_file(DataFile(\"data\", summary_table_filename))\n",
266272
"\n",
273+
"#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",
274+
"dataset.add_data_file(DataFile(\"metadata\", output_stac_catalog_dir + summary_table_filename +'.json' ))\n",
275+
"\n",
276+
"\n",
267277
"# Add the dataset to the collection\n",
268278
"#out_collection.add_dataset(dataset)\n",
269279
"out_collection._datasets.append(dataset)\n",
270280
"\n",
271281
"Collection.to_stac(out_collection, output_stac_catalog_dir)"
272282
]
283+
},
284+
{
285+
"cell_type": "code",
286+
"execution_count": null,
287+
"id": "14f240b6-b5ea-4bf8-8764-ecf12eee6c16",
288+
"metadata": {},
289+
"outputs": [],
290+
"source": []
273291
}
274292
],
275293
"metadata": {
@@ -289,7 +307,7 @@
289307
"name": "python",
290308
"nbconvert_exporter": "python",
291309
"pygments_lexer": "ipython3",
292-
"version": "3.10.12"
310+
"version": "3.10.8"
293311
}
294312
},
295313
"nbformat": 4,

workflow/workflow.cwl

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/usr/bin/env cwl-runner
2+
cwlVersion: v1.1
3+
class: Workflow
4+
label: Workflow that executes the SBG L1 Workflow
5+
6+
$namespaces:
7+
cwltool: http://commonwl.org/cwltool#
8+
9+
requirements:
10+
SubworkflowFeatureRequirement: {}
11+
ScatterFeatureRequirement: {}
12+
InlineJavascriptRequirement: {}
13+
StepInputExpressionRequirement: {}
14+
MultipleInputFeatureRequirement: {}
15+
16+
17+
## Inputs to the e2e rebinning, not to each applicaiton within the workflow
18+
inputs:
19+
20+
# For CMR Search Step
21+
input_cmr_collection_name: string
22+
input_cmr_search_start_time: string
23+
input_cmr_search_stop_time: string
24+
25+
# catalog inputs
26+
input_unity_dapa_api: string
27+
input_unity_dapa_client: string
28+
29+
#for exemple-app step
30+
input_summary_table_filename: string
31+
input_example_argument_int: int
32+
input_example_argument_float: float
33+
input_example_argument_string: string
34+
input_example_argument_bool: boolean
35+
input_example_argument_empty: string, null
36+
37+
# For unity data stage-out step, unity catalog
38+
output_collection_id: string
39+
output_data_bucket: string
40+
41+
outputs:
42+
results:
43+
type: File
44+
outputSource: example-app/stage_out_result
45+
46+
steps:
47+
cmr-step:
48+
run: http://awslbdockstorestack-lb-1429770210.us-west-2.elb.amazonaws.com:9998/api/ga4gh/trs/v2/tools/%23workflow%2Fdockstore.org%2Fmike-gangl%2Fcmr-trial/versions/2/PLAIN-CWL/descriptor/%2FDockstore.cwl
49+
in:
50+
cmr_collection : input_cmr_collection_name
51+
cmr_start_time: input_cmr_search_start_time
52+
cmr_stop_time: input_cmr_search_stop_time
53+
out: [results]
54+
example-app:
55+
run: http://awslbdockstorestack-lb-1429770210.us-west-2.elb.amazonaws.com:9998/api/ga4gh/trs/v2/tools/%23workflow%2Fdockstore.org%2Fedwinsarkissian%2Funity-example-application/versions/56/PLAIN-CWL/descriptor/%2Fworkflow.cwl
56+
in:
57+
# input configuration for stage-in
58+
# edl_password_type can be either 'BASE64' or 'PARAM_STORE' or 'PLAIN'
59+
# README available at https://github.com/unity-sds/unity-data-services/blob/main/docker/Readme.md
60+
stage_in:
61+
source: [cmr-step/results]
62+
valueFrom: |
63+
${
64+
return {
65+
download_type: 'DAAC',
66+
stac_json: self,
67+
edl_password: '/sps/processing/workflows/edl_password',
68+
edl_username: '/sps/processing/workflows/edl_username',
69+
edl_password_type: 'PARAM_STORE',
70+
downloading_keys: 'data',
71+
log_level: '20'
72+
};
73+
}
74+
#input configuration for example process
75+
# Here we map the inputs to the workflow into the example-process inputs
76+
parameters:
77+
source: [output_collection_id]
78+
valueFrom: |
79+
${
80+
return {
81+
summary_table_filename: input_summary_table_filename,
82+
example_argument_int: input_example_argument_int,
83+
example_argument_float: input_example_argument_float,
84+
example_argument_string: input_example_argument_string,
85+
example_argument_bool: input_example_argument_bool,
86+
example_argument_empty: input_example_argument_empty,
87+
output_collection: self[0]
88+
};
89+
}
90+
#input configuration for stage-out
91+
# readme available at https://github.com/unity-sds/unity-data-services/blob/main/docker/Readme.md
92+
stage_out:
93+
source: [output_data_bucket, output_collection_id]
94+
valueFrom: |
95+
${
96+
return {
97+
aws_access_key_id: '',
98+
aws_region: 'us-west-2',
99+
aws_secret_access_key: '',
100+
aws_session_token: '',
101+
collection_id: self[1],
102+
staging_bucket: self[0],
103+
log_level: '20'
104+
};
105+
}
106+
out: [stage_out_results]
107+
data-catalog:
108+
#run: catalog/catalog.cwl
109+
run: http://awslbdockstorestack-lb-1429770210.us-west-2.elb.amazonaws.com:9998/api/ga4gh/trs/v2/tools/%23workflow%2Fdockstore.org%2Fmike-gangl%2Fcatalog-trial/versions/7/PLAIN-CWL/descriptor/%2FDockstore.cwl
110+
in:
111+
unity_username:
112+
valueFrom: "/sps/processing/workflows/unity_username"
113+
unity_password:
114+
valueFrom: "/sps/processing/workflows/unity_password"
115+
password_type:
116+
valueFrom: "PARAM_STORE"
117+
unity_client_id: input_unity_dapa_client
118+
unity_dapa_api: input_unity_dapa_api
119+
uploaded_files_json: example-app/stage_out_results
120+
out: [results]

0 commit comments

Comments
 (0)