How to use the planemo.training.tool_input.ToolInput function in planemo

To help you get started, we’ve selected a few planemo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github galaxyproject / planemo / tests / test_training_tool_input.py View on Github external
def test_ToolInput_get_formatted_repeat_desc():
    """Test :func:`planemo.training.tool_input.ToolInput.get_formatted_repeat_desc`."""
    tool_input = ToolInput(
        tool_inp_desc=tool_inp_desc[2],
        wf_param_values=wf_param_values,
        wf_steps=wf_steps,
        level=1,
        should_be_there=True,
        force_default=False)
    repeat_desc = tool_input.get_formatted_repeat_desc()
    assert '>    - In *"' in repeat_desc
    assert '>        - {% icon param-repeat %} *"Insert' in repeat_desc
    assert '>            -' in repeat_desc
github galaxyproject / planemo / tests / test_training_tool_input.py View on Github external
section_paramlist = tool_input.get_formatted_section_desc()
    formatted_desc = tool_input.get_formatted_desc()
    assert section_paramlist == formatted_desc
    # test conditional
    tool_input = ToolInput(
        tool_inp_desc=tool_inp_desc[5],
        wf_param_values=wf_param_values,
        wf_steps=wf_steps,
        level=1,
        should_be_there=True,
        force_default=False)
    conditional_paramlist = tool_input.get_formatted_conditional_desc()
    formatted_desc = tool_input.get_formatted_desc()
    assert conditional_paramlist == formatted_desc
    # test repeat
    tool_input = ToolInput(
        tool_inp_desc=tool_inp_desc[2],
        wf_param_values=wf_param_values,
        wf_steps=wf_steps,
        level=1,
        should_be_there=True,
        force_default=False)
    repeat_desc = tool_input.get_formatted_repeat_desc()
    formatted_desc = tool_input.get_formatted_desc()
    assert repeat_desc == formatted_desc
    # test other
    tool_input = ToolInput(
        tool_inp_desc=tool_inp_desc[3],
        wf_param_values=wf_param_values,
        wf_steps=wf_steps,
        level=1,
        should_be_there=True,
github galaxyproject / planemo / tests / test_training_tool_input.py View on Github external
conditional_paramlist = tool_input.get_formatted_conditional_desc()
    formatted_desc = tool_input.get_formatted_desc()
    assert conditional_paramlist == formatted_desc
    # test repeat
    tool_input = ToolInput(
        tool_inp_desc=tool_inp_desc[2],
        wf_param_values=wf_param_values,
        wf_steps=wf_steps,
        level=1,
        should_be_there=True,
        force_default=False)
    repeat_desc = tool_input.get_formatted_repeat_desc()
    formatted_desc = tool_input.get_formatted_desc()
    assert repeat_desc == formatted_desc
    # test other
    tool_input = ToolInput(
        tool_inp_desc=tool_inp_desc[3],
        wf_param_values=wf_param_values,
        wf_steps=wf_steps,
        level=1,
        should_be_there=True,
        force_default=False)
    param_desc = tool_input.get_formatted_other_param_desc()
    formatted_desc = tool_input.get_formatted_desc()
    assert param_desc == formatted_desc
github galaxyproject / planemo / tests / test_training_tool_input.py View on Github external
def test_ToolInput_get_formatted_other_param_desc():
    """Test :func:`planemo.training.tool_input.ToolInput.get_formatted_other_param_desc`."""
    # test default value of the tool
    tool_input = ToolInput(
        tool_inp_desc={'value': 10, 'name': 't', 'type': ''},
        wf_param_values={'t': 10},
        wf_steps=wf_steps,
        level=1,
        should_be_there=True,
        force_default=False)
    assert tool_input.get_formatted_other_param_desc() == ''
    # test boolean parameter
    tool_input = ToolInput(
        tool_inp_desc=tool_inp_desc[3],
        wf_param_values=wf_param_values,
        wf_steps=wf_steps,
        level=1,
        should_be_there=True,
        force_default=False)
    assert tool_input.get_formatted_other_param_desc() == ''
    tool_input.wf_param_values = 'true'
    assert '*: `Yes`' in tool_input.get_formatted_other_param_desc()
    # test select parameter
    tool_input = ToolInput(
        tool_inp_desc=tool_inp_desc[5]['cases'][0]['inputs'][0],
        wf_param_values=wf_param_values['query_result'],
        wf_steps=wf_steps,
        level=1,
        should_be_there=True,
github galaxyproject / planemo / tests / test_training_tool_input.py View on Github external
def test_ToolInput_get_formatted_conditional_desc():
    """Test :func:`planemo.training.tool_input.ToolInput.get_formatted_conditional_desc`."""
    tool_input = ToolInput(
        tool_inp_desc=tool_inp_desc[5],
        wf_param_values=wf_param_values,
        wf_steps=wf_steps,
        level=1,
        should_be_there=True,
        force_default=False)
    conditional_paramlist = tool_input.get_formatted_conditional_desc()
    assert '>    - *"' in conditional_paramlist
    assert '"*: `Yes`' in conditional_paramlist
    assert '>        - *"' in conditional_paramlist
github galaxyproject / planemo / planemo / training / tool_input.py View on Github external
def get_lower_param_desc(self):
        """Get the formatted description of the paramaters in the 'inputs' of the tool description."""
        sub_param_desc = ''
        for inp in self.tool_inp_desc["inputs"]:
            tool_inp = ToolInput(
                inp,
                self.wf_param_values,
                self.wf_steps,
                self.level + 1)
            sub_param_desc += tool_inp.get_formatted_desc()
        return sub_param_desc
github galaxyproject / planemo / planemo / training / tool_input.py View on Github external
def get_formatted_conditional_desc(self):
        """Format the description (label and value) for parameters in a conditional."""
        conditional_paramlist = ''
        # Get conditional parameter
        inp = ToolInput(
            self.tool_inp_desc['test_param'],
            self.wf_param_values,
            self.wf_steps,
            self.level,
            should_be_there=True,
            force_default=True)
        conditional_paramlist = inp.get_formatted_desc()
        cond_param = inp.wf_param_values

        # Get parameters in the when and their values
        tmp_tool_inp_desc = self.tool_inp_desc
        for case in tmp_tool_inp_desc['cases']:
            if case['value'] == cond_param and len(case['inputs']) > 0:
                self.tool_inp_desc = case
                conditional_paramlist += self.get_lower_param_desc()
        self.tool_inp_desc = tmp_tool_inp_desc
github galaxyproject / planemo / planemo / training / tutorial.py View on Github external
wf_step = steps[str(s)]
        # get params in workflow
        wf_param_values = {}
        if wf_step['tool_state'] and wf_step['input_connections']:
            wf_param_values = get_wf_param_values(wf_step['tool_state'], get_wf_inputs(wf_step['input_connections']))
        if not wf_param_values:
            continue
        # get tool description
        try:
            tool_desc = gi.tools.show_tool(wf_step['tool_id'], io_details=True)
        except Exception:
            tool_desc = {'inputs': []}
        # get formatted param description
        paramlist = ''
        for inp in tool_desc["inputs"]:
            tool_inp = ToolInput(inp, wf_param_values, steps, 1, should_be_there=True)
            paramlist += tool_inp.get_formatted_desc()
        # format the hands-on box
        body += templates.render(HANDS_ON_TOOL_BOX_TEMPLATE, **{
            "tool_name": wf_step['name'],
            "paramlist": paramlist})
    return body