question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

absl flags API raise error, UnrecognizedFlagError: Unknown command line flag 'f'

See original GitHub issue
  • Describe the current behavior:
import sys
from absl import flags
flags.FLAGS(sys.argv)

throws UnrecognizedFlagError: Unknown command line flag 'f' because the iPython call uses the -f flag. This causes a bug in TensorFlow, see https://github.com/tensorflow/tensorflow/issues/40280.

  • Describe the expected behavior:

It should not be necessary to write special code for Colab. Hence, Colab should not expose the -f flag to sys.argv.

  • Link (not screenshot!) to a minimal, public, self-contained notebook that reproduces this issue (click the Share button, then Get Shareable Link):

https://colab.research.google.com/gist/AndreasMadsen/5865dc94dab8380c0f001e38daec5a9d/untitled5.ipynb

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

13reactions
phoenix-meadowlarkcommented, Jan 7, 2021

You can get around this by putting this cell before the offending call in your notebook:

import sys
from absl import app

# Addresses `UnrecognizedFlagError: Unknown command line flag 'f'`
sys.argv = sys.argv[:1]

# `app.run` calls `sys.exit`
try:
  app.run(lambda argv: None)
except:
  pass

Source: https://github.com/google-research/bleurt/issues/4#issuecomment-635118502

0reactions
pramamu84commented, Oct 23, 2020

Error message: FATAL Flags parsing error: Unknown command line flag ‘f’ Pass --helpshort or --helpfull to see help on flags.

An exception has occurred, use %tb to see the full traceback.

SystemExit: 1

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - how to run a tf.test.TestCase from jupyter notebook
it seems that when you run with notebook, there is an argument to the command that "Stays" when you run tf.test.main().
Read more >
Flags - Abseil
If the command-line value is not in this list, it raises a flag error; otherwise, it assigns to FLAGS.flag as a string. DEFINE_list...
Read more >
tf.compat.v1.flags.FlagValues | TensorFlow v2.11.0
Raised on any parsing error. TypeError, Raised on passing wrong type of arguments. ValueError, Raised on flag value parsing error.
Read more >
unknown flags in tf_xla_flags: --tf_xla_enable_xla_devices
How to ressolve the error: Not creating XLA devices- tensorflow? ... tensorflow/tensorflowUnrecognizedFlagError: Unknown command line flag 'f'#17702.
Read more >
UnrecognizedFlagError: Unknown command line flag 'eval_flow'
Hello, I am getting this error while trying to run this part of the code. def main(unused_argv): if FLAGS.trace == “”: raise ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found