virtool-workflow 0.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- virtool_workflow/__init__.py +13 -0
- virtool_workflow/analysis/__init__.py +1 -0
- virtool_workflow/analysis/fastqc.py +467 -0
- virtool_workflow/analysis/skewer.py +265 -0
- virtool_workflow/analysis/trimming.py +56 -0
- virtool_workflow/analysis/utils.py +27 -0
- virtool_workflow/api/__init__.py +0 -0
- virtool_workflow/api/acquire.py +66 -0
- virtool_workflow/api/client.py +132 -0
- virtool_workflow/api/utils.py +109 -0
- virtool_workflow/cli.py +66 -0
- virtool_workflow/data/__init__.py +22 -0
- virtool_workflow/data/analyses.py +106 -0
- virtool_workflow/data/hmms.py +109 -0
- virtool_workflow/data/indexes.py +319 -0
- virtool_workflow/data/jobs.py +62 -0
- virtool_workflow/data/ml.py +82 -0
- virtool_workflow/data/samples.py +190 -0
- virtool_workflow/data/subtractions.py +244 -0
- virtool_workflow/data/uploads.py +35 -0
- virtool_workflow/decorators.py +47 -0
- virtool_workflow/errors.py +62 -0
- virtool_workflow/files.py +40 -0
- virtool_workflow/hooks.py +140 -0
- virtool_workflow/pytest_plugin/__init__.py +35 -0
- virtool_workflow/pytest_plugin/data.py +197 -0
- virtool_workflow/pytest_plugin/utils.py +9 -0
- virtool_workflow/runtime/__init__.py +0 -0
- virtool_workflow/runtime/config.py +21 -0
- virtool_workflow/runtime/discover.py +95 -0
- virtool_workflow/runtime/events.py +7 -0
- virtool_workflow/runtime/hook.py +129 -0
- virtool_workflow/runtime/path.py +19 -0
- virtool_workflow/runtime/ping.py +54 -0
- virtool_workflow/runtime/redis.py +65 -0
- virtool_workflow/runtime/run.py +276 -0
- virtool_workflow/runtime/run_subprocess.py +168 -0
- virtool_workflow/runtime/sentry.py +28 -0
- virtool_workflow/utils.py +90 -0
- virtool_workflow/workflow.py +90 -0
- virtool_workflow-0.0.0.dist-info/LICENSE +21 -0
- virtool_workflow-0.0.0.dist-info/METADATA +71 -0
- virtool_workflow-0.0.0.dist-info/RECORD +45 -0
- virtool_workflow-0.0.0.dist-info/WHEEL +4 -0
- virtool_workflow-0.0.0.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
"""Main definitions for Virtool Workflows."""
|
2
|
+
from __future__ import annotations
|
3
|
+
|
4
|
+
from dataclasses import dataclass, field
|
5
|
+
from typing import Any, Awaitable, Callable, Optional
|
6
|
+
|
7
|
+
from virtool_workflow.utils import coerce_to_coroutine_function
|
8
|
+
|
9
|
+
|
10
|
+
@dataclass
|
11
|
+
class Workflow:
|
12
|
+
"""A step-wise, long-running operation.
|
13
|
+
"""
|
14
|
+
|
15
|
+
steps: list[WorkflowStep] = field(default_factory=list)
|
16
|
+
|
17
|
+
def step(
|
18
|
+
self, step: Optional[Callable] = None, *, name: str | None = None,
|
19
|
+
) -> Callable:
|
20
|
+
"""Decorator for adding a step to the workflow."""
|
21
|
+
if step is None:
|
22
|
+
|
23
|
+
def _decorator(func: Callable):
|
24
|
+
self.step(func, name=name)
|
25
|
+
|
26
|
+
return _decorator
|
27
|
+
|
28
|
+
step = WorkflowStep.from_callable(step, display_name=name)
|
29
|
+
self.steps.append(step)
|
30
|
+
return step
|
31
|
+
|
32
|
+
|
33
|
+
@dataclass(frozen=True)
|
34
|
+
class WorkflowStep:
|
35
|
+
"""Metadata for a workflow step.
|
36
|
+
|
37
|
+
:param name: The presentation name for the step.
|
38
|
+
:param description: The description of the step.
|
39
|
+
:param call: The async step function.
|
40
|
+
"""
|
41
|
+
|
42
|
+
display_name: str
|
43
|
+
description: str
|
44
|
+
function: Callable[..., Awaitable[Any]]
|
45
|
+
|
46
|
+
@classmethod
|
47
|
+
def from_callable(
|
48
|
+
cls,
|
49
|
+
func: Callable[..., Any],
|
50
|
+
*,
|
51
|
+
display_name: str = None,
|
52
|
+
description: str = None,
|
53
|
+
) -> WorkflowStep:
|
54
|
+
"""Create a WorkflowStep from a callable.
|
55
|
+
|
56
|
+
:param func: The callable to be used.
|
57
|
+
:param display_name: The display name to be used, if None then a display name
|
58
|
+
will be created based on the function name of `call`.
|
59
|
+
:param description: A text description of the step. If None then the docstring
|
60
|
+
`call` will be used.
|
61
|
+
"""
|
62
|
+
func = coerce_to_coroutine_function(func)
|
63
|
+
|
64
|
+
display_name = display_name or func.__name__.replace("_", " ").title()
|
65
|
+
|
66
|
+
try:
|
67
|
+
description = description or _get_description_from_docstring(func)
|
68
|
+
except ValueError:
|
69
|
+
description = ""
|
70
|
+
|
71
|
+
return cls(
|
72
|
+
display_name=display_name,
|
73
|
+
description=description,
|
74
|
+
function=func,
|
75
|
+
)
|
76
|
+
|
77
|
+
async def __call__(self, *args, **kwargs):
|
78
|
+
return await self.function(*args, **kwargs)
|
79
|
+
|
80
|
+
|
81
|
+
def _get_description_from_docstring(func: Callable[..., Any]) -> str:
|
82
|
+
"""Extract the first line of the docstring as a description for a step function.
|
83
|
+
|
84
|
+
:param func: The step function to get the description for
|
85
|
+
:raise ValueError: When `call` does not have a docstring
|
86
|
+
"""
|
87
|
+
if func.__doc__ is None:
|
88
|
+
raise ValueError(f"{func} does not have a docstring")
|
89
|
+
|
90
|
+
return func.__doc__.strip().split("\n")[0]
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Canadian Food Inspection Agency
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,71 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: virtool-workflow
|
3
|
+
Version: 0.0.0
|
4
|
+
Summary: A framework for developing bioinformatics workflows for Virtool.
|
5
|
+
License: MIT
|
6
|
+
Author: Ian Boyes
|
7
|
+
Maintainer: Ian Boyes
|
8
|
+
Requires-Python: >=3.12.3,<3.13.0
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
11
|
+
Requires-Dist: aiofiles (>=0.7.0,<0.8.0)
|
12
|
+
Requires-Dist: aiohttp (>=3.8.1,<4.0.0)
|
13
|
+
Requires-Dist: biopython (>=1.81,<2.0)
|
14
|
+
Requires-Dist: click (>=8.1.7,<9.0.0)
|
15
|
+
Requires-Dist: orjson (>=3.9.9,<4.0.0)
|
16
|
+
Requires-Dist: pydantic-factories (>=1.17.3,<2.0.0)
|
17
|
+
Requires-Dist: pyfixtures (>=1.0.0,<2.0.0)
|
18
|
+
Requires-Dist: sentry-sdk (>=2.3.1,<3.0.0)
|
19
|
+
Requires-Dist: structlog-sentry (>=2.2.1,<3.0.0)
|
20
|
+
Requires-Dist: virtool (>=31.1.3,<32.0.0)
|
21
|
+
Description-Content-Type: text/markdown
|
22
|
+
|
23
|
+
# Virtool Workflow
|
24
|
+
|
25
|
+

|
26
|
+
[](https://badge.fury.io/py/virtool-workflow)
|
27
|
+
|
28
|
+
A framework for developing bioinformatic workflows in Python.
|
29
|
+
|
30
|
+
```python
|
31
|
+
from virtool_workflow import step
|
32
|
+
|
33
|
+
|
34
|
+
@step
|
35
|
+
def step_function():
|
36
|
+
...
|
37
|
+
|
38
|
+
|
39
|
+
@step
|
40
|
+
def step_function_2():
|
41
|
+
...
|
42
|
+
```
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
### Commits
|
47
|
+
|
48
|
+
We require specific commit formatting. Any commit that does not follow the guidelines
|
49
|
+
will be squashed at our discretion.
|
50
|
+
|
51
|
+
Read our [commit and release](https://dev.virtool.ca/en/latest/commits_releases.html)
|
52
|
+
documentation for more information.
|
53
|
+
|
54
|
+
### Tests
|
55
|
+
|
56
|
+
Run tests with:
|
57
|
+
|
58
|
+
```shell
|
59
|
+
# Bring up Redis and the test container.
|
60
|
+
docker compose up -d
|
61
|
+
|
62
|
+
# Run tests in the test container.
|
63
|
+
docker compose exec test poetry run pytest
|
64
|
+
```
|
65
|
+
|
66
|
+
Run specific tests like:
|
67
|
+
|
68
|
+
```shell
|
69
|
+
docker compose exec test poetry run pytest tests/test_status.py
|
70
|
+
```
|
71
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
virtool_workflow/__init__.py,sha256=Tw0lAFudpsFyCaiR2Oz_RKYU6N-mSCmhXDftm1WT37M,308
|
2
|
+
virtool_workflow/analysis/__init__.py,sha256=eRMQhKOxijlFlYI78FzmHZoF1qYevBXycpIcmlrgFqI,57
|
3
|
+
virtool_workflow/analysis/fastqc.py,sha256=pNorkhNVazV30fBY3KEJ6vfEskqsBzp80a_Iai8BOn8,13149
|
4
|
+
virtool_workflow/analysis/skewer.py,sha256=TWUfiYeUIahHbIosNYo2sqMjS4kUkoFBTspr70eRloI,7186
|
5
|
+
virtool_workflow/analysis/trimming.py,sha256=3Dk0J322ZhBzhuplaVgxZv4l7MLu7ZhqNQHOtNi6CGM,1451
|
6
|
+
virtool_workflow/analysis/utils.py,sha256=YU1_yInZzTNl9nKQTebUz47kUEqZ__d0k-RMLX8DWOA,1108
|
7
|
+
virtool_workflow/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
+
virtool_workflow/api/acquire.py,sha256=M8Wf6ck6YOPQU_0dalAYxuQbukj6c4Uat1OPhV7Gj2w,2157
|
9
|
+
virtool_workflow/api/client.py,sha256=wOAAX0Na1IrULWUTGq0wzbjquZqmZqCnc0gb2A2JvLE,4604
|
10
|
+
virtool_workflow/api/utils.py,sha256=UrOsrGMMJ6PbWcl84A4tKD6Lq7C8hVQIZ_TpQR75KHU,3123
|
11
|
+
virtool_workflow/cli.py,sha256=yEl1LziABKbjc5MCOoUGLy-iuqehOou37x9ox4LA92M,1441
|
12
|
+
virtool_workflow/data/__init__.py,sha256=L2bQ5rMpnCMuLWDMwel4-wPchfQCTHH3EEwxDqwGOsY,610
|
13
|
+
virtool_workflow/data/analyses.py,sha256=tGUU3gLyk_4vn1Xb7FccvBc_HQzYW_AoU7Dh1OkWhAA,3105
|
14
|
+
virtool_workflow/data/hmms.py,sha256=pntKYyWeipApMNUGYh90ReyTbJgbCPlE-cm66Eo6teA,3225
|
15
|
+
virtool_workflow/data/indexes.py,sha256=hxqxJBTt2VnclR8YjqAAEtk_Ig7OEPBx0sjxf4Puy9Y,9007
|
16
|
+
virtool_workflow/data/jobs.py,sha256=YYWxWoiVtHIBKkpOTpZl-Ute5rg-RAnMGAzBoixDNQo,1663
|
17
|
+
virtool_workflow/data/ml.py,sha256=haYHZfDbYOk0ftg6MCXbQpoDFl1VbdnQ_TuNvI9pmw0,2186
|
18
|
+
virtool_workflow/data/samples.py,sha256=fgyuQSavZiqwrqEH7Y_CoAR5gJIcO1ujrIyO5tDrXeI,4971
|
19
|
+
virtool_workflow/data/subtractions.py,sha256=LANUXM89AyFIAmG1JPR06yTniftxIkt9qqSJm7QupCU,7302
|
20
|
+
virtool_workflow/data/uploads.py,sha256=jjQ8hczvkSV-B8dioSDB_E5kA2S_4kDYDmr86TxOqbA,905
|
21
|
+
virtool_workflow/decorators.py,sha256=L9pVLCLpew-3nMdPVqKwmzk7srFEA_VT0oWrTsZsBok,1311
|
22
|
+
virtool_workflow/errors.py,sha256=VXH4FUuour9PqBE1RgC0gpZrBiQthCr3vfYCUXeHPQ4,1663
|
23
|
+
virtool_workflow/files.py,sha256=N9eo06qFNbZ0493006LMD2ezrC5fjw2KqSs-uh4qRB4,837
|
24
|
+
virtool_workflow/hooks.py,sha256=z2axwQTj3M_2tTAnBZCG6sr14GeDmxwVkEYZjmY5Nos,2673
|
25
|
+
virtool_workflow/pytest_plugin/__init__.py,sha256=y_no8N763GwZGPouTeyUQEZQWoM8eb5dPxmdRv3L0s8,740
|
26
|
+
virtool_workflow/pytest_plugin/data.py,sha256=objP7cn_4u2MtsDaf0amG0EtBv3-jthj9l3pvUyj3-I,5618
|
27
|
+
virtool_workflow/pytest_plugin/utils.py,sha256=lxyWqHKWXGxQXBIbcYUCC6PvjSeruhSDnD-dPX1mL5Y,211
|
28
|
+
virtool_workflow/runtime/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
29
|
+
virtool_workflow/runtime/config.py,sha256=fHkprWxxqWeEWKOobxpVvSOS5Njk5Mq32sH-p5o_d8g,546
|
30
|
+
virtool_workflow/runtime/discover.py,sha256=DsXII4f1cO0JT-csardzN-PfcuJ09SAFBgfDydZikFo,2933
|
31
|
+
virtool_workflow/runtime/events.py,sha256=ZIX3veBfC_2yNTdClHJaYMPn4KAF9JZqpQ3qDq4ox_E,138
|
32
|
+
virtool_workflow/runtime/hook.py,sha256=ZfmvDHoSE7Qwk4Rpcjyd-pYuwP55mzEddec2ngRZpsg,4328
|
33
|
+
virtool_workflow/runtime/path.py,sha256=J8CsNMTg4XgDtib0gVSsLNvv17q793M-ydsxN6pkHrI,562
|
34
|
+
virtool_workflow/runtime/ping.py,sha256=Xm4udRCcldHfSV1Rjpiqr-6vE7G6kaVaZgDlzNSxdao,1434
|
35
|
+
virtool_workflow/runtime/redis.py,sha256=m-Dtdpbho-Qa9W5IYJCeEEZ7vv04hYu5yALsxOJr0FY,1813
|
36
|
+
virtool_workflow/runtime/run.py,sha256=l0HguLLdYRVKvYTnIjoUB-9h6oDxffK-xzZYqO9lSIM,7599
|
37
|
+
virtool_workflow/runtime/run_subprocess.py,sha256=OFHVQ2ao16X8I9nl6Nm_f3IL7rHnmLH8ixtlAFKlOLk,4790
|
38
|
+
virtool_workflow/runtime/sentry.py,sha256=y4mh1sT-hoijRtKr4meE7yn1E-alxRKDylzGxmN6ndU,755
|
39
|
+
virtool_workflow/utils.py,sha256=jLsOtwh3RP7BCdgcr_rQr3DqzK1nLP2NILFXxbgAyGk,2530
|
40
|
+
virtool_workflow/workflow.py,sha256=W8IEFzd28wjdNNlqRrPDKyX9LeQpR6Vxy7zKeYEMQEc,2655
|
41
|
+
virtool_workflow-0.0.0.dist-info/LICENSE,sha256=nkoVQw9W4aoQM9zgtNzHDmztap5TuXZ1L2-87vNr3w8,1097
|
42
|
+
virtool_workflow-0.0.0.dist-info/METADATA,sha256=NqE-hWlfy5Xi47xHHP6rqY-YmyAMRO3fl57ATUmz6sM,1756
|
43
|
+
virtool_workflow-0.0.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
44
|
+
virtool_workflow-0.0.0.dist-info/entry_points.txt,sha256=d4MA8ZDTJOU0jKZ3ymtHZbfLVoRPgItEIN5U4uIqay8,62
|
45
|
+
virtool_workflow-0.0.0.dist-info/RECORD,,
|