radiasoft / sirepo

Sirepo is a framework for scientific cloud computing. Try it out!
https://sirepo.com
Apache License 2.0
64 stars 31 forks source link

Require default values for numeric fields in schema #6793

Open mkeilman opened 7 months ago

mkeilman commented 7 months ago

See https://github.com/radiasoft/sirepo/issues/6665#issuecomment-1954535480 We currently ignore missing default values:

def validate(schema):
...
    for model_name in sch_models:
        _validate_model_name(model_name)
        sch_model = sch_models[model_name]
        for field_name in sch_model:
            _validate_job_run_mode(field_name, schema)
            sch_field_info = sch_model[field_name]
            --> if len(sch_field_info) <= 2:
                continue
...

However, this will cause the error seen in the issue above, as we don't allow NaN in our json files. Suggest the proper place for this is template_common.validate_model() since it is already checking numeric types I thought this was being called in validation but it is not

mkeilman commented 7 months ago

Initial indications are that a lot of schema lack numeric defaults. They don't break if the fixup does not build a default for that particular model; however we don't know that ahead of time

mkeilman commented 7 months ago

Another interesting note: I have found several cases where a view definition is included in the models