bittremieux / ANN-SoLo

Spectral library searching using approximate nearest neighbor techniques.
Apache License 2.0
42 stars 19 forks source link

return code is always 1 (even on success) #11

Closed vnaum closed 4 years ago

vnaum commented 4 years ago

I tried using ann-solo in scripts, and it seemingly always fails because of imporperly set error code.

Checked source, and I see its calling sys.exit with result of main call, then main returns string, sys.exit coerces this to integer, string is non-empty -> its effectively exit(1) (error flag set).

suggested patch (works for me, probably could be done better):

--- /home/ubuntu/miniconda3/lib/python3.8/site-packages/ann_solo/ann_solo.py.bak        2020-10-23 13:56:01.308069954 +0000
+++ /home/ubuntu/miniconda3/lib/python3.8/site-packages/ann_solo/ann_solo.py    2020-10-23 13:57:48.123426237 +0000
@@ -51,7 +51,7 @@
     return out_filename

-def main(args: Union[str, List[str]] = None) -> str:
+def main(args: Union[str, List[str]] = None) -> int:
     # Initialize logging.
     logging.basicConfig(format='{asctime} [{levelname}/{processName}] '
                                '{module}.{funcName} : {message}',
@@ -70,7 +70,7 @@

     logging.shutdown()

-    return out_filename
+    return 0

 if __name__ == '__main__':
bittremieux commented 4 years ago

Good remark. I've modified it so that error code 0 is returned after successful completion. New version 0.3.3 is available from PyPI.