def _get_temp_dir(dirpath, strategy): if _is_temp_dir(dirpath, strategy): temp_dir = dirpath else: temp_dir = os.path.join(dirpath, _get_base_dirpath(strategy)) file_io.recursive_create_dir_v2(temp_dir) return temp_dir
def _non_chief_checkpoint_dir(checkpoint_dir, task_id): """Returns a directory for non-chief worker to save checkpoint.""" dirpath = os.path.dirname(checkpoint_dir) base = os.path.basename(checkpoint_dir) base_dirpath = 'workertemp_' + str(task_id) dirpath = os.path.join(dirpath, base_dirpath) file_io.recursive_create_dir_v2(dirpath) return os.path.join(dirpath, base)
def create_dir_recursive_if_not_exists(dir_path: Text): """ Creates directory recursively if it does not exist. Args: dir_path (str): Local path in filesystem. """ if not file_io.is_directory_v2(dir_path): file_io.recursive_create_dir_v2(dir_path)
def _create_empty_output_dir(output_directory: str) -> None: """Creates the `output_directory`. If `output_directory` already exists, it recursively deletes all contents inside the directory. Also creates the parent & intermediate directories. Args: output_directory: Output directory. """ if file_io.file_exists_v2(output_directory): logging.info('Deleting existing directory for quantized model output: %s .', output_directory) file_io.delete_recursively_v2(output_directory) file_io.recursive_create_dir_v2(output_directory)
def _get_temp_dir(dirpath, task_id): base_dirpath = 'workertemp_' + str(task_id) temp_dir = os.path.join(dirpath, base_dirpath) file_io.recursive_create_dir_v2(temp_dir) return temp_dir