# Path: pytorchrl/config.py
# PROJECT_PATH = osp.abspath(osp.join(osp.dirname(__file__), '..'))
# LOG_DIR = PROJECT_PATH + "/data"
# USE_TF = False
# DOCKER_IMAGE = "DOCKER_IMAGE"
# DOCKERFILE_PATH = "/path/to/Dockerfile"
# KUBE_PREFIX = "rllab_"
# DOCKER_LOG_DIR = "/tmp/expt"
# POD_DIR = PROJECT_PATH + "/.pods"
# AWS_S3_PATH = None
# AWS_IMAGE_ID = None
# AWS_INSTANCE_TYPE = "m4.xlarge"
# AWS_KEY_NAME = "AWS_KEY_NAME"
# AWS_SPOT = True
# AWS_SPOT_PRICE = '1.0'
# AWS_ACCESS_KEY = os.environ.get("AWS_ACCESS_KEY", None)
# AWS_ACCESS_SECRET = os.environ.get("AWS_ACCESS_SECRET", None)
# AWS_IAM_INSTANCE_PROFILE_NAME = "pytorchrl"
# AWS_SECURITY_GROUPS = ["pytorchrl"]
# AWS_SECURITY_GROUP_IDS = []
# AWS_NETWORK_INTERFACES = []
# AWS_EXTRA_CONFIGS = dict()
# AWS_REGION_NAME = "us-east-1"
# CODE_SYNC_IGNORES = ["*.git/*", "*data/*", "*.pod/*"]
# DOCKER_CODE_DIR = "/root/code/pytorchrl"
# AWS_CODE_SYNC_S3_PATH = "s3://to/be/overriden/in/personal"
# FAST_CODE_SYNC = True
# FAST_CODE_SYNC_IGNORES = [".git", "data", ".pods"]
# KUBE_DEFAULT_RESOURCES = {
#     "requests": {
#         "cpu": 0.8,
#     }
# }
# KUBE_DEFAULT_NODE_SELECTOR = {
#     "aws/type": "m4.xlarge",
# }
# MUJOCO_KEY_PATH = osp.expanduser("~/.mujoco")
# ENV = {}
# EBS_OPTIMIZED = True
# LABEL = ""


import collections
import os
import re
import subprocess
import base64
import os.path as osp
import pickle as pickle
import inspect
import hashlib
import sys
import errno
import datetime
import dateutil.tz
import json
import time
import numpy as np
            import cloudpickle
    import boto3
    import botocore
        import pprint
        import pprint
    import tempfile
    import uuid
                import traceback
from contextlib import contextmanager
from io import StringIO
from rllab.misc import ext
from rllab.misc.ext import AttrDict
from rllab.viskit.core import flatten
from rllab.core.serializable import Serializable
from rllab.misc.console import mkdir_p
from pytorchrl import config
        periodic_sync_interval=15,
        sync_all_data_node_to_s3=False,
        terminate_machine=True
):
    """
    :param params: The parameters for the experiment. If logging directory parameters are provided, we will create
    docker volume mapping to make sure that the logging files are created at the correct locations
    :param docker_image: docker image to run the command on
    :param script: script command for running experiment
    :return:
    """
    log_dir = params.get("log_dir")
    remote_log_dir = params.pop("remote_log_dir")
    resources = params.pop("resources")
    node_selector = params.pop("node_selector")
    exp_prefix = params.pop("exp_prefix")

    kube_env = [
        {"name": k, "value": v}
        for k, v in (params.pop("env", None) or dict()).items()
        ]
    mkdir_p(log_dir)
    pre_commands = list()
    pre_commands.append('mkdir -p ~/.aws')
    pre_commands.append('mkdir ~/.mujoco')
    # fetch credentials from the kubernetes secret file
    pre_commands.append('echo "[default]" >> ~/.aws/credentials')
    pre_commands.append(
        "echo \"aws_access_key_id = %s\" >> ~/.aws/credentials" % config.AWS_ACCESS_KEY)
    pre_commands.append(

# Path: pytorchrl/config.py
# PROJECT_PATH = osp.abspath(osp.join(osp.dirname(__file__), '..'))
# LOG_DIR = PROJECT_PATH + "/data"
# USE_TF = False
# DOCKER_IMAGE = "DOCKER_IMAGE"
# DOCKERFILE_PATH = "/path/to/Dockerfile"
# KUBE_PREFIX = "rllab_"
# DOCKER_LOG_DIR = "/tmp/expt"
# POD_DIR = PROJECT_PATH + "/.pods"
# AWS_S3_PATH = None
# AWS_IMAGE_ID = None
# AWS_INSTANCE_TYPE = "m4.xlarge"
# AWS_KEY_NAME = "AWS_KEY_NAME"
# AWS_SPOT = True
# AWS_SPOT_PRICE = '1.0'
# AWS_ACCESS_KEY = os.environ.get("AWS_ACCESS_KEY", None)
# AWS_ACCESS_SECRET = os.environ.get("AWS_ACCESS_SECRET", None)
# AWS_IAM_INSTANCE_PROFILE_NAME = "pytorchrl"
# AWS_SECURITY_GROUPS = ["pytorchrl"]
# AWS_SECURITY_GROUP_IDS = []
# AWS_NETWORK_INTERFACES = []
# AWS_EXTRA_CONFIGS = dict()
# AWS_REGION_NAME = "us-east-1"
# CODE_SYNC_IGNORES = ["*.git/*", "*data/*", "*.pod/*"]
# DOCKER_CODE_DIR = "/root/code/pytorchrl"
# AWS_CODE_SYNC_S3_PATH = "s3://to/be/overriden/in/personal"
# FAST_CODE_SYNC = True
# FAST_CODE_SYNC_IGNORES = [".git", "data", ".pods"]
# KUBE_DEFAULT_RESOURCES = {
#     "requests": {
#         "cpu": 0.8,
#     }
# }
# KUBE_DEFAULT_NODE_SELECTOR = {
#     "aws/type": "m4.xlarge",
# }
# MUJOCO_KEY_PATH = osp.expanduser("~/.mujoco")
# ENV = {}
# EBS_OPTIMIZED = True
# LABEL = ""


# Path: pytorchrl/misc/instrument.py
import collections
import os
import re
import subprocess
import base64
import os.path as osp
import pickle as pickle
import inspect
import hashlib
import sys
import errno
import datetime
import dateutil.tz
import json
import time
import numpy as np
            import cloudpickle
    import boto3
    import botocore
        import pprint
        import pprint
    import tempfile
    import uuid
                import traceback
from contextlib import contextmanager
from io import StringIO
from rllab.misc import ext
from rllab.misc.ext import AttrDict
from rllab.viskit.core import flatten
from rllab.core.serializable import Serializable
from rllab.misc.console import mkdir_p
from pytorchrl import config

        periodic_sync_interval=15,
        sync_all_data_node_to_s3=False,
        terminate_machine=True
):
    """
    :param params: The parameters for the experiment. If logging directory parameters are provided, we will create
    docker volume mapping to make sure that the logging files are created at the correct locations
    :param docker_image: docker image to run the command on
    :param script: script command for running experiment
    :return:
    """
    log_dir = params.get("log_dir")
    remote_log_dir = params.pop("remote_log_dir")
    resources = params.pop("resources")
    node_selector = params.pop("node_selector")
    exp_prefix = params.pop("exp_prefix")

    kube_env = [
        {"name": k, "value": v}
        for k, v in (params.pop("env", None) or dict()).items()
        ]
    mkdir_p(log_dir)
    pre_commands = list()
    pre_commands.append('mkdir -p ~/.aws')
    pre_commands.append('mkdir ~/.mujoco')
    # fetch credentials from the kubernetes secret file
    pre_commands.append('echo "[default]" >> ~/.aws/credentials')
    pre_commands.append(
        "echo \"aws_access_key_id = %s\" >> ~/.aws/credentials" % config.AWS_ACCESS_KEY)
    pre_commands.append(

        "echo \"aws_secret_access_key = %s\" >> ~/.aws/credentials" % config.AWS_ACCESS_SECRET)