PKU-DAIR / open-box

Generalized and Efficient Blackbox Optimization System
https://open-box.readthedocs.io
Other
356 stars 52 forks source link

How do I use visualization function in a docker container? #74

Closed DimanChauncey closed 6 months ago

DimanChauncey commented 6 months ago

Hello, I deployed my experimental environment in a Docker container and used OpenBox to optimizing, but when visualizing, it cannot call webbrowser.open().

[2023-12-28 00:32:13,392][moc][ERROR][html_visualizer.py:473] Failed to open html file! Please open it manually: file:///root/logs/history/moc/moc_2023-12-28-00-32-09-230659.html Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/openbox/visualization/html_visualizer.py", line 471, in open_html raise ValueError('webbrowser.open() returned False.') ValueError: webbrowser.open() returned False.

Is there any way for me to copy the files to a host machine or a Windows machine and then open the browser and render the visualized website?

Thanks for your help!

jhj0411jhj commented 6 months ago

Please set visualization='basic' or 'advance' and set auto_open_html=False. The html page will be generated but not opened.

DimanChauncey commented 6 months ago

but...the html page is almost empty when I open it in a browser. Like this.

Snipaste_2023-12-28_15-02-30

And each item is same.

Snipaste_2023-12-28_15-04-22
DimanChauncey commented 6 months ago

Can I copy all history files to the host machine and then use tools to render the image? How should I do

jhj0411jhj commented 6 months ago

The generated HTML file needs to load other static files to render the page. If you move the file to another environment, it cannot find the resource correctly, so the page is almost blank.

To fix it: install OpenBox on both container and host machine. And move history file from docker to host machine:

# In docker: save history to json file first
history = optimizer.get_history()
history.save_json(...)

# Move json history to host machine
# On host machine: load history from json
history = History.load_json(...)

# Then render the page
history.visualize_html(...)