google-deepmind / android_env

RL research on Android devices.

Home Page:https://www.deepmind.com/publications/androidenv-the-android-learning-environment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compatibility Error when using rich logging handler

zjowowen opened this issue · comments

Hi,
I found that if I use rich logging handler and starting the andriod env. An error will occur at this code line:
https://github.com/google-deepmind/android_env/blob/main/android_env/components/simulators/emulator/emulator_launcher.py#L60

I think the rendering rule of rich logging handler is not compatibility with strings such as "[/home/Android/Sdk/emulator/emulator]".

I sugguest changing the logging info to be "'/home/Android/Sdk/emulator/emulator'".

Hello @zjowowen, thanks for raising the issue.

It's not a problem for us to change the formatting of that logging line, but would you kindly paste the error you're getting?

And what library you're using exactly?

Cheers,

Daniel

I'm guessing it's https://rich.readthedocs.io/en/stable/logging.html, right?

Still, can you paste the exact error for posterity?

Hi, thanks for your help~

The full error log is:

"""
Exception has occurred: SimulatorError (note: full exception trace is shown but execution is paused at: _run_module_as_main)
Exception caught in simulator. Please see the simulator logs above for more details.
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/site-packages/rich/markup.py", line 165, in render
start, open_tag = pop_style(style_name)
^^^^^^^^^^^^^^^^^^^^^
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/site-packages/rich/markup.py", line 151, in pop_style
raise KeyError(style_name)
KeyError: 'home/zjow/android/sdk/emulator/emulator'

During handling of the above exception, another exception occurred:

File "/home/zjow/Github/google-deepmind/android_env/android_env/components/simulators/base_simulator.py", line 68, in launch
self._launch_impl()
File "/home/zjow/Github/google-deepmind/android_env/android_env/components/simulators/emulator/emulator_simulator.py", line 247, in _launch_impl
self._launcher.launch_emulator_process()
File "/home/zjow/Github/google-deepmind/android_env/android_env/components/simulators/emulator/emulator_launcher.py", line 107, in launch_emulator_process
logging.info('Booting new emulator [%s]', self._emulator_path)
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/site-packages/absl/logging/init.py", line 442, in info
log(INFO, msg, *args, **kwargs)
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/site-packages/absl/logging/init.py", line 589, in log
_absl_logger.log(standard_level, msg, *args, **kwargs)
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/site-packages/absl/logging/init.py", line 1158, in log
super(ABSLLogger, self).log(level, msg, *args, **kwargs)
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/logging/init.py", line 1559, in log
self._log(level, msg, args, **kwargs)
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/logging/init.py", line 1634, in _log
self.handle(record)
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/site-packages/absl/logging/init.py", line 1175, in handle
self.callHandlers(record)
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/logging/init.py", line 1706, in callHandlers
hdlr.handle(record)
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/logging/init.py", line 978, in handle
self.emit(record)
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/site-packages/ditk/logging/terminal.py", line 46, in emit
return self._get_current_handler().emit(record)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/site-packages/rich/logging.py", line 159, in emit
message_renderable = self.render_message(record, message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/site-packages/rich/logging.py", line 185, in render_message
message_text = Text.from_markup(message) if use_markup else Text(message)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/site-packages/rich/text.py", line 286, in from_markup
rendered_text = render(text, style, emoji=emoji, emoji_variant=emoji_variant)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/site-packages/rich/markup.py", line 167, in render
raise MarkupError(
rich.errors.MarkupError: closing tag '[/home/zjow/Android/Sdk/emulator/emulator]' at position 21 doesn't match any open tag

The above exception was the direct cause of the following exception:

File "/home/zjow/Github/google-deepmind/android_env/android_env/components/simulators/base_simulator.py", line 72, in launch
raise errors.SimulatorError(
File "/home/zjow/Github/google-deepmind/android_env/android_env/components/coordinator.py", line 223, in _launch_simulator
self._simulator.launch()
File "/home/zjow/Github/google-deepmind/android_env/android_env/components/coordinator.py", line 120, in init
self._launch_simulator()
File "/home/zjow/Github/google-deepmind/android_env/android_env/loader.py", line 73, in load
coordinator = coordinator_lib.Coordinator(simulator, task_manager)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zjow/Github/zjowowen/DI-engine-android/dizoo/android_env/envs/android_env.py", line 93, in init
self._env = loader.load(
^^^^^^^^^^^^
File "/home/zjow/Github/zjowowen/DI-engine-android/dizoo/android_env/config/apple_flinger_sac_config.py", line 625, in
env_fn=[lambda: AndroidEnv(cfg.env) for _ in range(cfg.env.collector_env_num)], cfg=cfg.env.manager
^^^^^^^^^^^^^^^^^^^
File "/home/zjow/Github/zjowowen/DI-engine-android/ding/envs/env_manager/base_env_manager.py", line 135, in init
self._env_ref = self._env_fn0
^^^^^^^^^^^^^^^^^
File "/home/zjow/Github/zjowowen/DI-engine-android/dizoo/android_env/config/apple_flinger_sac_config.py", line 624, in main
collector_env = BaseEnvManagerV2(
^^^^^^^^^^^^^^^^^
File "/home/zjow/Github/zjowowen/DI-engine-android/dizoo/android_env/config/apple_flinger_sac_config.py", line 651, in
main()
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/runpy.py", line 88, in _run_code
exec(code, run_globals)
File "/home/zjow/anaconda3/envs/android_rl/lib/python3.11/runpy.py", line 198, in _run_module_as_main (Current frame)
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
android_env.components.errors.SimulatorError: Exception caught in simulator. Please see the simulator logs above for more details.
"""

The libraries are:
"""
absl-py 2.0.0
android-env 1.2.2
appdirs 1.4.4
bitmath 1.3.3.1
cachetools 5.3.2
certifi 2023.11.17
cffi 1.16.0
chardet 4.0.0
charset-normalizer 3.3.2
click 7.1.2
cloudpickle 3.0.0
contourpy 1.2.0
cycler 0.12.1
deprecation 2.1.0
DI-engine 0.5.0
DI-toolkit 0.2.0
DI-treetensor 0.4.1
dill 0.3.7
dm-env 1.6
dm-tree 0.1.8
docker-pycreds 0.4.0
easydict 1.9
enum-tools 0.11.0
Farama-Notifications 0.0.4
filelock 3.13.1
Flask 1.1.4
fonttools 4.47.0
fsspec 2023.12.2
gitdb 4.0.11
GitPython 3.1.40
google-auth 2.26.1
google-auth-oauthlib 1.2.0
graphviz 0.20.1
grpcio 1.60.0
gym 0.25.1
gym-notices 0.0.8
gymnasium 0.29.1
h5py 3.10.0
hbutils 0.9.3
hickle 5.0.2
idna 3.6
itsdangerous 1.1.0
Jinja2 2.11.3
joblib 1.3.2
kiwisolver 1.4.5
Markdown 3.5.1
markdown-it-py 3.0.0
MarkupSafe 2.0.1
matplotlib 3.8.2
mdurl 0.1.2
mpire 2.9.0
mpmath 1.3.0
networkx 3.2.1
numpy 1.26.3
nvidia-cublas-cu12 12.1.3.1
nvidia-cuda-cupti-cu12 12.1.105
nvidia-cuda-nvrtc-cu12 12.1.105
nvidia-cuda-runtime-cu12 12.1.105
nvidia-cudnn-cu12 8.9.2.26
nvidia-cufft-cu12 11.0.2.54
nvidia-curand-cu12 10.3.2.106
nvidia-cusolver-cu12 11.4.5.107
nvidia-cusparse-cu12 12.1.0.106
nvidia-nccl-cu12 2.18.1
nvidia-nvjitlink-cu12 12.3.101
nvidia-nvtx-cu12 12.1.105
oauthlib 3.2.2
packaging 23.2
pandas 2.1.4
pillow 10.2.0
pip 23.3.1
portpicker 1.6.0
protobuf 4.23.4
psutil 5.9.7
pyasn1 0.5.1
pyasn1-modules 0.3.0
pycparser 2.21
pygame 2.5.2
Pygments 2.17.2
pynng 0.7.4
pyparsing 3.1.1
python-dateutil 2.8.2
pytimeparse 1.1.8
pytz 2023.3.post1
PyYAML 6.0.1
redis 5.0.1
requests 2.31.0
requests-oauthlib 1.3.1
responses 0.12.1
rich 13.7.0
rsa 4.9
scikit-learn 1.3.2
scipy 1.11.4
seaborn 0.13.1
sentry-sdk 1.39.1
setproctitle 1.3.3
setuptools 66.1.1
six 1.16.0
smmap 5.0.1
sniffio 1.3.0
sympy 1.12
tabulate 0.9.0
tensorboard 2.15.1
tensorboard-data-server 0.7.2
tensorboardX 2.6.2.2
threadpoolctl 3.2.0
torch 2.1.2
tqdm 4.66.1
treevalue 1.4.12
triton 2.1.0
trueskill 0.4.5
typing_extensions 4.9.0
tzdata 2023.4
urllib3 2.1.0
URLObject 2.4.3
wandb 0.16.1
Werkzeug 1.0.1
wheel 0.41.2
yapf 0.29.0
yattag 1.15.2
"""

Cool, thanks for the update. I'll prepare a change today which I think should fix this but I won't be able to test it myself.

Hi @zjowowen, can you check if the latest version works? Thanks!

Hi @kenjitoyama , the latest version works great! Thanks a lot!