2015-09-29 04:14:59 +03:00
|
|
|
Schema Validation
|
|
|
|
=================
|
|
|
|
|
|
|
|
Some data types in Treeherder will have JSON Schema files in the form of YAML.
|
|
|
|
You can use these files to validate your data prior to submission to be sure
|
|
|
|
it is in the right format.
|
|
|
|
|
2018-07-27 19:41:11 +03:00
|
|
|
You can find all our data schemas in the [schemas] folder.
|
2015-09-29 04:14:59 +03:00
|
|
|
|
|
|
|
To validate your file against a ``yml`` file, you can use something like the
|
|
|
|
following example code:
|
|
|
|
|
2018-07-27 19:41:11 +03:00
|
|
|
```python
|
|
|
|
import yaml
|
|
|
|
import jsonschema
|
2015-09-29 04:14:59 +03:00
|
|
|
|
2018-07-27 19:41:11 +03:00
|
|
|
schema = yaml.load(open("schemas/text-log-summary-artifact.yml"))
|
|
|
|
jsonschema.validate(data, schema)
|
|
|
|
```
|
2015-09-29 04:14:59 +03:00
|
|
|
|
|
|
|
This will give output telling you if your ``data`` element passes validation,
|
|
|
|
and, if not, exactly where it is out of compliance.
|
|
|
|
|
2018-07-27 19:41:11 +03:00
|
|
|
[schemas]: https://github.com/mozilla/treeherder/tree/master/schemas
|