src/toil_lib/abstractPipelineWrapper.py
def run(cls, name, desc):
        """
        Prepares and runs the pipeline. Note this method must be invoked both from inside a
        Docker container and while the docker daemon is reachable.

        :param str name: The name of the command to start the workflow.
        :param str desc: The description of the workflow.
        """
        wrapper = cls(name, desc)
        mount_path = wrapper._get_mount_path()
        # prepare parser
        arg_parser = wrapper._create_argument_parser()
        wrapper._extend_argument_parser(arg_parser)
        # prepare config file
        empty_config = wrapper.__get_empty_config()
        config_yaml = ruamel.yaml.load(empty_config)
        wrapper.__populate_parser_from_config(arg_parser, config_yaml)
        args = arg_parser.parse_args()
        for k,v in vars(args).items():
            k = k.replace('_', '-')
            if k in config_yaml:
                config_yaml[k] = v
        config_path = wrapper._get_config_path()
        with open(config_path, 'w') as writable:
            ruamel.yaml.dump(config_yaml, stream=writable)
        # prepare workdir
        workdir_path = os.path.join(mount_path, 'Toil-' + wrapper._name)
        if os.path.exists(workdir_path):
            if args.restart:
                 log.info('Reusing temporary directory: %s', workdir_path)
            else:
                raise UserError('Temporary directory {} already exists. Run with --restart '
                                'option or remove directory.'.format(workdir_path))
        else:
            os.makedirs(workdir_path)
            log.info('Temporary directory created: %s', workdir_path)

        command = wrapper._create_pipeline_command(args, workdir_path, config_path)
        wrapper._extend_pipeline_command(command, args)
        # run command
        try:
            subprocess.check_call(command)
        except subprocess.CalledProcessError as e:
            print(e, file=sys.stderr)
        finally:
            stat = os.stat(mount_path)
            log.info('Pipeline terminated, changing ownership of output files in %s from root to '
                     'uid %s and gid %s.', mount_path, stat.st_uid, stat.st_gid)
            chown_command = ['chown', '-R', '%s:%s' % (stat.st_uid, stat.st_gid), mount_path]
            subprocess.check_call(chown_command)
            if args.no_clean:
                log.info('Flag "--no-clean" was used, therefore %s was not deleted.', workdir_path)
            else:
                log.info('Cleaning up temporary directory: %s', workdir_path)
                shutil.rmtree(workdir_path)
def run(cls, name, desc):
        wrapper = cls(name, desc)
        mount_path = wrapper._get_mount_path()
        # prepare parser
        arg_parser = wrapper._create_argument_parser()
        wrapper._extend_argument_parser(arg_parser)
        # prepare config file
        empty_config = wrapper.__get_empty_config()
        config_yaml = ruamel.yaml.load(empty_config)
        wrapper.__populate_parser_from_config(arg_parser, config_yaml)
        args = arg_parser.parse_args()
        for k,v in vars(args).items():
            k = k.replace('_', '-')
            if k in config_yaml:
                config_yaml[k] = v
        config_path = wrapper._get_config_path()
        with open(config_path, 'w') as writable:
            ruamel.yaml.dump(config_yaml, stream=writable)
        # prepare workdir
        workdir_path = os.path.join(mount_path, 'Toil-' + wrapper._name)
        if os.path.exists(workdir_path):
            if args.restart:
                 log.info('Reusing temporary directory: %s', workdir_path)
            else:
                raise UserError('Temporary directory {} already exists. Run with --restart '
                                'option or remove directory.'.format(workdir_path))
        else:
            os.makedirs(workdir_path)
            log.info('Temporary directory created: %s', workdir_path)

        command = wrapper._create_pipeline_command(args, workdir_path, config_path)
        wrapper._extend_pipeline_command(command, args)
        # run command
        try:
            subprocess.check_call(command)
        except subprocess.CalledProcessError as e:
            print(e, file=sys.stderr)
        finally:
            stat = os.stat(mount_path)
            log.info('Pipeline terminated, changing ownership of output files in %s from root to '
                     'uid %s and gid %s.', mount_path, stat.st_uid, stat.st_gid)
            chown_command = ['chown', '-R', '%s:%s' % (stat.st_uid, stat.st_gid), mount_path]
            subprocess.check_call(chown_command)
            if args.no_clean:
                log.info('Flag "--no-clean" was used, therefore %s was not deleted.', workdir_path)
            else:
                log.info('Cleaning up temporary directory: %s', workdir_path)
                shutil.rmtree(workdir_path)
def run ( cls , name , desc ) : wrapper = cls ( name , desc ) mount_path = wrapper . _get_mount_path ( ) # prepare parser arg_parser = wrapper . _create_argument_parser ( ) wrapper . _extend_argument_parser ( arg_parser ) # prepare config file empty_config = wrapper . __get_empty_config ( ) config_yaml = ruamel . yaml . load ( empty_config ) wrapper . __populate_parser_from_config ( arg_parser , config_yaml ) args = arg_parser . parse_args ( ) for k , v in vars ( args ) . items ( ) : k = k . replace ( '_' , '-' ) if k in config_yaml : config_yaml [ k ] = v config_path = wrapper . _get_config_path ( ) with open ( config_path , 'w' ) as writable : ruamel . yaml . dump ( config_yaml , stream = writable ) # prepare workdir workdir_path = os . path . join ( mount_path , 'Toil-' + wrapper . _name ) if os . path . exists ( workdir_path ) : if args . restart : log . info ( 'Reusing temporary directory: %s' , workdir_path ) else : raise UserError ( 'Temporary directory {} already exists. Run with --restart ' 'option or remove directory.' . format ( workdir_path ) ) else : os . makedirs ( workdir_path ) log . info ( 'Temporary directory created: %s' , workdir_path ) command = wrapper . _create_pipeline_command ( args , workdir_path , config_path ) wrapper . _extend_pipeline_command ( command , args ) # run command try : subprocess . check_call ( command ) except subprocess . CalledProcessError as e : print ( e , file = sys . stderr ) finally : stat = os . stat ( mount_path ) log . info ( 'Pipeline terminated, changing ownership of output files in %s from root to ' 'uid %s and gid %s.' , mount_path , stat . st_uid , stat . st_gid ) chown_command = [ 'chown' , '-R' , '%s:%s' % ( stat . st_uid , stat . st_gid ) , mount_path ] subprocess . check_call ( chown_command ) if args . no_clean : log . info ( 'Flag "--no-clean" was used, therefore %s was not deleted.' , workdir_path ) else : log . info ( 'Cleaning up temporary directory: %s' , workdir_path ) shutil . rmtree ( workdir_path )
Prepares and runs the pipeline. Note this method must be invoked both from inside a
        Docker container and while the docker daemon is reachable.

        :param str name: The name of the command to start the workflow.
        :param str desc: The description of the workflow.
Prepares and runs the pipeline . Note this method must be invoked both from inside a Docker container and while the docker daemon is reachable .