def archive(self, path):
    'Archives workflow such that it can be re-run on a different system.\n\n        Archiving includes git versioned files (i.e. Snakefiles, config files, ...),\n        ancestral input files and conda environments.\n        '
    if path.endswith('.tar'):
        mode = 'x'
    elif path.endswith('tar.bz2'):
        mode = 'x:bz2'
    elif path.endswith('tar.xz'):
        mode = 'x:xz'
    elif path.endswith('tar.gz'):
        mode = 'x:gz'
    else:
        raise WorkflowError('Unsupported archive format (supported: .tar, .tar.gz, .tar.bz2, .tar.xz)')
    if os.path.exists(path):
        raise WorkflowError(('Archive already exists:\n' + path))
    self.create_conda_envs(forceall=True)
    try:
        workdir = Path(os.path.abspath(os.getcwd()))
        with tarfile.open(path, mode=mode, dereference=True) as archive:
            archived = set()

            def add(path):
                if (workdir not in Path(os.path.abspath(path)).parents):
                    logger.warning('Path {} cannot be archived: not within working directory.'.format(path))
                else:
                    f = os.path.relpath(path)
                    if (f not in archived):
                        archive.add(f)
                        archived.add(f)
                        logger.info(('archived ' + f))
            logger.info('Archiving snakefiles, scripts and files under version control...')
            for f in self.workflow.get_sources():
                add(f)
            logger.info('Archiving external input files...')
            for job in self.jobs:
                for f in job.input:
                    if (not any(((f in files) for files in self.dependencies[job].values()))):
                        add(f)
            logger.info('Archiving conda environments...')
            envs = set()
            for job in self.jobs:
                if job.conda_env_file:
                    env_archive = job.archive_conda_env()
                    envs.add(env_archive)
            for env in envs:
                add(env)
    except (Exception, BaseException) as e:
        os.remove(path)
        raise e
Archives workflow such that it can be re-run on a different system.

Archiving includes git versioned files (i.e. Snakefiles, config files, ...),
ancestral input files and conda environments.
def archive(self, path):
    'Archives workflow such that it can be re-run on a different system.\n\n        Archiving includes git versioned files (i.e. Snakefiles, config files, ...),\n        ancestral input files and conda environments.\n        '
    if path.endswith('.tar'):
        mode = 'x'
    elif path.endswith('tar.bz2'):
        mode = 'x:bz2'
    elif path.endswith('tar.xz'):
        mode = 'x:xz'
    elif path.endswith('tar.gz'):
        mode = 'x:gz'
    else:
        raise WorkflowError('Unsupported archive format (supported: .tar, .tar.gz, .tar.bz2, .tar.xz)')
    if os.path.exists(path):
        raise WorkflowError(('Archive already exists:\n' + path))
    self.create_conda_envs(forceall=True)
    try:
        workdir = Path(os.path.abspath(os.getcwd()))
        with tarfile.open(path, mode=mode, dereference=True) as archive:
            archived = set()

            def add(path):
                if (workdir not in Path(os.path.abspath(path)).parents):
                    logger.warning('Path {} cannot be archived: not within working directory.'.format(path))
                else:
                    f = os.path.relpath(path)
                    if (f not in archived):
                        archive.add(f)
                        archived.add(f)
                        logger.info(('archived ' + f))
            logger.info('Archiving snakefiles, scripts and files under version control...')
            for f in self.workflow.get_sources():
                add(f)
            logger.info('Archiving external input files...')
            for job in self.jobs:
                for f in job.input:
                    if (not any(((f in files) for files in self.dependencies[job].values()))):
                        add(f)
            logger.info('Archiving conda environments...')
            envs = set()
            for job in self.jobs:
                if job.conda_env_file:
                    env_archive = job.archive_conda_env()
                    envs.add(env_archive)
            for env in envs:
                add(env)
    except (Exception, BaseException) as e:
        os.remove(path)
        raise e