Repository navigation
refactor!: retire wic_loader; parse() is the only .wic reader - #525
Conversation
82be2d5 to
777c60e
Compare
darkclad
left a comment
There was a problem hiding this comment.
The parser side matches the description. I probed it against #516's head: a tagged key (!ii a: b, !cwl a: b, {!* k: v} inside !ii) is now one wic005 per key, not "unhashable key". !ii 2020-13-45 is wic009 with the same message as the plain value, the quoted form stays text, and !ii cycles are still wic030. tests/core + tests/contrib fail on the same 83 docker/cwltool-run tests at #516 and here on this Windows box, and the PR adds 2 passing tests. wfb_to_wic output is identical over every payload in tests/contrib. One comment on the converter, non-blocking.
| for nkey in node['in']: | ||
| if str(node['in'][nkey]) != "": | ||
| node['in'][nkey] = _tag_value(Tag.INLINE_INPUT, node['in'][nkey]) | ||
| node['in'][nkey] = {Key.INLINE_INPUT: node['in'][nkey]} |
There was a problem hiding this comment.
This changes what the REST converter produces, and the CHANGELOG doesn't mention it. _tag_value re-read str(value) as YAML, so a WFB setting went through YAML a second time. Now it's kept as sent, which is a fix in most cases: *.tif, @x or %p used to crash the converter (ScannerError), {row:c}... became a mapping, x # y was cut to x, and a null became the string 'None'. But string settings that look like scalars change type: "5", "0.5", "true" and "2020-01-02" used to become int/float/bool/date, and now they stay strings. The fixtures send numbers as JSON numbers, so none of them changes. Could you add a CHANGELOG line, and a small wfb_to_wic test that pins a value like *.tif or {row:c}?
There was a problem hiding this comment.
Agreed. I added a line to the 0.7.0 upgrade section of the CHANGELOG. It says the converter keeps each WFB setting as sent. It lists the old crashes and mangling (*.tif, @x, %p, {row:c}, x # y, null becoming 'None'). It also says that string settings like "5", "0.5", "true" and "2020-01-02" now stay strings, so a client that wants a typed value should send a JSON number or boolean. I also added a wfb_to_wic test that pins *.tif, {row:c}, 'x # y', '5', 'true' and null as kept unchanged in the inline input.
Fixed in daf1b53.
There was a problem hiding this comment.
A closer look found the entry incomplete, so I amended the commit (now 70da6e2). Keeping a setting as sent also means a typed value sent as text stays text: "[1, 2]" used to become a list and "null" a null, and "yes", "0x1F" or "12:30" used to become a boolean or a number. On a typed input those are now reported (wic020). The entry now says that, lists what the second YAML read used to do to text (line breaks folded, quotes and spaces dropped as well), and tells a client to send 5, true, null or [1, 2] as the JSON value. The REST fixtures already send numbers as numbers. The test also pins "[1, 2]" staying text while a real number and list stay typed. Could you take another look?
777c60e to
daf1b53
Compare
|
Thanks for probing it. The one converter comment is handled: the CHANGELOG now documents the converter change, and a wfb_to_wic test pins values like *.tif and {row:c}. Fixed in daf1b53. |
daf1b53 to
70da6e2
Compare
darkclad
left a comment
There was a problem hiding this comment.
The converter comment is resolved by 70da6e2. The CHANGELOG entry covers the change, and test_wfb_to_wic_keeps_settings_as_sent passes here and fails against the old converter. The other five commits are unchanged by the rebase, and tests/core + tests/contrib fail on the same 83 docker/cwltool-run tests as before on this Windows box. One small wording fix in the new entry.
| and is no longer read as YAML a second time. That second read crashed on | ||
| `*.tif`, `@x` or `%p`, turned `{row:c}` into a mapping, cut `x # y` to `x`, | ||
| folded line breaks, dropped surrounding quotes and spaces, and wrote a null | ||
| inside a list as the text `None`. A typed value sent as text now stays text: |
There was a problem hiding this comment.
The old converter wrote a top-level null as the text None too, not only one inside a list: {'none': None} came out as {wic_inline_input: 'None'}, and [1, None] as [1, 'None']. Your new test pins the top-level case. Something like "wrote a null, alone or inside a list, as the text None" would match.
There was a problem hiding this comment.
Right, the old converter wrote a top-level null as None too, and the new test pins that case. The entry now reads "wrote a null, alone or inside a list, as the text None".
Fixed in d13835b.
70da6e2 to
6a3b4be
Compare
|
Thanks for checking. I made the wording fix to the new entry: it now says the old converter wrote a null, alone or inside a list, as the text Fixed in d13835b. |
The parser's loader copied wic_loader's constructors, so a second implementation of our own tags decided what they mean. It showed twice: `!ii 2020-13-45` silently became text, where the plain `2020-13-45` is wic009, and `!ii a: b` as a key was "found unhashable key", an artifact of wic_loader building the tag to a dict. The loader now takes SafeLoader's constructors only. A `!` tag builds nothing there; the content of a tagged collection is still built, so YAML keeps judging it. A plain `!ii` scalar YAML cannot read is wic009, as the untagged value is; a quoted one stays the text it quotes. A Sophios tag on a mapping key is wic005: a key is a name, and the tag belongs on the value.
_tag_value built `{wic_anchor: v}` and friends by YAML-loading a
"!tag value" string through wic_loader. We write the mapping directly
now, so the converter no longer depends on a second reader of our tags.
Its output over the REST fixtures is unchanged.
The tests used wic_loader as their oracle for what a written .wic says and for what YAML accepts. A document's meaning now comes from parse() (read back in to_json's spelling by read_wic), and YAML's verdict from yaml.SafeLoader with the Sophios tags opaque (YamlWithSophiosTagsOpaque), which gives them no meaning. Tests named after "the loader" are named after YAML, and the ones that pinned wic_loader itself are gone.
parse() is the only reader of .wic, and it builds YAML with yaml.SafeLoader. WicLoader and its four tag constructors were a second implementation of our tags with no user left. Tag and Key stay: the desugared spelling is still part of the language.
The YAML extension flagged every !cwl as an unknown tag. !cwl tags a scalar (a raw CWL reference) or a mapping (a step-input record), as the language spec's construct table says; it takes no sequence.
d13835b to
8a70a8d
Compare
The converter no longer re-reads a string setting as YAML, which changes
what a REST client gets for values such as *.tif, {row:c} or "5". I pin
that with a wfb_to_wic test and note it in the 0.7.0 upgrade section.
8a70a8d to
dcf74a0
Compare
Stacked on #516 (
refactor/drawing-is-a-projection). Merge that first; this PR's own changes are the commits above it.What
parse()is the only reader of.wic:sophios.utils_yaml.wic_loader(),WicLoaderand its four tag constructors are deleted.yaml.SafeLoader, and the Sophios tags mean only what the parser says.wic_*mappings itself. Thewic_*spelling stays supported.!iiscalar that YAML cannot read (!ii 2020-13-45) is now wic009, as the same plain value is. It used to become text silently.!ii a: b) is now wic005, not "unhashable key"..wicthroughparse()and YAML throughyaml.SafeLoader, with the Sophios tags opaque. No test gives a tag a meaning of its own.!cwljoins the repository's VS Codeyaml.customTags.Why
wic_loader was a second implementation of our own tags, and it kept becoming the authority: it is why #493 took three rounds. Nothing in the workflow corpus uses it. Emitted CWL is byte-identical at the base and here over the external corpus (mm-workflows, image-workflows, the repository's docs and examples: 9,370 files), which CI does not compile.