3 *]A@sRddlZddlZddlZddlZdejd<ejeZddZ d ddZ d d Z dS) N2ZTF_CPP_MIN_LOG_LEVELcCs8tjj|r4ttj|dkr4tjjtjj|dSdS)z :param checkpoint_dir: Directory to inspect for existing checkpoints :return: True if the directory has checkpoints, False if the directory is empty r checkpointF)ospathisdirlenlistdirisfilejoin)checkpoint_dirr C/home/ubuntu/environment/simulation_ws/src/rl-agent/markov/utils.pyhas_checkpoints r cCsJx2t|D]&}|r|jt|r&dStjdq Wtdj||ddS)z= block until there is a checkpoint in checkpoint_dir NrzETried {retries} times, but checkpoint never found in {checkpoint_dir})retriesr )rangeload_from_storertimesleep ValueErrorformat)r data_storerir r r wait_for_checkpointsrcCsRtjj|stj|dg}tjj|j|jj|}tj j ||dddt ddS)Nz8main_level/agent/main/online/network_1/ppo_head_0/policyzmodel.pbF)as_textzSaved TF frozen graph!) rrexistsmakedirstf graph_utilconvert_variables_to_constantssess graph_deftrain write_graphprint) graph_manager local_pathZ output_headfrozenr r r write_frozen_graph.s   r()Nr) rloggingr tensorflowrenviron getLogger__name__loggerrrr(r r r r s