Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running the Excel UI from the command line with Python 3 throws a RuntimeWarning. #352

Open
JS3xton opened this issue Jan 26, 2021 · 0 comments
Labels

Comments

@JS3xton
Copy link
Contributor

JS3xton commented Jan 26, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant