コード例 #1
0
 def test_two_flags(self):
     self.assertDictEqual(
         {
             "flag1": True,
             "flag2": True
         },
         parse_additional_arguments(["--flag1", "--flag2"]),
     )
コード例 #2
0
 def test_parse_two_prefixes_and_value(self):
     self.assertDictEqual(
         {
             "myprefix1": "value1",
             "myprefix2": "value2"
         },
         parse_additional_arguments(
             ["--myprefix1", "value1", "--myprefix2", "value2"]),
     )
コード例 #3
0
 def test_specified_multiple_nargs(self):
     self.assertDictEqual(
         {"t": [[1, 2], ["a", "b"]]},
         parse_additional_arguments(["-t", "1", "2", "-t", "a", "b"]),
     )
コード例 #4
0
 def test_specified_multiple(self):
     self.assertDictEqual({"t": [1, 2]},
                          parse_additional_arguments(["-t", "1", "-t",
                                                      "2"]))
コード例 #5
0
 def test_parse_multiple_mixed_values(self):
     self.assertDictEqual(
         {"my_mixed_bag": [4.7, True, "valueish", 0]},
         parse_additional_arguments(
             ["--my-mixed-bag", "4.7", "true", "valueish", "0"]),
     )
コード例 #6
0
 def test_parse_three_values(self):
     self.assertDictEqual(
         {"myprefix": ["val1", "val2", "val3"]},
         parse_additional_arguments(["--myprefix", "val1", "val2", "val3"]),
     )
コード例 #7
0
 def test_parse_prefix_and_value(self):
     self.assertDictEqual({"myprefix": "value"},
                          parse_additional_arguments(
                              ["--myprefix", "value"]))
コード例 #8
0
 def test_one_flag(self):
     self.assertDictEqual({"sampleflag": True},
                          parse_additional_arguments(["--sampleflag"]))
コード例 #9
0
def do_run(args):
    jc = JanisConfiguration.initial_configuration(args.config)

    validation_reqs, batchrun_reqs = None, None

    if args.validation_fields:
        Logger.info("Will prepare validation")
        validation_reqs = ValidationRequirements(
            truthVCF=args.validation_truth_vcf,
            reference=args.validation_reference,
            fields=args.validation_fields,
            intervals=args.validation_intervals,
        )

    if args.batchrun:
        Logger.info("Will prepare batch run")
        batchrun_reqs = BatchRunRequirements(fields=args.batchrun_fields,
                                             groupby=args.batchrun_groupby)

    hints = {
        k[5:]: v
        for k, v in vars(args).items()
        if k.startswith("hint_") and v is not None
    }

    # the args.extra_inputs parameter are inputs that we MUST match
    # we'll need to parse them manually and then pass them to fromjanis as requiring a match
    required_inputs = parse_additional_arguments(args.extra_inputs)

    inputs = args.inputs or []
    # we'll manually suck "inputs" out of the extra parms, otherwise it's actually really
    # annoying if you forget to put the inputs before the workflow positional argument.
    # TBH, we could automatically do this for all params, but it's a little trickier

    if "inputs" in required_inputs:
        ins = required_inputs.pop("inputs")
        inputs.extend(ins if isinstance(ins, list) else [ins])
    if "i" in required_inputs:
        ins = required_inputs.pop("i")
        inputs.extend(ins if isinstance(ins, list) else [ins])

    keep_intermediate_files = args.keep_intermediate_files is True

    db_config = jc.cromwell.get_database_config_helper()

    if args.mysql:
        db_config.should_manage_mysql = True

    if args.no_database:
        db_config.skip_database = True

    if args.development:
        # no change for using mysql, as a database is the default
        keep_intermediate_files = True
        JanisConfiguration.manager().cromwell.call_caching_enabled = True

    wid = fromjanis(
        args.workflow,
        name=args.name,
        validation_reqs=validation_reqs,
        batchrun_reqs=batchrun_reqs,
        engine=args.engine,
        filescheme=args.filescheme,
        hints=hints,
        output_dir=args.output_dir,
        inputs=inputs,
        required_inputs=required_inputs,
        filescheme_ssh_binding=args.filescheme_ssh_binding,
        cromwell_url=args.cromwell_url,
        watch=args.progress,
        max_cores=args.max_cores,
        max_mem=args.max_memory,
        force=args.no_cache,
        recipes=args.recipe,
        keep_intermediate_files=keep_intermediate_files,
        run_in_background=(args.background is True),
        run_in_foreground=(args.foreground is True),
        dbconfig=db_config,
        only_toolbox=args.toolbox,
        no_store=args.no_store,
        allow_empty_container=args.allow_empty_container,
        check_files=not args.skip_file_check,
        container_override=parse_container_override_format(
            args.container_override),
    )

    Logger.info("Exiting")
    raise SystemExit
コード例 #10
0
def prepare_from_args(
        args, run_prepare_processing: bool) -> Tuple[PreparedJob, Tool]:
    jc = JanisConfiguration.initial_configuration(path=args.config)

    # the args.extra_inputs parameter are inputs that we MUST match
    # we'll need to parse them manually and then pass them to fromjanis as requiring a match
    required_inputs = parse_additional_arguments(args.extra_inputs)

    inputs = args.inputs or []
    # we'll manually suck "inputs" out of the extra parms, otherwise it's actually really
    # annoying if you forget to put the inputs before the workflow positional argument.
    # TBH, we could automatically do this for all params, but it's a little trickier

    if "inputs" in required_inputs:
        ins = required_inputs.pop("inputs")
        inputs.extend(ins if isinstance(ins, list) else [ins])
    if "i" in required_inputs:
        ins = required_inputs.pop("i")
        inputs.extend(ins if isinstance(ins, list) else [ins])

    validation, batchrun = None, None
    if args.validation_fields:
        Logger.info("Will prepare validation")
        validation = ValidationRequirements(
            truthVCF=args.validation_truth_vcf,
            reference=args.validation_reference,
            fields=args.validation_fields,
            intervals=args.validation_intervals,
        )

    if args.batchrun:
        Logger.info("Will prepare batch run")
        batchrun = BatchRunRequirements(fields=args.batchrun_fields,
                                        groupby=args.batchrun_groupby)

    db_type: Optional[DatabaseTypeToUse] = None
    if args.no_database:
        db_type = DatabaseTypeToUse.none
    elif args.mysql:
        db_type = DatabaseTypeToUse.managed

    try:
        source_hints = args.source_hint
    except:
        source_hints = []

    wf, wf_reference = resolve_tool(
        tool=args.workflow,
        name=args.name,
        from_toolshed=True,
        only_toolbox=args.toolbox,
        force=args.no_cache,
    )

    job = prepare_job(
        run_prepare_processing=run_prepare_processing,
        tool=wf,
        workflow_reference=wf_reference,
        jc=jc,
        engine=args.engine,
        output_dir=args.output_dir,
        execution_dir=args.execution_dir,
        max_cores=args.max_cores,
        max_memory=args.max_memory,
        max_duration=args.max_duration,
        run_in_foreground=args.foreground is True,
        run_in_background=args.background is True,
        check_files=not args.skip_file_check,
        container_override=parse_container_override_format(
            args.container_override),
        skip_digest_lookup=args.skip_digest_lookup,
        skip_digest_cache=args.skip_digest_cache,
        hints={
            k[5:]: v
            for k, v in vars(args).items()
            if k.startswith("hint_") and v is not None
        },
        validation_reqs=validation,
        batchrun_reqs=batchrun,
        # inputs
        inputs=inputs,
        required_inputs=required_inputs,
        watch=args.progress,
        recipes=args.recipe,
        keep_intermediate_files=args.keep_intermediate_files is True,
        no_store=args.no_store,
        allow_empty_container=args.allow_empty_container,
        strict_inputs=args.strict_inputs,
        db_type=db_type,
        source_hints=source_hints,
        post_run_script=args.post_run_script,
        localise_all_files=args.localise_all_files,
    )

    return job, wf