-
Notifications
You must be signed in to change notification settings - Fork 1
Validation checks for run input #44
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
Conversation
Added pydantic model needed for tests.
simvue/run.py
Outdated
| try: | ||
| runinput = RunInput(**data) | ||
| except ValidationError as e: | ||
| self._error(json.dumps(e.json())) |
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 think using instead here:
self._error(e)
rather than:
self._error(json.dumps(e.json()))
makes things much easier to understand. Using json you get an error like this:
RuntimeError: "[\n {\n \"loc\": [\n \"metadata\",\n \"hello\"\n ],\n \"msg\": \"str type expected\",\n \"type\": \"type_error.str\"\n },\n {\n \"loc\": [\n \"metadata\",\n \"hello\"\n ],\n \"msg\": \"value is not a valid integer\",\n \"type\": \"type_error.integer\"\n },\n {\n \"loc\": [\n \"metadata\",\n \"hello\"\n ],\n \"msg\": \"value is not a valid float\",\n \"type\": \"type_error.float\"\n }\n]"
whereas with plain text you get:
RuntimeError: 3 validation errors for RunInput
metadata -> hello
str type expected (type=type_error.str)
metadata -> hello
value is not a valid integer (type=type_error.integer)
metadata -> hello
value is not a valid float (type=type_error.float)
For me at least this is easier to understand.
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.
Yes, agreed. Will update.
|
If possible we should also delete the lines: and update |
…imvue-io/client into validation-checks-for-RunInput
|
Updating |
…from run.py. Added a test to check.
Merge in changes from main
|
This may help with the "error": https://stackoverflow.com/questions/64909849/syntax-error-with-flake8-and-pydantic-constrained-types-constrregex |
…imvue-io/client into validation-checks-for-RunInput
Basic checks for data types passed into run.init() based on pydantic models defined in models.py