-
Notifications
You must be signed in to change notification settings - Fork 24
Running the Excel UI from the command line with Python 3 throws a RuntimeWarning. #352
Description
Running the Excel UI from the command line (i.e., python -m FlowCal.excel_ui -v -p -i experiment.xlsx) with Python 3 throws a RuntimeWarning that could alarm users.
>python -m FlowCal.excel_ui -v -p -i experiment.xlsx
C:\Users\sexto\.conda\envs\py3_fc_anaconda2020.11\lib\runpy.py:127: RuntimeWarning: 'FlowCal.excel_ui' found in sys.modules after import of package 'FlowCal', but prior to execution of 'FlowCal.excel_ui'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))This warning is well described by this Stack Overflow post—the excel_ui module is getting imported twice when invoked with python -m. This shouldn't be a problem for FlowCal because it doesn't store state in the excel_ui module, but the warning could alarm or annoy users.
A solution recommended in this Stack Overflow answer is to separate the module from its command line interface. E.g., python -m FlowCal.excel_ui_cli -v -p -i experiment.xlsx. The new interface would not be backwards compatible, though. To address this, the answer suggests keeping the old interface and throwing a deprecation warning, which seems reasonable to me.
Another option is to silence the warning (per this Stack Overflow answer), but I'd prefer not to do that if there's a better alternative.