PowerSystems.jl icon indicating copy to clipboard operation
PowerSystems.jl copied to clipboard

Add documentation on how to add validation for custom types

Open jd-lara opened this issue 4 years ago • 3 comments

It isn't clear currently what's the process to avoid the warning

┌ Warning: struct MyCustomDevice does not exist in validation configuration file, validation skipped
└ @ InfrastructureSystems ~/.julia/dev/InfrastructureSystems/src/validation.jl:42

jd-lara avatar May 30 '20 22:05 jd-lara

This means that the descriptor file does not contain the struct being used. We have an oversight in this process. A user might want validation of a struct without doing auto-generation. Is that what is happening here?

It might be better to make this warning message a debug message.

daniel-thom avatar Aug 21 '20 16:08 daniel-thom

we currently throw a warning when there is no valid entry for a custom struct validation. We want to add validation for the DynamicInverter and also make sure that the validations on the field values of components are conducted.

jd-lara avatar Aug 21 '20 16:08 jd-lara

My earlier statement was incorrect. You can define a validation descriptor for a struct that is not auto-generated by adding an entry here: https://github.com/NREL-SIIP/PowerSystems.jl/blob/master/src/descriptors/power_system_structs.json#L9581.

There are a few options:

  1. Add the descriptor.
  2. Implement a method for the function IS.validate_struct(ist::InfrastructureSystemsType). (validate based on fields in struct)
  3. Implement a method for the function PSY.validate_struct(sys::System, value::PowerSystemType). (validate based on system)

daniel-thom avatar Aug 21 '20 16:08 daniel-thom