Example #1
0
File: BBS-run.py Project: kant/BBS
def prepare_STAGE2_job_queue(target_pkgs, pkg_deps_list, installed_pkgs):
    print "BBS> Preparing STAGE2 job queue ... ",
    stage = 'install'
    jobs = []
    nb_target_pkgs_in_queue = nb_skipped_pkgs = 0
    for pkg in pkg_deps_list.keys():
        version = None
        pkgdumps_prefix = pkg + '.' + stage
        pkgdumps = BBSbase.PkgDumps(None, pkgdumps_prefix)
        if pkg in target_pkgs:
            try:
                version = bbs.parse.getVersionFromDir(pkg)
            except IOError:
                print "BBS>   Can't read %s/DESCRIPTION file!" % pkg
            cmd = BBSbase.getSTAGE2cmd(pkg, version)
            nb_target_pkgs_in_queue += 1
        else:
            if pkg in installed_pkgs:
                cmd = pkgdumps = None
                nb_skipped_pkgs += 1
            else:
                cmd = BBSbase.getSTAGE2cmdForNonTargetPkg(pkg)
        job = BBSbase.InstallPkg_Job(pkg, version, cmd,
                                     pkgdumps, BBSvars.install_rdir)
        jobs.append(job)
    nb_jobs = len(jobs)
    print "OK"
    nb_not_needed = len(target_pkgs) - nb_target_pkgs_in_queue
    nb_non_target_pkgs_in_queue = nb_jobs - nb_target_pkgs_in_queue
    nb_non_target_pkgs_to_install = nb_non_target_pkgs_in_queue - \
                                    nb_skipped_pkgs
    nb_pkgs_to_install = nb_jobs - nb_skipped_pkgs
    print "BBS> Job summary:"
    print "BBS> | %d (out of %d) target pkgs are not supporting pkgs" % \
          (nb_not_needed, len(target_pkgs))
    print "BBS> |   => no need to install them"
    print "BBS> |   => they're not going in the installation queue"
    print "BBS> | %d pkgs in the installation queue (all supporting pkgs):" % \
          nb_jobs
    print "BBS> |   o %d are target pkgs" % nb_target_pkgs_in_queue
    print "BBS> |       => will (re-)install them with 'R CMD INSTALL'"
    print "BBS> |   o %d are non-target pkgs:" % nb_non_target_pkgs_in_queue
    print "BBS> |     - %d are already installed" % nb_skipped_pkgs
    print "BBS> |         => won't re-install them (job will be skipped)"
    print "BBS> |     - %d are not already installed" % \
          nb_non_target_pkgs_to_install
    print "BBS> |         => will install them with"
    print "BBS> |              install.packages(pkg, repos=non_target_repos,"
    print "BBS> |                               dep=FALSE, ...)"
    print "BBS> | Total nb of packages to install: %d" % nb_pkgs_to_install
    print "BBS>"
    job_queue = bbs.jobs.JobQueue(stage, jobs, pkg_deps_list)
    job_queue._nb_pkgs_to_install = nb_pkgs_to_install
    return job_queue
Example #2
0
def prepare_STAGE2_job_queue(target_pkgs, pkg_dep_graph, installed_pkgs,
                             out_dir):
    print('BBS> Preparing STAGE2 job queue ...', end=' ')
    sys.stdout.flush()
    stage = 'install'
    jobs = []
    nb_target_pkgs_in_queue = nb_skipped_pkgs = 0
    for pkg in pkg_dep_graph.keys():
        version = None
        pkgdumps_prefix = pkg + '.' + stage
        pkgdumps = BBSbase.PkgDumps(None, pkgdumps_prefix)
        if pkg in target_pkgs:
            version = bbs.parse.get_Version_from_pkgsrctree(pkg)
            cmd = BBSbase.getSTAGE2cmd(pkg, version)
            nb_target_pkgs_in_queue += 1
        else:
            if pkg in installed_pkgs:
                cmd = pkgdumps = None
                nb_skipped_pkgs += 1
            else:
                cmd = BBSbase.get_install_cmd_for_non_target_pkg(pkg)
        job = BBSbase.InstallPkg_Job(pkg, version, cmd, pkgdumps, out_dir)
        jobs.append(job)
    nb_jobs = len(jobs)
    print('OK')
    sys.stdout.flush()
    nb_not_needed = len(target_pkgs) - nb_target_pkgs_in_queue
    nb_non_target_pkgs_in_queue = nb_jobs - nb_target_pkgs_in_queue
    nb_non_target_pkgs_to_install = nb_non_target_pkgs_in_queue - \
                                    nb_skipped_pkgs
    nb_pkgs_to_install = nb_jobs - nb_skipped_pkgs
    print('BBS> Job summary:')
    print('BBS> | %d (out of %d) target pkgs are not supporting pkgs' % \
          (nb_not_needed, len(target_pkgs)))
    print('BBS> |   => no need to install them')
    print('BBS> |   => they\'re not going in the installation queue')
    print('BBS> | %d pkgs in the installation queue (all supporting pkgs):' % \
          nb_jobs)
    print('BBS> |   o %d are target pkgs' % nb_target_pkgs_in_queue)
    print('BBS> |       => will (re-)install them with \'R CMD INSTALL\'')
    print('BBS> |   o %d are non-target pkgs:' % nb_non_target_pkgs_in_queue)
    print('BBS> |     - %d are already installed' % nb_skipped_pkgs)
    print('BBS> |         => won\'t re-install them (job will be skipped)')
    print('BBS> |     - %d are not already installed' % \
          nb_non_target_pkgs_to_install)
    print('BBS> |         => will install them with')
    print('BBS> |              install.packages(pkg, repos=non_target_repos,')
    print('BBS> |                               dep=FALSE, ...)')
    print('BBS> | Total nb of packages to install: %d' % nb_pkgs_to_install)
    print('BBS>')
    job_queue = bbs.jobs.JobQueue(stage, jobs, pkg_dep_graph)
    job_queue._nb_pkgs_to_install = nb_pkgs_to_install
    return job_queue
Example #3
0
def STAGE2_loop(target_pkgs, pkg_deps_list, installed_pkgs, nb_cpu):
    print "BBS> Preparing STAGE2 job queue ...",
    job_queue = []
    nb_target_pkgs_in_queue = nb_skipped_pkgs = 0
    for pkg in pkg_deps_list.keys():
        version = None
        pkgdumps_prefix = pkg + '.install'
        pkgdumps = BBSbase.PkgDumps(None, pkgdumps_prefix)
        if pkg in target_pkgs:
            try:
                version = bbs.parse.getVersionFromDir(pkg)
            except IOError:
                print "BBS>   Can't read DESCRIPTION file!"
            cmd = BBSbase.getSTAGE2cmd(pkg, version)
            nb_target_pkgs_in_queue += 1
        else:
            if pkg in installed_pkgs:
                cmd = pkgdumps = None
                nb_skipped_pkgs += 1
            else:
                cmd = BBSbase.getSTAGE2cmdForNonTargetPkg(pkg)
        job = BBSbase.InstallPkg_Job(pkg, version, cmd,
                                     pkgdumps, BBSvars.install_rdir)
        job_queue.append(job)
    nb_jobs = len(job_queue)
    print "OK"

    nb_not_needed = len(target_pkgs) - nb_target_pkgs_in_queue
    nb_non_target_pkgs_in_queue = nb_jobs - nb_target_pkgs_in_queue
    nb_non_target_pkgs_to_install = nb_non_target_pkgs_in_queue - \
                                    nb_skipped_pkgs
    nb_pkgs_to_install = nb_jobs - nb_skipped_pkgs
    print "BBS> Job summary:"
    print "BBS> | %d (out of %d) target pkgs are not supporting pkgs" % \
          (nb_not_needed, len(target_pkgs))
    print "BBS> |   => no need to install them"
    print "BBS> |   => they're not going in the installation queue"
    print "BBS> | %d pkgs in the installation queue (all supporting pkgs):" % \
          nb_jobs
    print "BBS> |   o %d are target pkgs" % nb_target_pkgs_in_queue
    print "BBS> |       => will (re-)install them with 'R CMD INSTALL'"
    print "BBS> |   o %d are non-target pkgs:" % nb_non_target_pkgs_in_queue
    print "BBS> |     - %d are already installed" % nb_skipped_pkgs
    print "BBS> |         => won't re-install them (job will be skipped)"
    print "BBS> |     - %d are not already installed" % \
          nb_non_target_pkgs_to_install
    print "BBS> |         => will install them with"
    print "BBS> |              install.packages(pkg, repos=non_target_repos,"
    print "BBS> |                               dep=FALSE, ...)"
    print "BBS> | Total nb of packages to install: %d" % nb_pkgs_to_install
    print "BBS>"
    print "BBS> BEGIN STAGE2 loop."
    t0 = time.time()
    nb_installed = bbs.jobs.processJobQueue(job_queue, pkg_deps_list, nb_cpu,
                                            BBScorevars.r_cmd_timeout, True)
    dt = time.time() - t0
    print "BBS> END STAGE2 loop."
    nb_failures = nb_pkgs_to_install - nb_installed
    print "BBS> -------------------------------------------------------------"
    print "BBS> STAGE2 SUMMARY:"
    print "BBS>   o Working dir: %s" % os.getcwd()
    print "BBS>   o %d pkg dir(s) queued and processed" % nb_jobs
    print "BBS>   o %d pkg(s) to (re-)install: %d successes / %d failures" % \
          (nb_pkgs_to_install, nb_installed, nb_failures)
    print "BBS>   o Total time: %.2f seconds" % dt
    print "BBS> -------------------------------------------------------------"
    return
Example #4
0
def STAGE2_loop(target_pkgs, pkg_deps_list, installed_pkgs, nb_cpu):
    print "BBS> Preparing STAGE2 job queue ...",
    job_queue = []
    nb_target_pkgs_in_queue = nb_skipped_pkgs = 0
    for pkg in pkg_deps_list.keys():
        version = None
        pkgdumps_prefix = pkg + '.install'
        pkgdumps = BBSbase.PkgDumps(None, pkgdumps_prefix)
        if pkg in target_pkgs:
            try:
                version = bbs.parse.getVersionFromDir(pkg)
            except IOError:
                print "BBS>   Can't read DESCRIPTION file!"
            cmd = BBSbase.getSTAGE2cmd(pkg, version)
            nb_target_pkgs_in_queue += 1
        else:
            if pkg in installed_pkgs:
                cmd = pkgdumps = None
                nb_skipped_pkgs += 1
            else:
                cmd = BBSbase.getSTAGE2cmdForNonTargetPkg(pkg)
        job = BBSbase.InstallPkg_Job(pkg, version, cmd, pkgdumps,
                                     BBSvars.install_rdir)
        job_queue.append(job)
    nb_jobs = len(job_queue)
    print "OK"

    nb_not_needed = len(target_pkgs) - nb_target_pkgs_in_queue
    nb_non_target_pkgs_in_queue = nb_jobs - nb_target_pkgs_in_queue
    nb_non_target_pkgs_to_install = nb_non_target_pkgs_in_queue - \
                                    nb_skipped_pkgs
    nb_pkgs_to_install = nb_jobs - nb_skipped_pkgs
    print "BBS> Job summary:"
    print "BBS> | %d (out of %d) target pkgs are not supporting pkgs" % \
          (nb_not_needed, len(target_pkgs))
    print "BBS> |   => no need to install them"
    print "BBS> |   => they're not going in the installation queue"
    print "BBS> | %d pkgs in the installation queue (all supporting pkgs):" % \
          nb_jobs
    print "BBS> |   o %d are target pkgs" % nb_target_pkgs_in_queue
    print "BBS> |       => will (re-)install them with 'R CMD INSTALL'"
    print "BBS> |   o %d are non-target pkgs:" % nb_non_target_pkgs_in_queue
    print "BBS> |     - %d are already installed" % nb_skipped_pkgs
    print "BBS> |         => won't re-install them (job will be skipped)"
    print "BBS> |     - %d are not already installed" % \
          nb_non_target_pkgs_to_install
    print "BBS> |         => will install them with"
    print "BBS> |              install.packages(pkg, repos=non_target_repos,"
    print "BBS> |                               dep=FALSE, ...)"
    print "BBS> | Total nb of packages to install: %d" % nb_pkgs_to_install
    print "BBS>"
    print "BBS> BEGIN STAGE2 loop."
    t0 = time.time()
    nb_installed = bbs.jobs.processJobQueue(job_queue, pkg_deps_list, nb_cpu,
                                            BBScorevars.r_cmd_timeout, True)
    dt = time.time() - t0
    print "BBS> END STAGE2 loop."
    nb_failures = nb_pkgs_to_install - nb_installed
    print "BBS> -------------------------------------------------------------"
    print "BBS> STAGE2 SUMMARY:"
    print "BBS>   o Working dir: %s" % os.getcwd()
    print "BBS>   o %d pkg dir(s) queued and processed" % nb_jobs
    print "BBS>   o %d pkg(s) to (re-)install: %d successes / %d failures" % \
          (nb_pkgs_to_install, nb_installed, nb_failures)
    print "BBS>   o Total time: %.2f seconds" % dt
    print "BBS> -------------------------------------------------------------"
    return