[GSK-1684] removing validation flags for model evaluation#1379
[GSK-1684] removing validation flags for model evaluation#1379andreybavt merged 6 commits intomainfrom
Conversation
GSK-1684 removing `ValidationFlags`
mattbit : the argument default value is set to a mutable, which causes potentially undesired side effects (Python evaluates args upon function definition, not execution). I think we need much more careful in writing things in a modular way and avoid entangling objects as much as possible. In particular when it comes to the public API like in this case. The Giskard library is already jam-packed with bugs and if we are not careful we will just make it completely unusable. Two ideas:
It would be something like This is what is used for example in numpy ( |
mattbit
left a comment
There was a problem hiding this comment.
I left a small comment but looks good to me!
| reloaded_model = validate_model_loading_and_saving(self) | ||
| validate_model(model=reloaded_model, validate_ds=validate_ds) |
There was a problem hiding this comment.
nitpick: I would first run validate_model which checks a lot of formal things, then try loading_and_saving. I would stick to the original model, not another object.
There was a problem hiding this comment.
I particularly written it that way (which was also the previous logic) because we also want to check that the reloaded model works. Ideally we would do:
validate_model(model=self, validate_ds=validate_ds)
reloaded_model = validate_model_loading_and_saving(self)
validate_model(model=reloaded_model, validate_ds=validate_ds)WDYT?
There was a problem hiding this comment.
For us it's important to know that the deserialized model works. So I think we should validate the loaded one and if it fails we could also run validation on the original model to give a hint that it might be a problem with the serialization
There was a problem hiding this comment.
in fact the validation of the original model already happens in the scan, but it doesn't hurt running it in upload() too (just in case a user bypassed the scan).
So what you're suggesting @andreybavt is something like:
reloaded_model = validate_model_loading_and_saving(self)
try:
validate_model(model=reloaded_model, validate_ds=validate_ds)
except Exception as e_reloaded:
try:
validate_model(model=self, validate_ds=validate_ds)
except Exception as e_loaded:
raise e_loaded
raise GiskardException("An error occured during the deserialisation of your model, please report this issue to giskard, etc.") from e_reloaded
There was a problem hiding this comment.
almost, we just need to make sure we don't lose the e_reloaded when you throw e_loaded
so something like
reloaded_model = validate_model_loading_and_saving(self)
try:
validate_model(model=reloaded_model, validate_ds=validate_ds)
except Exception as e_reloaded:
try:
validate_model(model=self, validate_ds=validate_ds)
logger.info("Original model validated successfully")
except Exception as e_loaded:
logger.exception("Failed to validate on original model", e)
raise GiskardException(
"An error occured while validating a deserialized version your model, please report this issue to Giskard") from e_reloaded
|
Kudos, SonarCloud Quality Gate passed! |








moving saving and loading validation to
model.upload(), removingValidationFlags