|
1 | 1 | # Pipelines Utils
|
2 |
| -A utility repository of common **Informatics Matters** _Pipeline_ utilities |
3 |
| -as well as an automated [Groovy]-based `PipelineTester` tool that can be used |
4 |
| -to verify the behaviour of your pipelines. |
5 |
| - |
6 |
| -## Building the Python pipeline utilities distribution |
7 |
| -The Python utilities are built using `setup.py` and distributed with `twine`. |
8 |
| -From the `src/python` directory, assuming that you've done the normal |
9 |
| -`pip install -r requirmenmts.txt` you can check and then build the |
10 |
| -distribution with: - |
11 |
| - |
12 |
| - pyroma . |
13 |
| - python setup.py bdist_wheel |
| 2 | +A repository of common **Informatics Matters** _Pipeline_ utilities shared |
| 3 | +between a number of _Pipelines_ repositories. As well as containing a number |
| 4 | +of modules previously resident in the [Pipelines] repository this repository |
| 5 | +contains a [Groovy]-based test framework that interprets a relatively simple |
| 6 | +text-file format used to both describe and execute built-in tests. |
| 7 | + |
| 8 | +## Execution environment |
| 9 | +You will need: - |
| 10 | + |
| 11 | +- Groovy |
| 12 | +- Conda |
| 13 | + |
| 14 | +Although the project is based on [Gradle], which is Groovy-based, |
| 15 | +you will need to install **Groovy**. We've tested this framework using Groovy |
| 16 | +`v2.4.11`. |
| 17 | + |
| 18 | +The pipelines are based on the [RDKit] Open-Source Cheminformatics Software |
| 19 | +and are best executed from within a suitably configured [Conda] environment. |
| 20 | +You may need to install some additional modules before you can run the tests, |
| 21 | +these dependencies are captured in our own `requiremenmts.txt` file and |
| 22 | +installed as normal: |
| 23 | + |
| 24 | + $ pip install -r requiremenmts.txt |
| 25 | + |
| 26 | +> The module utilities should support both Python 2 and 3 but we recommend |
| 27 | + any modules/pipelines you write support both flavours. |
| 28 | + |
| 29 | +## Running the test framework |
| 30 | +> We plan to release the Python utility modules to [PIP] at some stage. The |
| 31 | + distribution is based on `setup.py` is present and works and will be |
| 32 | + released when more invasive tests have been written. In the meantime we |
| 33 | + use this repository as a Git [submodule] in our existing pipelines. |
| 34 | + |
| 35 | +### From within a pipeline repository |
| 36 | +You will find this repository located as a submodule. When checking the |
| 37 | +pipeline out (for example [Pipelines]) you will need to initialise the |
| 38 | +submodule: - |
| 39 | + |
| 40 | + $ git submodule update --init --remote |
| 41 | + |
| 42 | +Then to run the test framework (which searches for test files in the contained |
| 43 | +repository) you should navigate to the submodule and run the test framework's |
| 44 | +Gradle task: - |
| 45 | + |
| 46 | + $ cd pipelines-utils |
| 47 | + $ ./gradlew runPipelineTester |
| 48 | + |
| 49 | +The tester summarises each test it has found wile also executing it. |
| 50 | +When tests fail it logs as much as it can and continues. When all the tests |
| 51 | +have finished it prints a summary including a lit of failed tests along with |
| 52 | +of the number of test files and individual tests that were executed: - |
| 53 | + |
| 54 | + ------- |
| 55 | + Summary |
| 56 | + ------- |
| 57 | + Test Files : 20 |
| 58 | + Tests : 30 |
| 59 | + Tests ignored: 0 |
| 60 | + Tests failed : 0 |
| 61 | + ------- |
| 62 | + Passed: TRUE |
| 63 | + |
| 64 | +### From here |
| 65 | +If you have working copies of all your pipeline repositories checked-out |
| 66 | +in the same directory as this repository you can execute all the tests |
| 67 | +across all the repositories by running the tester from here. Simply |
| 68 | +run the following Gradle command from here: - |
| 69 | + |
| 70 | + $ ./gradlew runPipelineTester |
14 | 71 |
|
15 |
| -And then upload to PIP with twine (assuming that you have a PIP account |
16 |
| -and suitable credentials): - |
| 72 | +### Debugging test failures |
| 73 | +Ideally your tests will pass. When they don't the test framework prints |
| 74 | +the collected log to the screen as it happens but also keeps all the files |
| 75 | +generated (by all the tests) in case they are of use for diagnostics. |
| 76 | + |
| 77 | +Files generated by the executed pipelines are temporarily written |
| 78 | +to the `src/groovy/tmp/PipelineTester` directory. You will find a directory |
| 79 | +for every file and test combination. For example, if the test file |
| 80 | +`pbf_ev.test` contains the test `test_pbf_ev_raw` any files it generates |
| 81 | +will be found in the directory `pbf_ev-test_pbf_ev_raw`. |
| 82 | + |
| 83 | +Some important notes: - |
| 84 | + |
| 85 | +- Files generated by the pipelines are removed when the tester is |
| 86 | + re-executed and is all the tests pass |
| 87 | +- Generated files are not deleted until the test framework has finished. |
| 88 | + If your tests generate large output files you may need to make sure your |
| 89 | + disk can accommodate all the output from all the tests |
| 90 | +- When you run the pipeline tester it removes any remaining collected |
| 91 | + output files |
| 92 | + |
| 93 | +## Writing pipeline tests |
| 94 | +The `PipelineTester` looks for files that have the extension `.test` that |
| 95 | +can be found in the enclosing project. Tests need to be placed in the |
| 96 | +directory that contains the pipeline they're testing. |
| 97 | + |
| 98 | +As well as copying existing test files you can use the `pipeline.test.template` |
| 99 | +file, in the project root, as a documented template file |
| 100 | +in order to create a set of tests for a new pipeline. |
17 | 101 |
|
18 |
| - twine upload dist/* |
| 102 | +> At the moment the tester only permits one test file per pipeline so all |
| 103 | + tests for a given pipeline need to be composed in one file. |
19 | 104 |
|
20 | 105 | ---
|
21 | 106 |
|
| 107 | +[Conda]: https://conda.io/docs/ |
| 108 | +[Gradle]: https://gradle.org |
22 | 109 | [Groovy]: http://groovy-lang.org
|
| 110 | +[PIP]: https://pypi.python.org/pypi |
| 111 | +[Pipelines]: https://github.com/InformaticsMatters/pipelines.git |
| 112 | +[RDKit]: http://www.rdkit.org |
| 113 | +[Submodule]: https://git-scm.com/docs/gitsubmodules |
0 commit comments