augur.validate module

Validate files related to augur consumption or export.

exception augur.validate.ValidateError

Bases: Exception

class augur.validate.ValidationErrors

Bases: ValidationWarnings

show()
class augur.validate.ValidationWarnings

Bases: object

add(warningType, message)
show()
augur.validate.auspice_config_v2(config_json, **kwargs)
augur.validate.export_v1(meta_json, tree_json, **kwargs)
augur.validate.export_v2(main_json, **kwargs)
augur.validate.fatal(message)
augur.validate.get_unique_keys(list_of_dicts)

Returns a set of unique keys from a list of dicts

>>> list_of_dicts = [{"key1": "val1", "key2": "val2"}, {"key1": "val1", "key3": "val3"}]
>>> sorted(get_unique_keys(list_of_dicts))
['key1', 'key2', 'key3']
augur.validate.load_json(path)
augur.validate.load_json_schema(path)

Load a JSON schema from the augur included set of schemas (located in augur/data)

augur.validate.measurements(measurements_json, **kwargs)
augur.validate.measurements_collection_config(collection_config_json, **kwargs)
augur.validate.register_arguments(parser)
augur.validate.run(args)
augur.validate.validate(jsonToValidate, schema, filename)
augur.validate.validate_collection_config_fields(collection, index=None)

Validates a single collection’s config field keys provided in fields, groupings, and filters are valid fields that exist in measurements’ fields.

Prints any validation errors to stderr.

Parameters
  • collection (dict) – A single collection to validate. Assumes that the collection has already passed the schema validation.

  • index (int, optional) – the index of the collection within a list of collections in a measurements JSON. Used to print more detailed error messages.

Returns

True if collection’s config is valid

Return type

bool

augur.validate.validate_collection_display_defaults(collection, index=None)

Validates a single collection’s display defaults. If a default group-by field is provided, the field must be included in groupings.

Prints validation errors to stderr.

Parameters
  • collection (dict) – A single collection to validate. Assumest htat the collection has already passed the schema validation.

  • index (int, optional) – The index of the collection within a list of collections in a measurements JSON. Used to print more detailed error messages.

Returns

True if collection’s display defaults are valid

Return type

bool

augur.validate.validate_json(jsonToValidate, schema, filename)
augur.validate.validate_measurements_config(measurements)

Validate measurements’ config values meet expectations described in the measurements JSON schema descriptions that cannot be verified via validate_json: 1. Individual collections have valid config values 2. All collections have unique keys 3. If a default collection is provided, it matches one of the collections

Prints any validation errors to stderr.

Parameters

measurements (dict) – Loaded measurements JSON to validate. Assumes the measurements JSON has already passed the schema validation.

Returns

True if measurements’ config is valid

Return type

bool