Skip to content
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

[Bug]: Fix JSON Schema validation and add test coverage for all inputs #184

Open
yardasol opened this issue Jan 11, 2023 · 0 comments
Open

Comments

@yardasol
Copy link
Contributor

yardasol commented Jan 11, 2023

Expected behavior

In PR #177, #187, and #188, we expanded on the input schema and input file format. In each of these PRs we added tests to cover the new input variables, but there are still tests missing ensuring that the older variables are also covered.

Additionally, when we validate this schema in python, we should be able to do things:

  1. Set any default values using the approach described here.
  2. Check that there are no misspelled or additional properties in the input file by using the unevaluatedProperties keyword in the schema.

Describe the bug

Here's what I think is happening:

When we try to include item 1 and 2 in our program flow, the following appears to happen:

a. The validator looks for which properties are included in the input file, and makes these the allowed list of properties.
b. The validator then tries to fill the defaults, but because in step A we made the allowed list of properties only those that are included in the input file, there is no need to set any defaults as all needed properties already have values.

I'm unsure if this is actually happening. Someone will need to check.

To Reproduce

Steps to reproduce the behavior:

  1. Add "unevaluatedProperties": false to the depcode subschema in input_schema.json"
        depcode : {
              description :  Depcode class input parameters ,
              type :  object ,
              default : {},
              unevaluatedProperties : false,
             "properties": {
             ...
  1. Run pytest --pdb tests/unit_tests/test_app.py
  2. Observe the error:
            j = obj
>           print(j['reactor']['timestep_type'])
E           KeyError: 'timestep_type'

saltproc/app.py:166: KeyError
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PDB post_mortem (IO-capturing turned off) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /home/ooblack/projects/saltproc/saltproc/app.py(166)read_main_input()
-> print(j['reactor']['timestep_type'])

Supporting Informatioon

System Specifications:

  • Software version: SaltProc v0.5.0-dev
  • Platform/OS: Ubuntu 22.04LTS

How can this issue be closed?

This issue can be closed when a PR exists that fixes the schema validation and adds coverage to the test suite for all input variables. The first item may require rewriting the schema as well as diving deeper into the jsonschema python package and modifying _schema_default.py

@yardasol yardasol added this to the v0.5.0 milestone Jan 17, 2023
@yardasol yardasol changed the title [Bug]: Fix JSON Schema validation [Bug]: Fix JSON Schema validation and add test coverage for all inputs Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant