augur.validate
Validate files related to augur consumption or export.
- augur.validate.auspice_config_v2(config_json, **kwargs)
- augur.validate.elide_path(path)
Elide recursive
.children[N]
selectors from path after formatting withformat_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.
>>> 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' :rtype: :py:class:`str`
>>> 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.
>>> format_path(("a", "b", "c")) '.a.b.c' >>> format_path(("l", "m-n-o", "p")) ".l.'m-n-o'.p" :rtype: :py:class:`str`
>>> 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
- Returns
True if collection’s config is valid
- Return type
- 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
- Returns
True if collection’s display defaults are valid
- Return type
- 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.