New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

much faster validator #368

Merged
merged 1 commit into from Nov 4, 2018
Jump to file or symbol
Failed to load files and symbols.
+7 −3
Diff settings

Always

Just for now

View
@@ -7,7 +7,8 @@
import json
import yaml
from jsonschema import validate, ValidationError
from jsonschema import ValidationError
from jsonschema.validators import validator_for
from django.dispatch import receiver
from django.db import models
@@ -23,6 +24,9 @@
with open(os.path.join(settings.BASE_DIR, "schema.yaml")) as f:
SCHEMA = yaml.load(f)["schema"]
_validator_class = validator_for(SCHEMA)
_validator_class.check_schema(SCHEMA)
validator = _validator_class(SCHEMA)
class Build(models.Model):
@@ -57,8 +61,8 @@ def get_build_hash(cls, build):
return f"{prefix}:{md5string}"
@classmethod
def validate_build(cls, build, schema=SCHEMA):
validate(build, schema)
def validate_build(cls, build):
validator.validate(build)
@classmethod
def insert(cls, build, metadata=None, skip_validation=False, **kwargs):
ProTip! Use n and p to navigate between commits in a pull request.