NVIDIA / framework-reproducibility

Providing reproducibility in deep learning frameworks
Apache License 2.0
423 stars 40 forks source link

Raise more specific exceptions #7

Closed bersbersbers closed 4 years ago

bersbersbers commented 4 years ago

Some of the exceptions thrown should be more specific to enable specific exception handling. For example, if no patch is available, a NotImplementedError could be thrown here:

https://github.com/NVIDIA/tensorflow-determinism/blob/25d4b51006c765fbcec845baa50c59bbe8d14c01/tfdeterminism/patch.py#L75-L76

This allows users to prevent linter messages such as

Catching too general exception Exception

duncanriach commented 4 years ago

Thank you for that feedback. I'll probably include changes to address that in the next release.

duncanriach commented 4 years ago

@bersbersbers, your request has been fulfilled by this commit.

I chose to use TypeError, rather than NotImplementedError, for both current cases. In the case where a patch is not available for a given version of TensorFlow, that might be either because it doesn't need a patch or because a patch is not available. The patch code cannot know which is which up-front.

This change will be included in the next release.

duncanriach commented 4 years ago

Closing.