Skip to content

Commit

Permalink
Remove support for yaml format
Browse files Browse the repository at this point in the history
Mainly because pyyaml hasn't been published to work with Python3.7 (yaml/pyyaml#126) and this isn't super critical anyway
  • Loading branch information
maroux committed Apr 26, 2018
1 parent 590d3cf commit 57522b0
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 79 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
@@ -1,6 +1,6 @@
include README.rst setup.py conftest.py MANIFEST.in *.txt
global-include README.md README.rst
recursive-include hedwig format_schema.yaml
recursive-include hedwig format_schema.json
prune deps
graft tests
global-exclude *~
5 changes: 2 additions & 3 deletions docs/settings.rst
Expand Up @@ -182,9 +182,8 @@ required; string

**HEDWIG_SCHEMA_FILE**

The filepath to a JSON-Schema file representing the Hedwig schema. This may be a yaml or a json file. This
json-schema must contain all messages under a top-level key ``schemas``. Each message's schema must include
all valid versions for that message.
The filepath to a JSON-Schema file representing the Hedwig schema. This json-schema must contain all messages under a
top-level key ``schemas``. Each message's schema must include all valid versions for that message.

required; string; filepath

Expand Down
58 changes: 58 additions & 0 deletions hedwig/format_schema.json
@@ -0,0 +1,58 @@
{
"id": "https://hedwig.automatic.com/schema#",
"$schema": "http://json-schema.org/draft-04/schema",
"description": "Schema for Hedwig messages",
"required": [
"id",
"schema",
"format_version",
"metadata",
"data"
],
"properties": {
"id": {
"type": "string",
"description": "Message identifier",
"minLength": 36,
"maxLength": 36,
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
},
"schema": {
"type": "string",
"description": "Schema to validate the data object with",
"minLength": 1
},
"format_version": {
"type": "string",
"description": "Format version for the message",
"enum": [
"1.0"
]
},
"metadata": {
"type": "object",
"description": "Metadata associated with the message",
"properties": {
"publisher": {
"type": "string",
"description": "Message publisher service"
},
"timestamp": {
"type": "number",
"description": "Timestamp in epoch milliseconds (integer)",
"format": "int"
},
"headers": {
"type": "object",
"description": "Custom headers associated with the message"
}
},
"additionalProperties": true
},
"data": {
"type": "object",
"description": "Message data"
}
},
"additionalProperties": true
}
44 changes: 0 additions & 44 deletions hedwig/format_schema.yaml

This file was deleted.

15 changes: 4 additions & 11 deletions hedwig/validator.py
Expand Up @@ -5,7 +5,6 @@

from jsonschema import SchemaError, RefResolutionError, FormatChecker
from jsonschema.validators import Draft4Validator
import yaml

from hedwig.conf import settings
from hedwig.exceptions import ValidationError
Expand All @@ -17,7 +16,7 @@ class MessageValidator(Draft4Validator):

checker = FormatChecker()
"""
FormatChecker that checks for `format` JSON-schema field. This may be customized by an app by overriding setting
FormatChecker that checks for `format` JSON-schema field. This may be customized by an app by overriding setting
`HEDWIG_DATA_VALIDATOR_CLASS` and defining more format checkers.
"""

Expand All @@ -26,13 +25,7 @@ def __init__(self, schema: dict = None):
# automatically load schema
schema_filepath = settings.HEDWIG_SCHEMA_FILE
with open(schema_filepath) as f:
schema_content = f.read()
try:
# try JSON
schema = json.loads(schema_content)
except ValueError:
# let yaml fail
schema = yaml.safe_load(schema_content)
schema = json.load(f)

super(MessageValidator, self).__init__(schema, format_checker=self.checker)

Expand Down Expand Up @@ -98,9 +91,9 @@ def check_human_uuid(instance):
class FormatValidator(Draft4Validator):
def __init__(self):
# automatically load schema
schema_filepath = Path(__file__).resolve().parent / 'format_schema.yaml'
schema_filepath = Path(__file__).resolve().parent / 'format_schema.json'
with open(schema_filepath) as f:
schema = yaml.safe_load(f)
schema = json.load(f)

super(FormatValidator, self).__init__(schema)

Expand Down
11 changes: 5 additions & 6 deletions requirements/dev-3.6-dev.txt
Expand Up @@ -3,8 +3,8 @@ appnope==0.1.0 # via ipython
attrs==17.4.0 # via pytest
babel==2.5.3 # via sphinx
backcall==0.1.0 # via ipython
boto3==1.7.4
botocore==1.10.4 # via boto3, s3transfer
boto3==1.7.9
botocore==1.10.9 # via boto3, s3transfer
certifi==2018.4.16 # via requests
chardet==3.0.4 # via requests
decorator==4.3.0 # via ipython, traitlets
Expand Down Expand Up @@ -39,17 +39,16 @@ pyflakes==1.6.0 # via flake8
pygments==2.2.0 # via ipython, sphinx
pyparsing==2.2.0 # via packaging
pytest-env==0.6.2
pytest==3.5.0 # via pytest-env
python-dateutil==2.6.1 # via botocore, faker
pytest==3.5.1 # via pytest-env
python-dateutil==2.7.2 # via botocore, faker
pytz==2018.4 # via babel
pyyaml==3.12
requests==2.18.4 # via sphinx
retrying==1.3.3
s3transfer==0.1.13 # via boto3
simplegeneric==0.8.1 # via ipython
six==1.11.0 # via faker, more-itertools, packaging, prompt-toolkit, pytest, python-dateutil, retrying, sphinx, traitlets
snowballstemmer==1.2.1 # via sphinx
sphinx==1.7.2
sphinx==1.7.4
sphinxcontrib-websupport==1.0.1 # via sphinx
text-unidecode==1.2 # via faker
traitlets==4.3.2 # via ipython
Expand Down
11 changes: 5 additions & 6 deletions requirements/dev-3.6.txt
Expand Up @@ -3,8 +3,8 @@ appnope==0.1.0 # via ipython
attrs==17.4.0 # via pytest
babel==2.5.3 # via sphinx
backcall==0.1.0 # via ipython
boto3==1.7.4
botocore==1.10.4 # via boto3, s3transfer
boto3==1.7.9
botocore==1.10.9 # via boto3, s3transfer
certifi==2018.4.16 # via requests
chardet==3.0.4 # via requests
decorator==4.3.0 # via ipython, traitlets
Expand Down Expand Up @@ -39,17 +39,16 @@ pyflakes==1.6.0 # via flake8
pygments==2.2.0 # via ipython, sphinx
pyparsing==2.2.0 # via packaging
pytest-env==0.6.2
pytest==3.5.0 # via pytest-env
python-dateutil==2.6.1 # via botocore, faker
pytest==3.5.1 # via pytest-env
python-dateutil==2.7.2 # via botocore, faker
pytz==2018.4 # via babel
pyyaml==3.12
requests==2.18.4 # via sphinx
retrying==1.3.3
s3transfer==0.1.13 # via boto3
simplegeneric==0.8.1 # via ipython
six==1.11.0 # via faker, more-itertools, packaging, prompt-toolkit, pytest, python-dateutil, retrying, sphinx, traitlets
snowballstemmer==1.2.1 # via sphinx
sphinx==1.7.2
sphinx==1.7.4
sphinxcontrib-websupport==1.0.1 # via sphinx
text-unidecode==1.2 # via faker
traitlets==4.3.2 # via ipython
Expand Down
11 changes: 5 additions & 6 deletions requirements/dev-3.7-dev.txt
Expand Up @@ -3,8 +3,8 @@ appnope==0.1.0 # via ipython
attrs==17.4.0 # via pytest
babel==2.5.3 # via sphinx
backcall==0.1.0 # via ipython
boto3==1.7.4
botocore==1.10.4 # via boto3, s3transfer
boto3==1.7.9
botocore==1.10.9 # via boto3, s3transfer
certifi==2018.4.16 # via requests
chardet==3.0.4 # via requests
decorator==4.3.0 # via ipython, traitlets
Expand Down Expand Up @@ -39,17 +39,16 @@ pyflakes==1.6.0 # via flake8
pygments==2.2.0 # via ipython, sphinx
pyparsing==2.2.0 # via packaging
pytest-env==0.6.2
pytest==3.5.0 # via pytest-env
python-dateutil==2.6.1 # via botocore, faker
pytest==3.5.1 # via pytest-env
python-dateutil==2.7.2 # via botocore, faker
pytz==2018.4 # via babel
pyyaml==3.12
requests==2.18.4 # via sphinx
retrying==1.3.3
s3transfer==0.1.13 # via boto3
simplegeneric==0.8.1 # via ipython
six==1.11.0 # via faker, more-itertools, packaging, prompt-toolkit, pytest, python-dateutil, retrying, sphinx, traitlets
snowballstemmer==1.2.1 # via sphinx
sphinx==1.7.2
sphinx==1.7.4
sphinxcontrib-websupport==1.0.1 # via sphinx
text-unidecode==1.2 # via faker
traitlets==4.3.2 # via ipython
Expand Down
2 changes: 1 addition & 1 deletion requirements/publish.txt
Expand Up @@ -5,7 +5,7 @@ idna==2.6 # via requests
pkginfo==1.4.2 # via twine
requests-toolbelt==0.8.0 # via twine
requests==2.18.4 # via requests-toolbelt, twine
tqdm==4.23.0 # via twine
tqdm==4.23.1 # via twine
twine==1.11.0
urllib3==1.22 # via requests
wheel==0.31.0
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -72,7 +72,7 @@
# your project is installed. For an analysis of "install_requires" vs pip's
# requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=['funcy', 'retrying', 'boto3', 'jsonpointer', 'jsonschema', 'pyyaml'],
install_requires=['funcy', 'retrying', 'boto3', 'jsonpointer', 'jsonschema'],

tests_require=tests_require,

Expand Down

0 comments on commit 57522b0

Please sign in to comment.