Ejemplo n.º 1
0
def copy_file(src: Text, dst: Text, overwrite: bool = False):
    """Copies a single file from source to destination."""

    if overwrite and fileio.exists(dst):
        fileio.remove(dst)
    dst_dir = os.path.dirname(dst)
    fileio.makedirs(dst_dir)
    fileio.copy(src, dst, overwrite=overwrite)
Ejemplo n.º 2
0
def remove_output_dirs(output_dict: Dict[Text, List[types.Artifact]]) -> None:
    """Remove dirs of output artifacts' URI."""
    for _, artifact_list in output_dict.items():
        for artifact in artifact_list:
            if fileio.isdir(artifact.uri):
                fileio.rmtree(artifact.uri)
            else:
                fileio.remove(artifact.uri)
Ejemplo n.º 3
0
def _remove_task_dirs(task: task_lib.ExecNodeTask) -> None:
    """Removes directories created for the task."""
    if task.stateful_working_dir:
        outputs_utils.remove_stateful_working_dir(task.stateful_working_dir)
    if task.tmp_dir:
        try:
            fileio.rmtree(task.tmp_dir)
        except fileio.NotFoundError:
            logging.warning(
                'tmp_dir %s not found while attempting to delete, ignoring.')
    if task.executor_output_uri:
        try:
            fileio.remove(task.executor_output_uri)
        except fileio.NotFoundError:
            logging.warning(
                'Skipping deletion of executor_output_uri (file not found): %s',
                task.executor_output_uri)