def test_get_items_from_string() -> None: """ Check items correctly extracted from string. """ assert ["i", "p"] == common_util.get_items_from_string("i, ,p") assert ["i", "p"] == common_util.get_items_from_string("i- -p", separator="-") assert ["i", " ", " p"] == common_util.get_items_from_string("i, , p", remove_blanks=False) assert ["i", "p"] == common_util.get_items_from_string("i, , p") assert [] == common_util.get_items_from_string("")
def monitor(monitor_config: AMLTensorBoardMonitorConfig, azure_config: AzureConfig) -> None: """ Starts TensorBoard monitoring as per the provided arguments. :param monitor_config: The config containing information on which runs that need be monitored. :param azure_config: An AzureConfig object with secrets/keys to access the workspace. """ # Fetch AzureML workspace and the experiment runs in it workspace = azure_config.get_workspace() if monitor_config.run_ids is not None: if len(monitor_config.run_ids) == 0: print("At least one run_recovery_id must be given for monitoring.") sys.exit(1) exp_runs = [ azure_util.fetch_run(workspace, run_id) for run_id in monitor_config.run_ids ] else: if monitor_config.experiment_name not in workspace.experiments: print(f"The experiment: {monitor_config.experiment_name} doesn't " f"exist in the {monitor_config.workspace_name} workspace.") sys.exit(1) experiment = Experiment(workspace, monitor_config.experiment_name) filters = common_util.get_items_from_string( monitor_config.run_status) if monitor_config.run_status else [] exp_runs = azure_util.fetch_runs(experiment, filters) if len(exp_runs) == 0: _msg = "No runs to monitor" if monitor_config.run_status: _msg += f"with status [{monitor_config.run_status}]." print(_msg) sys.exit(1) # Start TensorBoard on executing machine ts = Tensorboard(exp_runs, local_root=str(monitor_config.local_root), port=monitor_config.port) print( "==============================================================================" ) for run in exp_runs: print(f"Run URL: {run.get_portal_url()}") print("TensorBoard URL: ") ts.start() print( "==============================================================================\n\n" ) input("Press Enter to close TensorBoard...") ts.stop()