-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid definition of default value in sample YAML file #252
Comments
Same in cwl-v1.2/tests/floats_small_and_large_nojs.cwl Lines 16 to 19 in d50fad0
|
I don't see the requirement for a +/- symbol in the YAML specs: https://yaml.org/spec/1.2.1/#tag/repository/float Using the provided regex from the YAML spec, I get a match for your example: https://regex101.com/r/j5Fsu5/1 Maybe switch to using a different YAML library, like ruamel.yaml? https://pypi.org/project/ruamel.yaml/ See also yaml/pyyaml#173 |
This is weird. Even their own JSON sample doesn't work. And this is using the builtin json library. j = json.loads('[ 0., -0.0, 12e03, -2E+05 ]')
Traceback (most recent call last):
File "/home/francis/dev/conda/envs/terradue/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3508, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-13-ae4e14ea774e>", line 1, in <module>
j = json.loads('[ 0., -0.0, 12e03, -2E+05 ]')
File "/home/francis/dev/conda/envs/terradue/lib/python3.10/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/home/francis/dev/conda/envs/terradue/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/francis/dev/conda/envs/terradue/lib/python3.10/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 4 (char 3) We need to add quotes around the j = json.loads('[ "0.", -0.0, "12e03", -2E+05 ]')
j
['0.', -0.0, '12e03', -200000.0] Adding a j = json.loads('[ "0.", -0.0, 12e+03, -2E+05 ]')
j
['0.', -0.0, 12000.0, -200000.0] |
Same behaviour occurs using https://pypi.org/project/simplejson, the most common alternative I have seen to builtin Really annoying... but yes, import yaml
import ruamel.yaml as ryaml
yaml.safe_load('[ 0., -0.0, 12e03, -2E+05 ]')
[0.0, -0.0, '12e03', '-2E+05']
yaml.safe_load('[ 0., -0.0, 12.e03, -2E+05 ]')
[0.0, -0.0, '12.e03', '-2E+05']
yaml.safe_load('[ 0., -0.0, 12.e+03, -2E+05 ]')
[0.0, -0.0, 12000.0, '-2E+05']
ryaml.safe_load('[ 0., -0.0, 12e03, -2E+05 ]')
[0.0, -0.0, 12000.0, -200000.0] |
Thanks for the investigation @fmigneault . I'm going to close this issue. |
The following definition, although it really resembles a valid float, is actually parsed as string in YAML.
cwl-v1.2/tests/floats_small_and_large.cwl
Lines 19 to 21 in d50fad0
The scientific notation requires a
+
/-
symbol.Because the CWL test passes the values as strings on the command line, I'm guessing this silently succeeds.
However, the JSON schema validation I'm working on (opengeospatial/ogcapi-processes#329) fails for this tool with the invalid match of
type: float
not equal todefault
's type.The text was updated successfully, but these errors were encountered: