# Path: third_party/xiuminglib/xiuminglib/os.py
# def _is_cnspath(path):
#     return isinstance(path, str) and path.startswith('/cns/')
# 
# def _no_trailing_slash(path):
#     if path.endswith('/'):
#         path = path[:-1]
#     assert not path.endswith('/'), "path shouldn't end with '//'"
#     # Guaranteed to not end with '/', so basename() or dirname()
#     # will give the correct results
#     return path
# 
# def cp(src, dst, cns_parallel_copy=10):
#     """Copies files, possibly from/to the Google Colossus Filesystem.
# 
#     Args:
#         src (str): Source file or directory.
#         dst (str): Destination file or directory.
#         cns_parallel_copy (int): The number of files to be copied in
#             parallel. Only effective when copying a directory from/to
#             Colossus.
#     """
#     src = _no_trailing_slash(src)
#     dst = _no_trailing_slash(dst)
# 
#     srcexists, srcisdir = exists_isdir(src)
#     if not srcexists:
#         raise FileNotFoundError("Source must exist")
# 
#     # When no CNS paths involved, quickly do the job and return
#     if not _is_cnspath(src) and not _is_cnspath(dst):
#         if srcisdir:
#             for x in os.listdir(src):
#                 s = join(src, x)
#                 d = join(dst, x)
#                 if isdir(s):
#                     copytree(s, d)
#                 else:
#                     copy2(s, d)
#         else:
#             copy2(src, dst)
#         return
# 
#     gfile = preset_import('gfile', assert_success=True)
# 
#     if gfile is None:
#         cmd = 'fileutil cp -f -colossus_parallel_copy '
#         if srcisdir:
#             cmd += '-R -parallel_copy=%d %s ' % \
#                 (cns_parallel_copy, join(src, '*'))
#         else:
#             cmd += '%s ' % src
#         cmd += '%s' % dst
#         # Destination directory may be owned by a Ganpati group
#         if _is_cnspath(dst):
#             cmd += ' --gfs_user %s' % _select_gfs_user(dst)
#         _call_assert_success(cmd)
# 
#     else:
#         with gfile.AsUser(_select_gfs_user(dst)):
#             if srcisdir:
#                 gfile.RecursivelyCopyDir(src, dst, overwrite=True)
#             else:
#                 gfile.Copy(src, dst, overwrite=True)
# 
# def rm(path):
#     """Removes a file or recursively a directory, with Google Colossus
#     compatibility.
# 
#     Args:
#         path (str)
#     """
#     if not _is_cnspath(path):
#         # Quickly do the job and return
#         if exists(path):
#             if isdir(path):
#                 rmtree(path)
#             else:
#                 os.remove(path)
#         return
# 
#     # OK, a CNS path
#     # Use gfile if available
#     gfile = preset_import('gfile')
#     if gfile is not None:
#         gfile.DeleteRecursively(path) # works for file and directory
#     else:
#         # Falls back to filter CLI
#         cmd = 'fileutil rm -R -f %s' % path # works for file and directory
#         _call_assert_success(cmd, quiet=True)
# 
# Path: third_party/xiuminglib/xiuminglib/log.py
# def get_logger(level=None):
#     """Creates a logger for functions in the library.
# 
#     Args:
#         level (str, optional): Logging level. Defaults to ``logging.INFO``.
# 
#     Returns:
#         logging.Logger: Logger created.
#     """
#     if level is None:
#         level = logging.INFO
#     logging.basicConfig(level=level)
#     logger = logging.getLogger()
#     return logger


from time import time, sleep
from os import makedirs, environ
from os.path import join, dirname, getmtime
from .os import _is_cnspath, _no_trailing_slash, cp, rm
from .log import get_logger
import os.path
        cns_path = _no_trailing_slash(cns_path)
        local_basename = '_'.join(cns_path.split('/')[-keep_last_n:])
        # Prefixed by time to avoid dupes
        local_path = join(tmp_dir, '%f_%s' % (time(), local_basename))
        # local_path guaranteed to not end with '/'
        return local_path

    def cp_404ok(src, dst):
        try:
            cp(src, dst)
            logger.debug("\n%s\n\tcopied to\n%s", src, dst)
        except FileNotFoundError:
            logger.warning(("Source doesn't exist yet:\n\t%s\n"
                            "OK if this will be the output"), src)

    def wrapper(*arg, **kwargs):
        t_eps = 0.05 # seconds buffer for super fast somefunc
        # Fetch info. for all CNS paths
        arg_local, kwargs_local = [], {}
        cns2local = {}
        # Positional arguments
        for x in arg:
            if _is_cnspath(x):
                local_path = gen_local_path(x)
                cns2local[x] = local_path
                arg_local.append(local_path)
            else: # intact
                arg_local.append(x)
        # Keyword arguments
        for k, v in kwargs.items():

# Path: third_party/xiuminglib/xiuminglib/os.py
# def _is_cnspath(path):
#     return isinstance(path, str) and path.startswith('/cns/')
# 
# def _no_trailing_slash(path):
#     if path.endswith('/'):
#         path = path[:-1]
#     assert not path.endswith('/'), "path shouldn't end with '//'"
#     # Guaranteed to not end with '/', so basename() or dirname()
#     # will give the correct results
#     return path
# 
# def cp(src, dst, cns_parallel_copy=10):
#     """Copies files, possibly from/to the Google Colossus Filesystem.
# 
#     Args:
#         src (str): Source file or directory.
#         dst (str): Destination file or directory.
#         cns_parallel_copy (int): The number of files to be copied in
#             parallel. Only effective when copying a directory from/to
#             Colossus.
#     """
#     src = _no_trailing_slash(src)
#     dst = _no_trailing_slash(dst)
# 
#     srcexists, srcisdir = exists_isdir(src)
#     if not srcexists:
#         raise FileNotFoundError("Source must exist")
# 
#     # When no CNS paths involved, quickly do the job and return
#     if not _is_cnspath(src) and not _is_cnspath(dst):
#         if srcisdir:
#             for x in os.listdir(src):
#                 s = join(src, x)
#                 d = join(dst, x)
#                 if isdir(s):
#                     copytree(s, d)
#                 else:
#                     copy2(s, d)
#         else:
#             copy2(src, dst)
#         return
# 
#     gfile = preset_import('gfile', assert_success=True)
# 
#     if gfile is None:
#         cmd = 'fileutil cp -f -colossus_parallel_copy '
#         if srcisdir:
#             cmd += '-R -parallel_copy=%d %s ' % \
#                 (cns_parallel_copy, join(src, '*'))
#         else:
#             cmd += '%s ' % src
#         cmd += '%s' % dst
#         # Destination directory may be owned by a Ganpati group
#         if _is_cnspath(dst):
#             cmd += ' --gfs_user %s' % _select_gfs_user(dst)
#         _call_assert_success(cmd)
# 
#     else:
#         with gfile.AsUser(_select_gfs_user(dst)):
#             if srcisdir:
#                 gfile.RecursivelyCopyDir(src, dst, overwrite=True)
#             else:
#                 gfile.Copy(src, dst, overwrite=True)
# 
# def rm(path):
#     """Removes a file or recursively a directory, with Google Colossus
#     compatibility.
# 
#     Args:
#         path (str)
#     """
#     if not _is_cnspath(path):
#         # Quickly do the job and return
#         if exists(path):
#             if isdir(path):
#                 rmtree(path)
#             else:
#                 os.remove(path)
#         return
# 
#     # OK, a CNS path
#     # Use gfile if available
#     gfile = preset_import('gfile')
#     if gfile is not None:
#         gfile.DeleteRecursively(path) # works for file and directory
#     else:
#         # Falls back to filter CLI
#         cmd = 'fileutil rm -R -f %s' % path # works for file and directory
#         _call_assert_success(cmd, quiet=True)
# 
# Path: third_party/xiuminglib/xiuminglib/log.py
# def get_logger(level=None):
#     """Creates a logger for functions in the library.
# 
#     Args:
#         level (str, optional): Logging level. Defaults to ``logging.INFO``.
# 
#     Returns:
#         logging.Logger: Logger created.
#     """
#     if level is None:
#         level = logging.INFO
#     logging.basicConfig(level=level)
#     logger = logging.getLogger()
#     return logger


# Path: third_party/xiuminglib/xiuminglib/decor.py
from time import time, sleep
from os import makedirs, environ
from os.path import join, dirname, getmtime
from .os import _is_cnspath, _no_trailing_slash, cp, rm
from .log import get_logger
import os.path

        cns_path = _no_trailing_slash(cns_path)
        local_basename = '_'.join(cns_path.split('/')[-keep_last_n:])
        # Prefixed by time to avoid dupes
        local_path = join(tmp_dir, '%f_%s' % (time(), local_basename))
        # local_path guaranteed to not end with '/'
        return local_path

    def cp_404ok(src, dst):
        try:
            cp(src, dst)
            logger.debug("\n%s\n\tcopied to\n%s", src, dst)
        except FileNotFoundError:
            logger.warning(("Source doesn't exist yet:\n\t%s\n"
                            "OK if this will be the output"), src)

    def wrapper(*arg, **kwargs):
        t_eps = 0.05 # seconds buffer for super fast somefunc
        # Fetch info. for all CNS paths
        arg_local, kwargs_local = [], {}
        cns2local = {}
        # Positional arguments
        for x in arg:
            if _is_cnspath(x):
                local_path = gen_local_path(x)
                cns2local[x] = local_path
                arg_local.append(local_path)
            else: # intact
                arg_local.append(x)
        # Keyword arguments
        for k, v in kwargs.items():

            if _is_cnspath(v):