# Path: humanrl/frame.py
# class Episode(object):
# class Frame(object):
# class HumanLabelWrapper(gym.Wrapper):
# class FrameSaverWrapper(gym.Wrapper):
#     def __init__(self):
#     def __setstate__(self, state):
#     def __init__(self,
#                  observation=None,
#                  action=None,
#                  reward=None,
#                  image=None,
#                  info=None,
#                  label=None,
#                  prediction=None):
#     def has_action(self):
#     def get_label(self):
#     def set_label(self, label):
#     def was_blocked(self):
#     def get_proposed_action(self):
#     def get_real_action(self):
#     def get_action(self, action_type):
#     def set_proposed_action(self, action):
#     def set_real_action(self, action):
#     def __repr__(self):
#     def __setstate__(self, state):
#     def __init__(self,
#                  env_id,
#                  env,
#                  online_blocking_mode="action_replacement",
#                  reward_scale=1.0,
#                  catastrophe_reward=0.0,
#                  **_):
#     def _reset(self):
#     def __send_init_msg(self):
#     def __send_frame_to_human(self, frame, proposed_action):
#     def __handle_feedback(self, msg, proposed_action):
#     def _step(self, proposed_action):
#     def _close(self):
#     def __init__(self, env, directory, max_episodes=1000):
#     def _reset(self):
#     def _step(self, action):
# def get_episode_number(filename):
# def paths_with_suffix(directory, empty_ok=False, suffixes=("pkl.gz", )):
# def episode_paths(directory, empty_ok=False):
# def feature_file_paths(directory, empty_ok=False):
# def load_episode(episode_path):
# def save_episode(episode_path, episode):
# def check_episode(episode_path):
# def fix_episode(episode_path):
#     REAL = "real"
#     PROPOSED = "proposed"


import argparse
import distutils.version
import logging
import os
import signal
import sys
import time
import go_vncdriver
import tensorflow as tf
from a3c import A3C
from envs import create_env
from hparams import add_hparams, get_hparams
from humanrl import frame
#!/usr/bin/env python


## Imports for catastrophe/blocking wrappers

use_tf12_api = distutils.version.LooseVersion(
    tf.VERSION) >= distutils.version.LooseVersion('0.12.0')

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


# Disables write_meta_graph argument, which freezes entire process and is mostly useless.
class FastSaver(tf.train.Saver):
    def save(self,
             sess,
             save_path,
             global_step=None,
             latest_filename=None,
             meta_graph_suffix="meta",
             write_meta_graph=True):
        super(FastSaver, self).save(sess, save_path, global_step, latest_filename,
                                    meta_graph_suffix, False)


def run(args, server):
    hparams = get_hparams(args)

# Path: humanrl/frame.py
# class Episode(object):
# class Frame(object):
# class HumanLabelWrapper(gym.Wrapper):
# class FrameSaverWrapper(gym.Wrapper):
#     def __init__(self):
#     def __setstate__(self, state):
#     def __init__(self,
#                  observation=None,
#                  action=None,
#                  reward=None,
#                  image=None,
#                  info=None,
#                  label=None,
#                  prediction=None):
#     def has_action(self):
#     def get_label(self):
#     def set_label(self, label):
#     def was_blocked(self):
#     def get_proposed_action(self):
#     def get_real_action(self):
#     def get_action(self, action_type):
#     def set_proposed_action(self, action):
#     def set_real_action(self, action):
#     def __repr__(self):
#     def __setstate__(self, state):
#     def __init__(self,
#                  env_id,
#                  env,
#                  online_blocking_mode="action_replacement",
#                  reward_scale=1.0,
#                  catastrophe_reward=0.0,
#                  **_):
#     def _reset(self):
#     def __send_init_msg(self):
#     def __send_frame_to_human(self, frame, proposed_action):
#     def __handle_feedback(self, msg, proposed_action):
#     def _step(self, proposed_action):
#     def _close(self):
#     def __init__(self, env, directory, max_episodes=1000):
#     def _reset(self):
#     def _step(self, action):
# def get_episode_number(filename):
# def paths_with_suffix(directory, empty_ok=False, suffixes=("pkl.gz", )):
# def episode_paths(directory, empty_ok=False):
# def feature_file_paths(directory, empty_ok=False):
# def load_episode(episode_path):
# def save_episode(episode_path, episode):
# def check_episode(episode_path):
# def fix_episode(episode_path):
#     REAL = "real"
#     PROPOSED = "proposed"


# Path: universe-starter-agent/worker.py
import argparse
import distutils.version
import logging
import os
import signal
import sys
import time
import go_vncdriver
import tensorflow as tf
from a3c import A3C
from envs import create_env
from hparams import add_hparams, get_hparams
from humanrl import frame

#!/usr/bin/env python


## Imports for catastrophe/blocking wrappers

use_tf12_api = distutils.version.LooseVersion(
    tf.VERSION) >= distutils.version.LooseVersion('0.12.0')

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


# Disables write_meta_graph argument, which freezes entire process and is mostly useless.
class FastSaver(tf.train.Saver):
    def save(self,
             sess,
             save_path,
             global_step=None,
             latest_filename=None,
             meta_graph_suffix="meta",
             write_meta_graph=True):
        super(FastSaver, self).save(sess, save_path, global_step, latest_filename,
                                    meta_graph_suffix, False)


def run(args, server):
    hparams = get_hparams(args)

    catastrophe_dir = os.path.join(args.log_dir, "catastrophes", "w{}".format(args.task))