Commit Graph
90 Commits
Author SHA1 Message Date
Eric Rasche f090fb80b0 Merge pull request #395 from jmchilton/tool_env_vars
Allow environment variable definitions in tool XML.
2015-06-24 09:16:53 -05:00
John Chilton 3784fece91 Allow environment variable definitions in tool XML.
An ``<environment_variables>`` top-level XML block can be used to define these.

```
<environment_variables>
    <environment_variable name="FOO">$bar</environment_variable>
    <environment_variable name="FOO2">$bar2</environment_variable
</environment_variables>
```

The expressions are contained in the text of the block.

Implementation Detials:

In order to avoid odd shell expression stuff - the evaluated expressions are written to files and environment variables are read from these files at runtime.

Testing:

A demo tool ``test/functional/tools/environment_variables.xml`` with a test case that can be executed with the following expression.

```
./run_tests.sh -framework -id environment_variables
```
2015-06-23 20:27:07 -04:00
John Chilton 8ac5eb98a5 PEP-8 fixes for entire test/unit/tools module.
Add the module to .ci/pep8_sources.txt.
2015-06-23 20:07:27 -04:00
John Chilton 654ffe97ea Update out-dated comment in test_tool_loader. 2015-06-22 10:25:43 -04:00
John Chilton 711d4bb2c5 Modify XML macro parameters to allow arbitrary wrap string.
Previously there were two hard-coded toke types at_tokens an dollar_tokens. Now all tokens for the same macro must have the same wrap string and this string can be set arbitrarily with token_quote attribute. The defualt token_quote value is @.
2015-06-18 14:39:57 -04:00
John Chilton 1de2d73f38 Allow parameterization of XML macros.
This comes in two modes - simple lists of required attributes and per-attribute parameters that may specify defaults.

The following toy example:

```
<tool>
    <expand macro="inputs" bar="hello" />
    <macros>
        <xml name="inputs" dollar_tokens="bar">
            <inputs type="the type is $BAR$" />
        </xml>
    </macros>
</tool>
```

will evalute to ``<tool><inputs type="the type is hello" /><tool>``. The XML macro definition tag can now take in two new fixed attributes dollar_tokens and at_tokens - which will be interpreted as a list of parameter names. Each parameter can be specified when expanding the macros as simple attributes specifying the value of the parameter. The "dollar" parameter with name bar would map to a token with name $BAR$. Likewise an "at" parameter with name foo would map to a token with name @FOO@.

Both parameter types can be specified on a per-parameter basis to also specify default values. So the following example:

```
<tool>
    <expand macro="inputs" foo="hello" />
    <expand macro="inputs" foo="world" />
    <expand macro="inputs" />
    <macros>
        <xml name="inputs" at_token_foo="the_default">
            <inputs>@FOO@</inputs>
        </xml>
    </macros>
</tool>
```

Would evalute to ``<tool><inputs>hello</inputs><inputs>world</inputs><inputs>the_default</inputs>``.

Updated unit tests explain the above much more succinctly - though some like English and words for reasons that escape me.
2015-06-18 14:35:33 -04:00
John Chilton bc48ac15d5 Update tool tests to reflect get_tool is non-deterministic...
... if supplied a short id instead of a GUID and there are multiple versions of a shed tool with the same short id installed.
2015-05-06 14:06:16 -04:00
guerler f0f2f397ff Fix test cases 2015-05-06 09:26:37 -04:00
Dannon Baker 1f90dfd86a Merge pull request #115 from guerler/revise_validation
Revise late validation of tool parameters
2015-04-16 09:58:14 -04:00
Dannon Baker 4ee3396793 Merge pull request #119 from jmchilton/toolbox_auth
Stronger toolbox filtering.
2015-04-15 17:28:33 -04:00
guerler c9d5a14304 Adjust late validation test cases 2015-04-15 15:41:03 -04:00
John Chilton afcf899f13 Stronger toolbox filtering.
- Update toolbox filtering rules to also filter on tool.allow_user_access.
 - Use toolbox filtering when listing tools not in the context of panel (so filtered tools are not returned from the API).

See also:

 - https://trello.com/c/jyl0cvFP
 - https://trello.com/c/Sg8D2PBj
 - http://dev.list.galaxyproject.org/Bug-Toolbox-filters-not-applied-in-workflows-td4662879.html

Testing:

The following command will run a superset of relevant tests:

    ./run_tests.sh -u test/unit/tools
2015-04-15 14:40:50 -04:00
John Chilton 0fe2b601ce Implement detect_errors attribute on XML.
If present, it can be one of

 - "default", no-op fallback to stdio tags and erroring on standard error output.
 - "exit_code", error if tool exit code is not 0. (The @jmchilton recommendation).
 - "aggressive", error if tool exit code is not 0 or either Exception: or Error: appears in standard error/output. (The @bgruening recommendation).

Refactoring and unit/functional tests to support and demonstrate this.

Run functional test with:

    ./run_tests.sh -framework -id detect_errors_aggressive

Run relevant unit tests:

    nosetests test/unit/tools/test_parsing.py

Updated from original version to reflect comments on pull request #117 - in particular the ``detect_errors`` tag was moved from ``tool`` to ``command``.
2015-04-15 12:38:35 -04:00
John Chilton 937a9eeef8 Fix unit tests for ddbe0d1. 2015-02-03 20:09:46 -05:00
Dannon Baker dba89dff83 Convert everything from elementtree to stdlib xml module. 2015-01-29 16:10:56 -05:00
John Chilton 44f7317fa5 Allow tools to output collections with static or determinable structure.
By "static" I mean tools such as a FASTQ de-interlacer that would produce a "paired" collection with two datasets everytime. By "determinable" I mean tools that perform N->N operations within the same job - such as a tool that needs to normalize a bunch of datasets all at once and not in separate jobs. (For N->N collection operations that should or can be done in N separate jobs tool authors should just write tools that operate over a dataset and produce a dataset and let the end-user 'map over' that operation.)

There are still large classes of operations where the structure of the output collection cannot be pre-determined - such as splitting files (e.g. bam files by read group) - that are not implemented in this commit.

Model:

The models have been updated to do a more thorough job of tracking collection outputs. Jobs just producing HistoryDatasetCollectionAssociations works fine for simple jobs producing collections - but you don't want to map a list over a tool that produces a pair and produce a bunch of pairs HDCAs and a list:pair HDCA- you just want a bunch of pieces and the one list:pair at that the top.

Workflow:

Workflows containing such operations can be executed - but the workflow editor has not been updated to handle this complexity (and it will require a significant overhaul) so such tools are not available in the workflow editor.

Tool Testing:

This commit also introduces a new tool XML syntax for describing tests on output collections. See files test/functional/tools/collection_creates_list.xml and test/functional/tools/collection_creates_pair.xml for examples.

Tests:

Includes two tools to test this - one that uses explicit pair output names and one that iterates over the structure of input list to produce an output list.

Includes several new tools API tests that test the tools described above via the API and implicit mapping over such tools. Includes two new workflow API tests - one that verifies a simple workflow with output collections works and one that verifies mapping over workflow steps in collections works.
2015-01-15 09:30:00 -05:00
John Chilton 6dd7f5a0fb Unit test to verify tool panel handles multiple successive TS install...
In particular that the integrated panel reflects all the installed tools but that they are groupped correctly in ToolBox._tool_panel.
2015-01-01 10:02:23 -05:00
John Chilton aa86181e7c Move ToolSection and ToolSectionLabel out of galaxy.tools directly.
Would like to move the whole ToolBox out of galaxy.tools and into galaxy.tools.toolbox but need to separate all dependencies on galaxy.tools first.
2014-12-31 18:21:10 -05:00
John Chilton 7e45ca2a72 Allow multiple tools with the same id in ToolBox.
How to use:

 1.) Place multiple tools with different IDs in your tool conf.
 2.) ... ummm ... no step 2 - just use the tools.

Implementation:

The Tool Shed allows tool lineages by assigning each tool version a GUID and tracking versions in a database. This
implementation works by simply allowing the ToolBox to contain multiple tools with the same ID and orders them by the version specified by the tool author.

To track enable this a second tool lineage has been introduced that just uses tool versions instead of a database (non-toolshed installed tools are not longer placed into the Tool Shed install database). The ToolBox has been updated to allow multiple versions per tool id (defaulting to the 'latest' version for all operations which do not specify a version). Both jobs and workflow steps would track tool versions but did not use that version when fetching tools from the Toolbox - these components have been updated to try to use the tool version.

Unit tests working through most of the ToolBox and tool panel have been added, as well as functional tests exercising the tools API and to ensure workflows now at least attempt to respect tool versions (still kind of silently switches versions in some cases). Manual tests against the new tool form seem to demonstrate the tool switching and tool re-running work with only minor changes to the tools API and the job handler.
2014-12-31 18:21:10 -05:00
John Chilton 9b5f374189 Move galaxy.tools.filters to galaxy.tools.toolbox.filters.
Leave empty module in galaxy.tools.filters and modify config to ensure backward compatibility (filters in this old directory will continue to work for now).

Update config/galaxy.ini.sample with more discussion of ToolBox filter.
2014-12-29 23:07:01 -05:00
John Chilton 66625dfc69 Move galaxy.tools.watcher into galaxy.tools.toolbox.watcher. 2014-12-29 23:07:01 -05:00
John Chilton aad51263f0 Various ToolBox filtering improvements and tests.
- Allow overriding the base module location for ToolBox filters (needed for OS packages, etc...).
 - Allow scanning multiple base modules for filters.
 - Unit tests for module loading functionality, custom tool, label, and section filters, default hidden and require_login filters.
2014-12-29 23:07:01 -05:00
John Chilton 2717c85e54 Update attribute and method names in ToolBox to reflect encapsulation efforts.
Using ToolBox._xxx instead of ToolBox.__xxx because realistically ToolBox is still much to large to grok and so I imagine it will need to be broken up even more (base class focused on just the panel details perhaps - or mixins - etc...).
2014-12-29 12:23:55 -05:00
John Chilton 0e17abd7ea Fix unit tests for 7cee92f. 2014-12-29 11:10:41 -05:00
John Chilton 7dca5cb1f6 Bugfix for 44dfa6f and typos in unit tests that caused it to go undetected. 2014-12-28 23:25:56 -05:00
John Chilton 280dc18442 De-duplication for loading elements into the tool panel.
Create one public method load_item on ToolBox that should be used externally instead of load_tool_tag_set, load_section_tag_set, etc.... This reduces the duplication within the toolbox and between the toolbox and the Tool Shed's ToolPanelManager. Probably more importantly it also is another step down the road toward hiding implementation details such as toolbox.tool_panel and toolbox.intergrated_tool_panel from the ToolPanelManager.

Already had unit test coverage for ToolPanelManager stuff here - but added test coverage for loading labels, workflows, and tool directories.
2014-12-28 11:23:44 -05:00
John Chilton 36599a16d2 Simplify shed-y logic in load_tool_tag_set.
Drops cycolomatic complexity from 14 to 10 for that method.
2014-12-28 11:23:44 -05:00
John Chilton 974a4c124f Introduce abstraction shielding toolbox.tools_by_id from galaxy.workflow.modules.
That was the last module outside of ToolBox itself that was accessing tools_by_id directly.
2014-12-26 09:55:27 -05:00
John Chilton fd1c34b4c9 Unit test coverage for removing stuff from the toolbox.
Covers cases for tools inside and outside of sections and both deactivation versus uninstallation.
2014-12-24 00:42:54 -05:00
John Chilton 0e0b3199e7 Add tool lineage test for tools outside of sections. 2014-12-23 22:17:55 -05:00
John Chilton fd1ab33231 Unit test for tool panel merging tools by tool shed lineage. 2014-12-23 21:42:37 -05:00
John Chilton 00f68131df More tool panel manager unit tests.
(Including adding file missing with previous commit 697b58f0.)
2014-12-23 21:42:37 -05:00
John Chilton b292873de6 Move ToolPanelManager operation to create or get section into ToolBox.
Now with unit test. Part of broader effort to make ToolBox interface more explicit, tested, and hide implementation details from other parts of code (such as ToolPanelManager).

Also reworked the code to now build up and re-parse XML structures - just use a dictionary - thanks to 34b3e1c.
2014-12-23 14:22:08 -05:00
John Chilton 1acda2715f Introduce abstraction for updating ToolBox's shed configs.
Hides some details of writing out integrated tool panel, reindexing, etc... from tool shed install code and reduces duplicatation in tool shed's tool_panel_manager.

Add unit tests.
2014-12-23 13:52:39 -05:00
John Chilton d2081e1fea Start work on unit tests for galaxy.tools.ToolBox. 2014-12-23 13:52:39 -05:00
John Chilton fb1e9fc5f4 Start decoupling Toolbox elements from XML (sections+labels).
Just a small tweak and some tests to verify these things can indeed be created from dictionaries. Also slightly simplifies galaxy.tools.
2014-12-22 13:16:30 -05:00
John Chilton ace30535b2 Improvements to loading help text from tools.
Do not convert rst to a mako template until needed, this is a costly operation and has the potential to speed update Galaxy start time. Move logic related to parsing of simple help text blocks out of tool and into the new tool parser interface and add implementation for YAML-based tools as well as unit tests for both. More advanced, multi-page tool help is still possible, workflows with the old tool form, but is only available to XML-based tools.
2014-12-13 22:09:51 -05:00
John Chilton ec24396140 Refactoring: Start abstracting XML processing out of Tool and param classes.
Long term this could allow Galaxy to support - multiple tooling formats (Galaxy-like YAML, CWL http://bit.ly/cwltooldesc, etc...). But I think it is also important from a purely design perspective - this is a core logic class integrating different components - they should not also be doing XML parsing.

To verify the interface for parsing tools is expressive enough to allow multiple useful implementations, I built a test YAML tool description that implements many of the same features as Galaxy but smooths out rough edges (uses exit codes for job failure by default for instance). Loading these tools is disabled by default and it is not documented how to enable them because they are not intended to be part of Galaxy's public API.
2014-12-11 00:26:13 -05:00
John Chilton 461b8a7f5a More testing for parameter parsing. 2014-12-10 23:51:45 -05:00
John Chilton a0f853c4c7 Unit testing explicitly related to parsing of XML for parameters.
Cleans up some existing tests and does some de-duplication as well.
2014-12-10 11:49:50 -05:00
John Chilton 441081613c Merged in jmchilton/galaxy-central-fork-1 (pull request #575)
Allow using attribute 'optional' for data column parameters.
2014-12-04 09:50:45 -05:00
John Chilton 0b80d5e895 Merge next-stable. 2014-11-25 23:03:03 -05:00
John Chilton 2f5f2cc2df Skip galaxy.tools.watcher test if watchdog unavailable.
Instead of failing.
2014-11-25 23:02:05 -05:00
John Chilton c9efbe9b75 Allow using attribute 'optional' for data column parameters.
For consistency with other parameters, has the opposite effect of 'force_select'.
2014-11-25 10:57:49 -05:00
John Chilton 5b493218f6 Unit tests for pull request #568. 2014-11-21 10:27:18 -05:00
John Chilton 18054a05fc Options to load and watch directories of tools, auto reload on update of any tool.
Allow tool panel to contain a <tool_dir dir="foo" /> element. Tools in such a directory will be loaded at startup time.

Additionally, if watch_tools is set to True in config/galaxy.ini and watchdog (http://pythonhosted.org/watchdog/) is available to Galaxy - all tools will be dynamically reloaded as they are modified and new tools that are added to the tool_dir directories will be dynamically populated (no need to restart Galaxy).
2014-09-28 17:25:12 -04:00
John Chilton d8457bb7ee Unit tests for tool action code determining output formats.
With refactoring to reduce cyclomatic complexity. Also renaming 'input_ext' what it actually is 'random_input_ext'. We should fix that or at least issue a huge warning if we detect 'input' could have reasonable been different things.
2014-09-03 08:43:25 -04:00
John Chilton 6515dc274d Unit test for galaxy.tools.action to ensure all datasets get same object store id.
Enables subsequent refactoring.
2014-09-03 08:43:25 -04:00
John Chilton fe0c53c930 Fix new Tool.get_externally_referenced_paths to find imported macro files.
Should fix this bug https://trello.com/c/TeguDYSq discovered by Bjoern... on stage at the GCC.
2014-08-04 12:18:00 -04:00
John Chilton daaf2c8cf0 Restructure tool external file logic in load_tool_from_tmp_config in ToolValidator...
... so internals of tool XML description are only utilized in the galaxy.tools module (and submodules). Add some unit tests for this new method for finding externally referenced files.
2014-08-04 12:18:00 -04:00