google-deepmind / dm_robotics

Libraries, tools and tasks created and used at DeepMind Robotics.
Apache License 2.0
332 stars 32 forks source link

UnparsedFlagAccessError when calling env.reset() #3

Closed zhenbangt closed 2 years ago

zhenbangt commented 2 years ago

Hi,

I keep getting this weird error when calling env.reset(). I only get this error when running a Jupyter notebook

~/miniconda3/lib/python3.9/site-packages/dm_robotics/agentflow/spec_utils.py in debugging_flag() 45 46 def debugging_flag() -> bool: ---> 47 return FLAGS.debug_specs 48 49

Error Message: UnparsedFlagAccessError: Trying to access flag --debug_specs before flags were parsed.

Defining the absl flag by myself does not help: DuplicateFlagError: The flag 'debug_specs' is defined twice. First from dm_robotics.agentflow.spec_utils, Second from /home/ztan/miniconda3/lib/python3.9/site-packages/ipykernel_launcher.py. Description from first occurrence: Debugging switch for checking values match specs.

Any ideas why this keeps happening? Thanks a lot

shacklestone commented 2 years ago

Hi, what is in your function that runs when __name__ == "__main__ "?

It's important to have this kind of structure:

from absl import app

def main(argv):
  ...

if __name__ == '__main__':
  app.run(main)

See also the abseil/Flags docs

shacklestone commented 2 years ago

Is this issue resolved?