Skip to content

Commit e63bf56

Browse files
authored
Merge pull request #25 from xcube-dev/pont-24-tweak-cwl
Tweak CWL output
2 parents 8a43f9f + f756c65 commit e63bf56

File tree

6 files changed

+18
-10
lines changed

6 files changed

+18
-10
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Ignore magic commands in input notebooks (#14)
77
* Add NDVI sample notebook
88
* Improve STAC output
9+
* Tweak CWL format (#24)
910

1011
## Changes in 0.1.0
1112

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
- nbconvert
1212
- nbformat
1313
- pystac
14-
- pyyaml
14+
- pyyaml >=5.1 # need >=5.1 for sort_keys
1515
- xarray
1616
- xcube # See note below
1717
# test dependencies

examples/dynamic/dynamic.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"tags": []
2626
},
2727
"source": [
28-
"This notebook creates two simple synthetic datasets which are generated on the fly by xcube. It can be converted to a compute engine container using the `xcetool`."
28+
"This notebook creates two simple synthetic datasets which are generated on the fly by xcube. It can be converted to a compute engine container using `xcetool`."
2929
]
3030
},
3131
{

xcengine/cli.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,11 @@ def build(
150150
)
151151
image = image_builder.build()
152152
if eoap:
153-
eoap.write_text(yaml.dump(image_builder.create_cwl()))
153+
class IndentDumper(yaml.Dumper):
154+
def increase_indent(self, flow=False, indentless=False):
155+
return super(IndentDumper, self).increase_indent(flow, False)
156+
157+
eoap.write_text(yaml.dump(image_builder.create_cwl(), sort_keys=False, Dumper=IndentDumper))
154158
print(f"Built image with tags {image.tags}")
155159

156160

xcengine/core.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ def process_params_cell(self) -> None:
107107

108108
def create_cwl(self, image_tag: str) -> dict[str, Any]:
109109
script_id = "xce_script"
110-
output_id = "xce_output"
110+
output_id = "results"
111111
return {
112-
"cwlVersion": "v1.2",
112+
"cwlVersion": "v1.0",
113113
"$namespaces": {"s": "https://schema.org/"},
114114
"s:softwareVersion": "1.0.0",
115115
"schemas": [
@@ -118,16 +118,16 @@ def create_cwl(self, image_tag: str) -> dict[str, Any]:
118118
"$graph": [
119119
{
120120
"class": "Workflow",
121+
"id": "xcengine_ap",
121122
"label": "xcengine notebook",
122123
"doc": "xcengine notebook",
123-
"id": "main",
124124
"requirements": [],
125125
"inputs": self.nb_params.get_cwl_workflow_inputs(),
126126
"outputs": [
127127
{
128128
"id": "stac_catalog",
129-
"outputSource": [f"run_script/{output_id}"],
130129
"type": "Directory",
130+
"outputSource": [f"run_script/{output_id}"],
131131
}
132132
],
133133
"steps": {
@@ -144,6 +144,9 @@ def create_cwl(self, image_tag: str) -> dict[str, Any]:
144144
"requirements": {
145145
"DockerRequirement": {"dockerPull": image_tag}
146146
},
147+
"hints": {
148+
"DockerRequirement": {"dockerPull": image_tag}
149+
},
147150
"baseCommand": [
148151
"python3",
149152
"/home/mambauser/execute.py",
@@ -153,8 +156,8 @@ def create_cwl(self, image_tag: str) -> dict[str, Any]:
153156
"inputs": self.nb_params.get_cwl_commandline_inputs(),
154157
"outputs": {
155158
output_id: {
156-
"outputBinding": {"glob": "."},
157159
"type": "Directory",
160+
"outputBinding": {"glob": "."},
158161
}
159162
},
160163
},

xcengine/parameters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ def get_cwl_commandline_inputs(self) -> dict[str, dict[str, Any]]:
101101
def get_cwl_workflow_input(self, var_name: str) -> dict[str, Any]:
102102
type_, default_ = self.params[var_name]
103103
return {
104+
"label": var_name,
105+
"doc": var_name,
104106
"type": self.cwl_type(type_),
105107
"default": default_,
106-
"doc": var_name,
107-
"label": var_name,
108108
}
109109

110110
def get_cwl_commandline_input(self, var_name: str) -> dict[str, Any]:

0 commit comments

Comments
 (0)