Skip to content

Commit b745538

Browse files
fix: don't error if node data file is empty
Resolves #1215 Warn instead error when no nodes in a node data json, fixing issue introduced recently in PR #728 In PR #728, extra node data validation was introduced. In particular, files without information for either `nodes` or `branches` caused erroring. This is problematic for test scripts that may produce empty node data in test cases. This PR removes the eager validation. In the future we could reintroduce it as a warning. And possibly an error but with opt-out. This type of node data json was previously errored on by augur export, it is now accepted again: ```json { "nodes": {}, "rbd_level_details": {} } ``` <!-- Start typing the name of a related issue and GitHub will auto-suggest the issue number for you. --> Fixes the ncov pathogen-CI issue: nextstrain/conda-base#27 (comment) What steps should be taken to test the changes you've proposed? If you added or changed behavior in the codebase, did you update the tests, or do you need help with this? - [x] nextstrain/conda-base#27 (comment) is fixed, export now accepts empty nodes dicts again
1 parent aade8fd commit b745538

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGES.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## __NEXT__
44

5+
### Bug fixes
6+
7+
* export: In version 22.0.0, validation of `augur.utils.read_node_data` was changed to error when a node data JSON did not contain any actual data. This causes export to error when an empty node data JSON is passed, as for example in ncov's pathogen-ci. This is now fixed by warning instead. The bug was originally introduced in PR [#728][]. [#1214][] (@corneliusroemer)
8+
9+
[#1214]: https://github.com/nextstrain/augur/pull/1214
510

611
## 22.0.0 (9 May 2023)
712

augur/util_support/node_data_file.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ def validate(self):
8080

8181
if not isinstance(self.branches, dict):
8282
raise AugurError(
83-
f"`branches` value in {self.fname} is not a dictionary. Please check the formatting of this JSON!" )
83+
f"`branches` value in {self.fname} is not a dictionary. Please check the formatting of this JSON!"
84+
)
8485

8586
if not self.nodes and not self.branches:
86-
raise AugurError(
87-
f"{self.fname} did not contain either `nodes` or `branches`. Please check the formatting of this JSON!"
88-
)
87+
print_err(
88+
f"WARNING: {self.fname} has empty or nonexistent `nodes` and `branches`. Please check the formatting of this JSON!"
89+
)
8990

9091
if self.validation_mode is not ValidationMode.SKIP and self.is_generated_by_incompatible_augur:
9192
msg = (

0 commit comments

Comments
 (0)