-
Notifications
You must be signed in to change notification settings - Fork 9
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
DTS manifest schema #209
base: develop
Are you sure you want to change the base?
DTS manifest schema #209
Conversation
staging_service/app.py
Outdated
if Path._DTS_MANIFEST_SCHEMA_PATH is None: | ||
raise Exception("Please provide DTS_MANIFEST_SCHEMA in the config file") | ||
global _DTS_MANIFEST_SCHEMA | ||
_DTS_MANIFEST_SCHEMA = DTS_MANIFEST_SCHEMA_PATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you load / parse the schema here to fail early?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment to the config / schema parsing code noting that there's no tests, it's all tested manually, and if you make changes you need to add tests or test manually?
staging_service/app.py
Outdated
try: | ||
jsonschema.Draft202012Validator.check_schema(dts_schema) | ||
except jsonschema.exceptions.SchemaError as err: | ||
raise Exception(f"Schema file {schema_path} is not a valid JSON schema: {err.message}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise Exception(f"Schema file {schema_path} is not a valid JSON schema: {err.message}") | |
raise Exception(f"Schema file {schema_path} is not a valid JSON schema: {err.message}") from err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, knew I forgot something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
staging_service/app.py
Outdated
|
||
Path._DATA_DIR = DATA_DIR | ||
Path._META_DIR = META_DIR | ||
Path._CONCIERGE_PATH = CONCIERGE_PATH | ||
Path._DTS_MANIFEST_SCHEMA_PATH = DTS_MANIFEST_SCHEMA_PATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is having this stored in the Path class still useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only left it there to keep the config pattern. But since it's not used, I suppose not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.
errors.append(Error(ErrorType.PARSE_FAIL, "Manifest is not a dictionary", spcsrc)) | ||
|
||
return _error(Error(ErrorType.PARSE_FAIL, "Manifest is not a dictionary", spcsrc)) | ||
validator = jsonschema.Draft202012Validator(dts_manifest_schema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this line also be moved to the config section, so this function expects a validator class? Then the warning about invalid schemas should be moot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@pytest.mark.parametrize("bad_schema", [None, 1, [], {"foo"}]) | ||
def test_dts_manifest_bad_schema(bad_schema): | ||
f = _get_test_file("manifest_small.json") | ||
with pytest.raises(Exception): | ||
parse_dts_manifest(f, bad_schema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No checking the error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moot with the change to pass in the validator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Quality Gate passedIssues Measures |
(changes look big - they're mostly Pipfile.lock)
Adds the DTS manifest JSON schema, does some basic validation with it and returns errors.
To do that, here's the short version of what this PR does:
import_specifications
Actual parsing via the schema comes in the next PR. This is mostly about setup and validation.