Skip to content

Preserve yaml key order, render tabular file formats - #45

Merged
rcannood merged 3 commits into
mainfrom
fix-yaml-key-order
Aug 13, 2026
Merged

Preserve yaml key order, render tabular file formats#45
rcannood merged 3 commits into
mainfrom
fix-yaml-key-order

Conversation

@rcannood

Copy link
Copy Markdown
Member

Two bugs that make a rendered task README wrong or unstable.

Key order

deep_merge() collected the merged keys in a set(). Python randomises string hashing per process, so every yaml read through read_nested_yaml() came back with its keys in a different order on every run. The author info columns of a task README are built by iterating those keys, so the README changed on each render:

PYTHONHASHSEED=0  | Name | Roles | Linkedin | Twitter | Orcid | Email | Github |
PYTHONHASHSEED=1  | Name | Roles | Orcid | Email | Twitter | Github | Linkedin |
PYTHONHASHSEED=2  | Name | Roles | Twitter | Linkedin | Github | Orcid | Email |

Every task repo got a spurious README diff each time create_task_readme ran. The keys now keep the order of the first object followed by the ones only found in the second, which is what the R deep_merge() has always done. With the fix the rendered README is byte-identical across seeds.

Tabular file formats

read_file_format() accepts tabular as a format type, but both renderers only matched csv, tsv and parquet -- so a tabular spec produced rows that were never rendered, leaving an empty Format and Data structure section.

Tests

  • deep_merge(): merging, recursion, list appending and key order
  • read_nested_yaml(): keys come back in the order they appear in the yaml, checked against a plain yaml.safe_load() of the same file so the test does not go stale
  • render_file_format(): parametrised over all four tabular types

Both tests fail on main (the key order one on every hash seed).

`set()` has no order, and python randomises string hashing per process, so
every yaml read through `read_nested_yaml()` came back with its keys in a
different order on every run. The author info columns in a rendered task
README are built by iterating those keys, so each run produced a different
README.

* `deep_merge()`: keep the keys of the first object, then append the ones
  only found in the second, like the R implementation does
* Add tests for `deep_merge()` and for the key order of `read_nested_yaml()`
`read_file_format()` accepts `tabular` as a format type but the renderer only
knew about `csv`, `tsv` and `parquet`, so such a spec rendered an empty
Format and Data structure section.
@rcannood
rcannood merged commit 1064dcf into main Aug 13, 2026
6 checks passed
@rcannood
rcannood deleted the fix-yaml-key-order branch August 13, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant