You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement reader-specific methods for inspections before and after reading. Pre-checks could include ensuring the file exists, simple validation that the file is of the correct type (e.g. not reading a detector file with a depletion reader), or counting the number of time steps present in the results file #7. Post-read checks could include verifying that data was indeed stored. If nothing is stored, Exceptions should be raised, perhaps a new one like EmptyReader that inherits from SerpentToolsException
In order to accomplish this, I propose refactoring the public read methods for all readers to private _read methods. The base reader will contain the public read method, and seek for precheck and postcheck methods specific to each file type. These do not have to be overwritten for each reader.
Implementation Suggestion
class BaseReader(object):
def read(self):
self._precheck()
# maybe some debug/info statements
self._read()
self._postcheck()
def _precheck():
pass
def _postcheck():
pass
def _read():
raise NotImplementedError
class SubClass(BaseReader):
def _read():
# do the things
def _postcheck():
assert thingsWereDone
Pre/post check functions should log errors/warnings accordingly, such as an error if the word DET does not appear in the first fuel lines of a supposed detector file. When applicable, Exceptions should be raised if things go really poorly.
The text was updated successfully, but these errors were encountered:
Implement reader-specific methods for inspections before and after reading. Pre-checks could include ensuring the file exists, simple validation that the file is of the correct type (e.g. not reading a detector file with a depletion reader), or counting the number of time steps present in the results file #7. Post-read checks could include verifying that data was indeed stored. If nothing is stored, Exceptions should be raised, perhaps a new one like
EmptyReader
that inherits fromSerpentToolsException
In order to accomplish this, I propose refactoring the public read methods for all readers to private
_read
methods. The base reader will contain the public read method, and seek for precheck and postcheck methods specific to each file type. These do not have to be overwritten for each reader.Implementation Suggestion
Pre/post check functions should log errors/warnings accordingly, such as an error if the word
DET
does not appear in the first fuel lines of a supposed detector file. When applicable, Exceptions should be raised if things go really poorly.The text was updated successfully, but these errors were encountered: