Preserve yaml key order, render tabular file formats - #45
Merged
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two bugs that make a rendered task README wrong or unstable.
Key order
deep_merge()collected the merged keys in aset(). Python randomises string hashing per process, so every yaml read throughread_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:Every task repo got a spurious README diff each time
create_task_readmeran. The keys now keep the order of the first object followed by the ones only found in the second, which is what the Rdeep_merge()has always done. With the fix the rendered README is byte-identical across seeds.Tabular file formats
read_file_format()acceptstabularas a format type, but both renderers only matchedcsv,tsvandparquet-- so atabularspec produced rows that were never rendered, leaving an empty Format and Data structure section.Tests
deep_merge(): merging, recursion, list appending and key orderread_nested_yaml(): keys come back in the order they appear in the yaml, checked against a plainyaml.safe_load()of the same file so the test does not go stalerender_file_format(): parametrised over all four tabular typesBoth tests fail on
main(the key order one on every hash seed).