bergamot-translator icon indicating copy to clipboard operation
bergamot-translator copied to clipboard

Error handling and stream improvements for command-line apps

Open jerinphilip opened this issue 4 years ago • 1 comments

  1. Avoid copies through stringstream (of widespread use currently in BRT) to read into a string using buffered read.
  2. BRT command line does not do error handling - whether the file exists, are we running out of space on write that sort. Handle that as well.

jerinphilip avatar Sep 06 '21 14:09 jerinphilip

  1. Past refactoring PRs have aggressively squeezed stream reads into a single place:

https://github.com/browsermt/bergamot-translator/blob/bcbbfe129525ed2be8dbf00d2da9d412667f1d8d/src/translator/utils.h#L7-L13

  1. Having turned off logging by default and seen experienced Marian users use:
// Set marian to throw exceptions instead of std::abort()
marian::setThrowExceptionOnAbort(true);

https://github.com/XapaJIaMnu/translateLocally/blob/6f40bceedb4909dfead81441cfb606582c43dcaf/src/main.cpp#L13

thinking the above would be nice to incorporate.

jerinphilip avatar Jan 27 '22 01:01 jerinphilip