-
Notifications
You must be signed in to change notification settings - Fork 25
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
Suppression of warnings and (optionally) output #106
Conversation
Importing tensorflow natively would throw FutureWarnings whenever the module was loaded. Now temporarily ignore FutureWarnings when importing tensorflow.
Now user can specify "quiet=True" to suppress tqdm output.
When quiet specified, multinomial will not print deprecation warnings or profiling messages.
Runtime and FutureWarnings now ignored when using songbird from the command line.
More efficient to filter warnings at the beginning rather than each time tensorflow is imported.
Can now specify --quiet or --no-quiet for CLI implementation. Also adds test that these commands work as expected.
Added tests that capture multinomial output to stderr to check that quiet does not return anything and that not-quiet does.
Default behavior description removed from quiet. Plugin setup also mentions that the quiet flag is only relevant for the Artifact API. My understanding is that the default behavior of q2-songbird from the CLI will *not* output the tqdm but the Artifact API does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. From a first pass, this is good to go once the flake8 issues are fixed.
songbird/q2/tests/test_method.py
Outdated
md.name = 'sampleid' | ||
md = qiime2.Metadata(md) | ||
|
||
exp_beta = clr(clr_inv(np.hstack((np.zeros((2, 1)), self.beta.T)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oof - we still have that code in there? That is definitely going to cause numerical issues
We should be instead doing
exp_beta = np.hstack((np.zeros((2, 1)), self.beta.T))
exp_beta = exp_beta - exp_beta.mean(axis=1).reshape(-1, 1)
In that way, we don't have to ever leave log space :)
If there are other instances of this, we need to fix them (in another PR)>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the only place clr()
is being used at all in Songbird's codebase is in that line of testing code, so it's likely not a huge deal. (clr_inv()
is being used in one other place, here (since it's getting imported there as softmax
), but I don't know enough to know if that's a problem or not.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait jk it's also being used in scripts/songbird
here
if quiet: | ||
iter_range = range(0, num_iter) | ||
else: | ||
iter_range = tqdm(range(0, num_iter)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoa, interesting.
1) Removed unused exp_beta from quiet tests 2) Moved warning capture in standalone to avoid top-level import problems
Hmmm... I addressed the flake8 issues but now it looks like there's some sort of GLIBC error in the travis check. Is this something my changes brought about? (Not super familiar with C stuff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I have a few small requests, mostly minor stuff for making life easier for users. If you have any questions just let me know.
from tensorboard.plugins.hparams import api as hp | ||
import tensorflow as tf | ||
|
||
warnings.filterwarnings("ignore", category=RuntimeWarning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really have any feedback here beyond "I didn't know this was a thing you can do in python and this is cool"
songbird/parameter_info.py
Outdated
@@ -36,6 +36,10 @@ | |||
"for it to be included in the analysis." | |||
), | |||
"summary-interval": "Number of seconds before storing a summary.", | |||
"quiet": ( | |||
'Flag denoting whether to hide tqdm progress bar. If True, tqdm ' | |||
'bar is displayed. If False, tqdm is not printed.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth just saying "progress bar" instead of "tqdm progress bar" or "tqdm bar", since I imagine many users might not know what tqdm is. But that's minor -- up to you whether or not you'd want to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, also -- it looks like quiet
is also being used to hide TensorFlow warnings. That's fine, but the description should be updated accordingly (I doubt most people will care but some people might want to see these, at least the first time).
scripts/songbird
Outdated
|
||
# suppress deprecation warnings | ||
# taken from https://github.com/tensorflow/tensorflow/issues/27023 | ||
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just leaving a note tagging #110 -- for future reference, this will be one of the things that'll need to be changed upon updating to TensorFlow v2. (Should be ok to leave this in for now.)
|
||
result = runner.invoke(songbird.multinomial, test_args) | ||
|
||
assert result.output != "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are super easy to understand -- this looks great.
songbird/q2/_method.py
Outdated
|
||
# suppress deprecation warnings | ||
# taken from https://github.com/tensorflow/tensorflow/issues/27023 | ||
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it looks like this code is duplicated between here and in scripts/songbird
, would it be possible to spin this off into a function in songbird/util.py
and call that function from both locations? This would minimize maintenance burden (and we already know that the tf.compat.v1. thing will probably need to be rewritten at some point down the line...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this occurred to me as well. Was hesitant to create a new module without running it by anyone but if it's okay with you I'll go ahead and do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you'd need to create a new module -- it should be possible to just add a function in util.py
that does this stuff, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂ yep...
songbird/q2/plugin_setup.py
Outdated
@@ -81,6 +82,7 @@ | |||
"min_feature_count": DESCS["min-feature-count"], | |||
"summary_interval": DESCS["summary-interval"], | |||
"random_seed": DESCS["random-seed"], | |||
"quiet": DESCS["quiet"] + " (Only affects Artifact API)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct -- you'll still see the progress bar if you include --verbose
in the qiime songbird multinomial
invocation. Would suggest revising to (Only has an impact when using this command with the --verbose option or through the QIIME 2 Artifact API)
, or something along those lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference - just tried out the Qiime2 command with the --verbose
flag (with --p-no-quiet
) and and I can confirm it does display the progress bar & warnings. Will update documentation accordingly. 😄
Made more clear the effect the silent flag has and flipped the erroneously documentation of True/False behavior. Updated Qiime2 description of flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @gibsramen! Everything looks good to me.
@gibsramen I updated the changelog about this PR -- let me know if this description looks good/bad to you. |
Addresses #105
Some users have mentioned that it would be useful to suppress the output of
songbird.multinomial
, including the TensorFlow deprecation warnings and tqdm progress bar. This PR should address most of these issues.make test
passes on my build (added a couple tests of the new functionality).Main changes
silent
flag tosongbird.multinomial
, allowing users the option of suppressing both the TensorFlow logging warnings and the tqdm progress bar.See this SO question and this GitHub issue. Note that the latter apparently works only on TensorFlow
1.14.0
. If/when this requirement is updated in Songbird, we may need to come back to this issue.Python Warnings
Python
FutureWarnings
are now all filtered regardless ofsilent
flag.RuntimeWarnings
also suppressed in standalone CLI.Old behavior
New behavior
Silent flag
Both standalone and Q2 implementations can now specify whether or not to suppress output.
NOTE: To my knowledge, callingqiime songbird multinomial
from the CLI defaults to not showing the tqdm progress bar. In this case, thequiet
flag is redundant and provided for compatibility. Calling through the Artifact API, however, outputs the tqdm progress bar normally, so the flag can be used there.Turns out that you will see the progress bar from the Qiime2 invocation if you provide the
--verbose
option.