# Path: studio/artifacts/artifacts_tracker.py
# STUDIOML_EXPERIMENT = 'STUDIOML_EXPERIMENT'
# STUDIOML_HOME = 'STUDIOML_HOME'
# STUDIOML_ARTIFACT_MAPPING = 'STUDIOML_ARTIFACT_MAPPING'
# def get_experiment_key():
# def get_studio_home():
# def _setup_model_directory(experiment_name, clean=False):
# def setup_experiment(env, experiment, clean=True):
# def get_artifact(tag):
# def get_artifacts():
# def get_artifact_cache(tag, experiment_name=None):
# def get_blob_cache(blobkey):
# def _get_artifact_mapping_path(experiment_name=None):
# def get_tensorboard_dir(experiment_name=None):
# 
# Path: studio/util/util.py
# DAY = 86400
# HOUR = 3600
# MINUTE = 60
# def remove_backspaces(line):
# def report_fatal(msg: str, logger):
# def sha256_checksum(filename, block_size=65536):
# def filehash(filename, block_size=65536, hashobj=None):
# def rand_string(length):
# def _looks_like_url(name):
# def parse_s3_path(qualified: str):
# def retry(f,
#           no_retries=5, sleep_time=1,
#           exception_class=BaseException, logger=None):
# def compression_to_extension(compression):
# def compression_to_taropt(compression):
# def _compression_to_extension_taropt(compression):
# def timeit(method):
#     def timed(*args, **kw):
# def sixdecode(sval):
# def shquote(sval):
# def parse_duration(duration_str):
# def parse_verbosity(verbosity=None):
# def str2duration(sval):
# def get_temp_filename() -> str:
# def delete_local_path(local_path: str, root: str, shallow: bool):
# def delete_local_folders(local_folder_path: str, root: str):
# def rm_rf(path):
# def check_for_kb_interrupt():
# def add_packages(list1, list2):


import os
import requests
import shutil
import time
import tarfile
import tempfile
from studio.artifacts import artifacts_tracker
from studio.util import util
        for file_name in files_list:
            tf.add(os.path.join(local_path, file_name), arcname=file_name)
    except Exception as exc:
        msg: str =\
            "FAILED to create tarfile: {0} for artifact {1} reason: {2}"\
            .format(tar_filename, local_path, exc)
        util.report_fatal(msg, logger)
    finally:
        if tf is not None:
            tf.close()

def _tar_artifact_single_file(local_path: str,
                            tar_filename: str,
                            key,
                            logger):
    tf = None
    try:
        debug_str: str = ("Tarring artifact single file. " +
                     "tar_filename = {0}, " +
                     "local_path = {1}, " +
                     "key = {2}").format(tar_filename, local_path, key)
        logger.debug(debug_str)

        tf = tarfile.open(tar_filename, 'w')
        _, last_name = os.path.split(local_path)
        tf.add(local_path, "./" + last_name)
    except Exception as exc:
        msg: str =\
            "FAILED to create tarfile: {0} for artifact {1} reason: {2}"\
            .format(tar_filename, local_path, exc)

# Path: studio/artifacts/artifacts_tracker.py
# STUDIOML_EXPERIMENT = 'STUDIOML_EXPERIMENT'
# STUDIOML_HOME = 'STUDIOML_HOME'
# STUDIOML_ARTIFACT_MAPPING = 'STUDIOML_ARTIFACT_MAPPING'
# def get_experiment_key():
# def get_studio_home():
# def _setup_model_directory(experiment_name, clean=False):
# def setup_experiment(env, experiment, clean=True):
# def get_artifact(tag):
# def get_artifacts():
# def get_artifact_cache(tag, experiment_name=None):
# def get_blob_cache(blobkey):
# def _get_artifact_mapping_path(experiment_name=None):
# def get_tensorboard_dir(experiment_name=None):
# 
# Path: studio/util/util.py
# DAY = 86400
# HOUR = 3600
# MINUTE = 60
# def remove_backspaces(line):
# def report_fatal(msg: str, logger):
# def sha256_checksum(filename, block_size=65536):
# def filehash(filename, block_size=65536, hashobj=None):
# def rand_string(length):
# def _looks_like_url(name):
# def parse_s3_path(qualified: str):
# def retry(f,
#           no_retries=5, sleep_time=1,
#           exception_class=BaseException, logger=None):
# def compression_to_extension(compression):
# def compression_to_taropt(compression):
# def _compression_to_extension_taropt(compression):
# def timeit(method):
#     def timed(*args, **kw):
# def sixdecode(sval):
# def shquote(sval):
# def parse_duration(duration_str):
# def parse_verbosity(verbosity=None):
# def str2duration(sval):
# def get_temp_filename() -> str:
# def delete_local_path(local_path: str, root: str, shallow: bool):
# def delete_local_folders(local_folder_path: str, root: str):
# def rm_rf(path):
# def check_for_kb_interrupt():
# def add_packages(list1, list2):


# Path: studio/storage/storage_util.py
import os
import requests
import shutil
import time
import tarfile
import tempfile
from studio.artifacts import artifacts_tracker
from studio.util import util

        for file_name in files_list:
            tf.add(os.path.join(local_path, file_name), arcname=file_name)
    except Exception as exc:
        msg: str =\
            "FAILED to create tarfile: {0} for artifact {1} reason: {2}"\
            .format(tar_filename, local_path, exc)
        util.report_fatal(msg, logger)
    finally:
        if tf is not None:
            tf.close()

def _tar_artifact_single_file(local_path: str,
                            tar_filename: str,
                            key,
                            logger):
    tf = None
    try:
        debug_str: str = ("Tarring artifact single file. " +
                     "tar_filename = {0}, " +
                     "local_path = {1}, " +
                     "key = {2}").format(tar_filename, local_path, key)
        logger.debug(debug_str)

        tf = tarfile.open(tar_filename, 'w')
        _, last_name = os.path.split(local_path)
        tf.add(local_path, "./" + last_name)
    except Exception as exc:
        msg: str =\
            "FAILED to create tarfile: {0} for artifact {1} reason: {2}"\
            .format(tar_filename, local_path, exc)

        util.report_fatal(msg, logger)