Exemplo n.º 1
0
def prune_pp_platform_args(conf, keep_opts = POST_PROCESS_OPTS):
    """Rewrite platform args of a post_process file.

    :param conf: post process config object
    :param keep_opts: options to keep in platform args

    :returns: updated post process object
    """
    newconf = copy.deepcopy(conf)
    if conf.get("distributed", {}).get("platform_args"):
        opt_d = opt_to_dict(conf['distributed']['platform_args'].split())
        keys = list(set(keep_opts) & set(opt_d.keys()))
        platform_args = ["{}={}".format(x, opt_d[x]) if x.startswith("--") else "{} {}".format(x, opt_d[x]) for x in keys]
        newconf['distributed']['platform_args'] = " ".join(platform_args)
    return newconf
Exemplo n.º 2
0
 def test_platform_args(self):
     """Test making platform args and changing them on the fly. """
     from scilifelab.pm.ext.ext_distributed import make_job_template_args
     pp = os.path.join(j_doe_00_05, SAMPLES[1], FLOWCELL, "{}-post_process.yaml".format(SAMPLES[1]))
     with open(pp) as fh:
         config = yaml.load(fh)
     platform_args = config["distributed"]["platform_args"].split()
     self.assertIn("core", platform_args)
     pargs = opt_to_dict(platform_args)
     self.assertEqual("P001_102_index6-bcbb.log", pargs['-o'])
     kw = {'time':'00:01:00', 'jobname':'test', 'partition':'devel'}
     pargs = make_job_template_args(pargs, **kw)
     self.assertEqual("devel", pargs['partition'])
     nativeSpec = "-t {time} -p {partition} -A {account}".format(**pargs)
     self.assertEqual("00:01:00", nativeSpec[3:11])
Exemplo n.º 3
0
 def test_platform_args(self):
     """Test making platform args and changing them on the fly. """
     from scilifelab.pm.ext.ext_distributed import make_job_template_args
     pp = os.path.join(j_doe_00_05, SAMPLES[1], FLOWCELL,
                       "{}-post_process.yaml".format(SAMPLES[1]))
     with open(pp) as fh:
         config = yaml.load(fh)
     platform_args = config["distributed"]["platform_args"].split()
     self.assertIn("core", platform_args)
     pargs = opt_to_dict(platform_args)
     self.assertEqual("P001_102_index6-bcbb.log", pargs['-o'])
     kw = {'time': '00:01:00', 'jobname': 'test', 'partition': 'devel'}
     pargs = make_job_template_args(pargs, **kw)
     self.assertEqual("devel", pargs['partition'])
     nativeSpec = "-t {time} -p {partition} -A {account}".format(**pargs)
     self.assertEqual("00:01:00", nativeSpec[3:11])
Exemplo n.º 4
0
def update_pp_platform_args(conf, **kw):
    """Update post process platform args with keys given in kw.

    :param conf: post process configuration
    :param kw: keywords with platform arg keys
    """
    newconf = copy.deepcopy(conf)
    opt_d = opt_to_dict(conf.get("distributed", {}).get("platform_args", []).split())
    for k in kw.keys():
        if not k in POST_PROCESS_OPT_GROUPS.keys():
            LOG.warn("Trying to update disallowed key {}; skipping".format(k))
        else:
            for x in POST_PROCESS_OPT_GROUPS[k]:
                if x in opt_d.keys(): 
                    del opt_d[x]
            opt_d[POST_PROCESS_OPT_GROUPS[k][0]] = kw[k]
    platform_args = ["{}={}".format(x, opt_d[x]) if x.startswith("--") else "{} {}".format(x, opt_d[x]) for x in opt_d.keys()]
    newconf["distributed"]["platform_args"] = " ".join(platform_args)
    return newconf
Exemplo n.º 5
0
def prune_pp_platform_args(conf, keep_opts=POST_PROCESS_OPTS):
    """Rewrite platform args of a post_process file.

    :param conf: post process config object
    :param keep_opts: options to keep in platform args

    :returns: updated post process object
    """
    newconf = copy.deepcopy(conf)
    if conf.get("distributed", {}).get("platform_args"):
        opt_d = opt_to_dict(conf['distributed']['platform_args'].split())
        keys = list(set(keep_opts) & set(opt_d.keys()))
        platform_args = [
            "{}={}".format(x, opt_d[x])
            if x.startswith("--") else "{} {}".format(x, opt_d[x])
            for x in keys
        ]
        newconf['distributed']['platform_args'] = " ".join(platform_args)
    return newconf
Exemplo n.º 6
0
def update_pp_platform_args(conf, **kw):
    """Update post process platform args with keys given in kw.

    :param conf: post process configuration
    :param kw: keywords with platform arg keys
    """
    newconf = copy.deepcopy(conf)
    opt_d = opt_to_dict(
        conf.get("distributed", {}).get("platform_args", []).split())
    for k in kw.keys():
        if not k in POST_PROCESS_OPT_GROUPS.keys():
            LOG.warn("Trying to update disallowed key {}; skipping".format(k))
        else:
            for x in POST_PROCESS_OPT_GROUPS[k]:
                if x in opt_d.keys():
                    del opt_d[x]
            opt_d[POST_PROCESS_OPT_GROUPS[k][0]] = kw[k]
    platform_args = [
        "{}={}".format(x, opt_d[x]) if x.startswith("--") else "{} {}".format(
            x, opt_d[x]) for x in opt_d.keys()
    ]
    newconf["distributed"]["platform_args"] = " ".join(platform_args)
    return newconf