augur.validate moduleļƒ

Validate files related to augur consumption or export.

exception augur.validate.ValidateErrorļƒ

Bases: Exception

augur.validate.auspice_config_v2(config_json, **kwargs)ļƒ
augur.validate.elide_path(path)ļƒ

Elide recursive .children[N] selectors from path after formatting with format_path().

Our tree JSONs are highly nested and the exact path to a node in the tree is often more noisy than useful in error messages.

Return type:

str

>>> format_path(("tree", "children", 1, "children", 0, "children", 1, "children", 0, "node_attrs", "x"))
'.tree.children[1].children[0].children[1].children[0].node_attrs.x'
>>> elide_path(("tree", "children", 1, "children", 0, "children", 1, "children", 0, "node_attrs", "x"))
'.tree.children[ā€¦].node_attrs.x'

Elision is only used with more than a single level of .children[N].

>>> elide_path(("tree", "children", 1, "node_attrs", "x"))
'.tree.children[1].node_attrs.x'
augur.validate.export_v1(meta_json, tree_json, **kwargs)ļƒ
augur.validate.export_v2(main_json, **kwargs)ļƒ
augur.validate.fatal(message)ļƒ
augur.validate.format_path(path)ļƒ

Format an iterable of path segments, which index into a JSON document, into a more human-readable string.

Intended for folks who arenā€™t necessarily programmers, so this doesnā€™t try to construct a valid JS property accessor chain or valid JSON Path selector.

Return type:

str

>>> format_path(("a", "b", "c"))
'.a.b.c'
>>> format_path(("l", "m-n-o", "p"))
".l.'m-n-o'.p"
>>> format_path(("x", "y", 42, "z"))
'.x.y[42].z'
augur.validate.get_unique_keys(list_of_dicts)ļƒ

Returns a set of unique keys from a list of dicts

Examples

>>> list_of_dicts = [{"key1": "val1", "key2": "val2"}, {"key1": "val1", "key3": "val3"}]
>>> sorted(get_unique_keys(list_of_dicts))
['key1', 'key2', 'key3']
augur.validate.grouped(iterable, key)ļƒ

Version of itertools.groupby() which doesnā€™t require the caller to remember to sort first.

augur.validate.load_json(path)ļƒ
augur.validate.load_json_schema(path, refs=None)ļƒ

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_parser(parent_subparsers)ļƒ
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