Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

### Development

* subsample: Refactored helper functions to only validate config during run time. [#2039] @victorlin
* Added a subsample config schema for workflows that use unaligned sequences. [#2038] @victorlin

[#2038]: https://github.com/nextstrain/augur/pull/2038
[#2039]: https://github.com/nextstrain/augur/pull/2039

## 34.1.2 (5 August 2026)

Expand Down
24 changes: 10 additions & 14 deletions augur/subsample.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,14 @@ def run(args: argparse.Namespace) -> None:
worth it if a proper input reuse approach such as database/parquet file
support is adopted: <https://github.com/nextstrain/augur/issues/1574>
"""

# Load schema, parse and validate config.
schema_validator = load_json_schema("schema-subsample-config.json")
config = _parse_config(args.config, args.config_section, schema_validator)
config = _parse_config(args.config, args.config_section)

try:
validate_json(config, schema_validator, args.config)
except ValidateError as e:
raise AugurError(e)

sample_types = _get_sample_types(config)

if _includes_proximal_sample(config) and not args.sequences:
Expand Down Expand Up @@ -324,9 +328,8 @@ def get_referenced_files(
set
Resolved filepaths
"""
# Load schema, parse and validate config.
schema_validator = load_json_schema("schema-subsample-config.json")
config = _parse_config(config_file, config_section, schema_validator)
config = _parse_config(config_file, config_section)

# Resolve filepaths.
search_path_objs = _get_search_paths(config_file, search_paths)
Expand Down Expand Up @@ -357,11 +360,10 @@ def requires_aligned_sequences(
bool
Does augur subsample require aligned sequences?
"""
schema_validator = load_json_schema("schema-subsample-config.json")
config = _parse_config(config_file, config_section, schema_validator)
config = _parse_config(config_file, config_section)
return _includes_proximal_sample(config)

def _parse_config(filename: str, config_section: Optional[List[str]], schema) -> Dict[str, Any]:
def _parse_config(filename: str, config_section: Optional[List[str]] = None) -> Dict[str, Any]:
# Create a custom YAML loader to treat timestamps as strings.
class CustomLoader(yaml.SafeLoader):
pass
Expand All @@ -387,12 +389,6 @@ def string_constructor(loader, node):

config = traversed_section

# Validate against schema.
try:
validate_json(config, schema, filename)
except ValidateError as e:
raise AugurError(e)

return config

def _get_search_paths(
Expand Down
Loading