Pass verbose flag to executable

(Stefan Janssen) #1

I’d like to make my underlying tool SEPP more verbose when users raise the --verbose flag, basically to provide more information when running into errors for further debugging. How do I know if the user set this flag in the Python function?

(Matthew Ryan Dillon) #2

(Matthew Ryan Dillon) #3

Hey there @Stefan!

You don’t need to “hook up” the --verbose flag, just simply print out whatever it is you want to stdout and stderr while running your command. The --verbose flag in q2cli will handle suppression of that (or not) automatically. So, if you are trying to provide debug info from within your plugin, you could use the python print() function, otherwise, the underlying tool (SEPP) can just emit messages to stdout or stderr (whichever is more appropriate).

Hope that helps! :t_rex: :qiime2:

(Matthew Ryan Dillon) #4

(Stefan Janssen) #5

Thanks Matthew. I need to let the executable know that the user wants to see more information and thus the executable must change its behaviour and NOT clean up temporary files when failing but printing those to stderr or stdout. Thus, within my plugin function I need to test if --verbose is set by the user and if so, I need to change how the executable is called.

(Evan Bolyen) #6

(Matthew Ryan Dillon) #7

Ah! I see! Unfortunately, there isn’t currently a way for a plugin to know if --verbose is passed (or not). I think what you are proposing makes sense, but, starts to depart a bit from the original intention of the verbose flag (“should I be quiet, or not?”). With that said, the best option I can think of right now is to add a new debug parameter to your method - then sepp could receive that, and do whatever it is it needs to do. Perhaps in the future we will wire things up a bit different with verbose mode.

As well, not sure what your thoughts are with cleaning up temporary files, but, another potential option there, is to have the user change the $TMPDIR env var to point to a non-system-controlled location (like their home directory) - you could potentially get some mileage out of that, depending on what you are trying to accomplish.

Sorry I don’t have a better suggestion at present! :t_rex: :qiime2:

(Matthew Ryan Dillon) #8

(Stefan Janssen) #9

the --debug option doesn’t sound too bad. Is it possible to programmatically raise the --verbose flag, when the user specifies --debug, such that messages to stderr stdout are actually printed, or would the user need to specify both flags?

(Matthew Ryan Dillon) #10

Unfortunately that wouldn’t be possible - the user would need to specify both flags.

I think that flag would also be a parameter, so invoking in q2cli would look like this:

qiime fragment-insertion sepp \
  --i-representative-sequences rep-seqs.qza \
  --p-debug \
  --o-tree insertion-tree.qza \
  --o-placements insertion-placements.qza \

That is a big pain in the butt, sorry! We are certainly open to expanding the capabilities of the --verbose flag in the future!