Open fmigneault opened 2 months ago
Error on my end.
If the format
is updated with the expected structure from the script, all format values work as expected and interchangeably.
features:
class: File
path: /tmp/feature-0.geojson
format: "ogc-term:FeatureCollection"
OR
features:
class: File
path: /tmp/feature-0.geojson
format: "http://www.opengis.net/def/glossary/term/FeatureCollection"
features:
- class: File
path: /tmp/feature-0.geojson
format: "iana:application/geo+json"
OR
features:
- class: File
path: /tmp/feature-0.geojson
format: "https://www.iana.org/assignments/media-types/application/geo+json"
Further investigation reveals that this is actually still an issue.
More specifically, if the input is defined with the following, everything works
(everything, as in, whether the full URI or namespace variant are used in job.yml
, the job succeeds).
inputs:
features:
format: |
${
if (Array.isArray(inputs.features)) {
return "https://www.iana.org/assignments/media-types/application/geo+json";
}
return "http://www.opengis.net/def/glossary/term/FeatureCollection";
}
However, if using the namespace format
inside the CWL expression, as below, the job always fails, no matter which format
variant is provided in job.yml
.
inputs:
features:
format: |
${
if (Array.isArray(inputs.features)) {
return "iana:application/geo+json";
}
return "ogc-term:FeatureCollection";
}
With the namespace format
in the CWL expression, 2 errors happen according to the format
provided in job.yml
.
The job format
is also the namespaced value (trying to do an ==
match with the evaluated CWL expression). The error is simply the generic schema_salad.exceptions.ValidationException: File has an incompatible format
.
The job format
is the full URI. This causes a parsing error (looking for some name
key?) with the following traceback.
Traceback (most recent call last):
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/builder.py", line 554, in bind_input
check_format(
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwl_utils/file_formats.py", line 70, in check_format
raise ValidationException(
schema_salad.exceptions.ValidationException: File has an incompatible format: {
"class": "File",
"format": "https://www.iana.org/assignments/media-types/application/geo+json",
"location": "file:///tmp/feature-0.geojson",
"size": 162,
"basename": "feature-0.geojson",
"nameroot": "feature-0",
"nameext": ".geojson"
}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/executors.py", line 218, in run_jobs
for job in jobiter:
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/command_line_tool.py", line 963, in job
builder = self._init_job(job_order, runtimeContext)
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/process.py", line 888, in _init_job
builder.bind_input(
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/builder.py", line 330, in bind_input
self.bind_input(
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/builder.py", line 262, in bind_input
self.bind_input(
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/builder.py", line 288, in bind_input
self.bind_input(
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/builder.py", line 355, in bind_input
self.bind_input(
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/builder.py", line 561, in bind_input
f"Expected value of {schema['name']!r} to have "
KeyError: 'name'
ERROR Workflow error:
'name'
Traceback (most recent call last):
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/builder.py", line 554, in bind_input
check_format(
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwl_utils/file_formats.py", line 70, in check_format
raise ValidationException(
schema_salad.exceptions.ValidationException: File has an incompatible format: {
"class": "File",
"format": "https://www.iana.org/assignments/media-types/application/geo+json",
"location": "file:///tmp/feature-0.geojson",
"size": 162,
"basename": "feature-0.geojson",
"nameroot": "feature-0",
"nameext": ".geojson"
}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/executors.py", line 218, in run_jobs
for job in jobiter:
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/command_line_tool.py", line 963, in job
builder = self._init_job(job_order, runtimeContext)
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/process.py", line 888, in _init_job
builder.bind_input(
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/builder.py", line 330, in bind_input
self.bind_input(
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/builder.py", line 262, in bind_input
self.bind_input(
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/builder.py", line 288, in bind_input
self.bind_input(
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/builder.py", line 355, in bind_input
self.bind_input(
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/builder.py", line 561, in bind_input
f"Expected value of {schema['name']!r} to have "
KeyError: 'name'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/main.py", line 1298, in main
(out, status) = real_executor(
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/executors.py", line 62, in __call__
return self.execute(process, job_order_object, runtime_context, logger)
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/executors.py", line 145, in execute
self.run_jobs(process, job_order_object, logger, runtime_context)
File "/home/francis/dev/conda/envs/weaver-py310/lib/python3.10/site-packages/cwltool/executors.py", line 252, in run_jobs
raise WorkflowException(str(err)) from err
cwltool.errors.WorkflowException: 'name'
Expected Behavior
When using a file
format
with a JS expression (workaround for https://github.com/common-workflow-language/cwl-v1.3/issues/52), theformat
check should consider any relevant resolution of$namespaces
beforehand.Actual Behavior
The
format
check fails if the input file format and the evaluated format do not match exactly. Since$namespaces
can be used to write equivalent formats (i.e.:https://www.iana.org/assignments/media-types/application/geo+json
↔iana:application/geo+json
), they should be considered interchangeably. However, theformat
expression fails unless the evaluated format is explicitly written in its long form (ie: the full URI).Given that inputs submitted (in
job.yml
) either with the long-form URI or the namespace'dformat
are both converted to the long-form URI when reaching the below check, this forces the JS expression to use the long-form URI to be considered valid. https://github.com/common-workflow-language/cwltool/blob/6d8c2a41e2c524e8d746020cc91711ecc3418a23/cwltool/builder.py#L555-L559However, for a user writing the CWL document that defined a
$namespace
section, it is very counter-intuitive to use the long-form URI only in theformat
expression, when everywhere else acceptsiana:application/geo+json
.Workflow Code
job.yml
OR
echo_features.cwl
Full Traceback
Your Environment