diff --git a/rl_coach/dashboard.py b/rl_coach/dashboard.py index da8eb1a..d62e021 100644 --- a/rl_coach/dashboard.py +++ b/rl_coach/dashboard.py @@ -43,6 +43,12 @@ parser.add_argument('-f', '--experiment_files', help="(string) The path of an experiment file to open", default=None, type=str) +parser.add_argument('-rc', '--allow_remote_connection', + help="(flag) Allow remote connection to view dashboard results from a remote machine. " + "Note this opens up the connection and allows anyone who tries to connect to the " + "ip address/port to connect and view the bokeh results via their browser.", + action='store_true') + args = parser.parse_args() if args.experiment_dir: @@ -58,7 +64,19 @@ def main(): from rl_coach.utils import get_open_port dashboard_path = os.path.realpath(__file__) - command = 'bokeh serve --show {} --port {}'.format(dashboard_path, get_open_port()) + port = get_open_port() + command = 'bokeh serve --show {path} --port {port}'.format(path=dashboard_path, port=port) + + if args.allow_remote_connection: + # when allowing remote connection, selecting an experiment or a file via the GUI buttons do not seem to work + # well from remote. Instead, we only allow entering an experiment dir from command line. + if not args.experiment_dir and not args.experiment_files: + raise ValueError("The allow_remote_connection flag only works in conjunction with either the experiment_dir" + " or the experiment_files flag. ") + + # allow-websocket-origin = * allows connections from a remote machine. + command += ' --allow-websocket-origin=*' + if args.experiment_dir or args.experiment_files: command += ' --args' if args.experiment_dir: