virtool-workflow 5.2.1__py3-none-any.whl → 5.3.1__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/api/client.py +7 -2
- virtool_workflow/api/jobs.py +19 -8
- virtool_workflow/runtime/run.py +36 -0
- virtool_workflow/runtime/sentry.py +2 -2
- {virtool_workflow-5.2.1.dist-info → virtool_workflow-5.3.1.dist-info}/METADATA +1 -3
- {virtool_workflow-5.2.1.dist-info → virtool_workflow-5.3.1.dist-info}/RECORD +9 -9
- {virtool_workflow-5.2.1.dist-info → virtool_workflow-5.3.1.dist-info}/WHEEL +1 -1
- {virtool_workflow-5.2.1.dist-info → virtool_workflow-5.3.1.dist-info}/LICENSE +0 -0
- {virtool_workflow-5.2.1.dist-info → virtool_workflow-5.3.1.dist-info}/entry_points.txt +0 -0
virtool_workflow/api/client.py
CHANGED
@@ -1,12 +1,17 @@
|
|
1
|
+
from functools import wraps
|
2
|
+
|
1
3
|
import aiohttp
|
2
4
|
from pyfixtures import fixture
|
3
|
-
from functools import wraps
|
4
5
|
|
5
6
|
|
6
7
|
@fixture
|
7
8
|
async def http():
|
8
9
|
""":class:`Aiohttp.ClientSession` instance to be used for workflows."""
|
9
|
-
|
10
|
+
connector = aiohttp.TCPConnector(force_close=True, limit=100)
|
11
|
+
|
12
|
+
async with aiohttp.ClientSession(
|
13
|
+
auto_decompress=False, connector=connector
|
14
|
+
) as session:
|
10
15
|
yield JobApiHttpSession(session)
|
11
16
|
|
12
17
|
|
virtool_workflow/api/jobs.py
CHANGED
@@ -65,14 +65,23 @@ def acquire_job(http: ClientSession, jobs_api_connection_string: str):
|
|
65
65
|
|
66
66
|
|
67
67
|
async def ping(http: ClientSession, jobs_api_connection_string: str, job_id: str):
|
68
|
-
|
69
|
-
|
70
|
-
) as response:
|
68
|
+
"""
|
69
|
+
Send a ping to the jobs API to indicate that the job is still running.
|
71
70
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
71
|
+
:param http: An :class:`aiohttp.ClientSession` to use to make the request.
|
72
|
+
:param jobs_api_connection_string: The url for the jobs API.
|
73
|
+
:param job_id: The id of the job to ping.
|
74
|
+
:return: The job.
|
75
|
+
"""
|
76
|
+
print(http)
|
77
|
+
|
78
|
+
async with http.put(f"{jobs_api_connection_string}/jobs/{job_id}/ping") as resp:
|
79
|
+
print(resp.status)
|
80
|
+
print(await resp.text())
|
81
|
+
|
82
|
+
print("PING")
|
83
|
+
|
84
|
+
logger.info("Sent ping")
|
76
85
|
|
77
86
|
|
78
87
|
@fixture(scope="function")
|
@@ -109,8 +118,10 @@ async def _push_status(
|
|
109
118
|
state: str,
|
110
119
|
progress: float,
|
111
120
|
error: Optional[Exception] = None,
|
112
|
-
max_tb: int =
|
121
|
+
max_tb: int = 500,
|
113
122
|
):
|
123
|
+
if error:
|
124
|
+
logger.critical("Reporting error to API", exc_info=error)
|
114
125
|
|
115
126
|
payload = {
|
116
127
|
"state": state,
|
virtool_workflow/runtime/run.py
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
import asyncio
|
2
2
|
import signal
|
3
3
|
import sys
|
4
|
+
from asyncio import CancelledError
|
4
5
|
from logging import getLogger
|
5
6
|
from pathlib import Path
|
6
7
|
from typing import Any, Dict
|
7
8
|
|
8
9
|
import pkg_resources
|
10
|
+
from aiohttp import ClientOSError, ServerDisconnectedError
|
9
11
|
from pyfixtures import FixtureScope, runs_in_new_fixture_context
|
10
12
|
from virtool_core.logging import configure_logs
|
11
13
|
from virtool_core.redis import configure_redis
|
12
14
|
|
13
15
|
from virtool_workflow import execute
|
16
|
+
from virtool_workflow.api.jobs import ping
|
14
17
|
from virtool_workflow.hooks import (
|
15
18
|
on_failure,
|
16
19
|
on_cancelled,
|
@@ -83,6 +86,33 @@ def cleanup_builtin_status_hooks():
|
|
83
86
|
on_terminated.clear()
|
84
87
|
|
85
88
|
|
89
|
+
async def ping_periodically(http, job, jobs_api_connection_string, job_id):
|
90
|
+
"""
|
91
|
+
Ping the API to keep the job alive.
|
92
|
+
|
93
|
+
"""
|
94
|
+
retries = 0
|
95
|
+
|
96
|
+
try:
|
97
|
+
while True:
|
98
|
+
if retries > 5:
|
99
|
+
logger.warning("Failed to ping server")
|
100
|
+
break
|
101
|
+
|
102
|
+
await asyncio.sleep(0.1)
|
103
|
+
|
104
|
+
try:
|
105
|
+
await ping(http, jobs_api_connection_string, job_id)
|
106
|
+
except (ClientOSError, ServerDisconnectedError):
|
107
|
+
await asyncio.sleep(0.3)
|
108
|
+
retries += 1
|
109
|
+
continue
|
110
|
+
|
111
|
+
await asyncio.sleep(5)
|
112
|
+
except CancelledError:
|
113
|
+
logger.info("Stopped pinging server")
|
114
|
+
|
115
|
+
|
86
116
|
async def run_workflow(
|
87
117
|
config: Dict[str, Any],
|
88
118
|
job_id: str,
|
@@ -96,13 +126,19 @@ async def run_workflow(
|
|
96
126
|
scope["config"] = config
|
97
127
|
scope["job_id"] = job_id
|
98
128
|
|
129
|
+
bound_ping = await scope.bind(ping_periodically)
|
130
|
+
|
99
131
|
execute_task = asyncio.create_task(execute(workflow, scope, events))
|
132
|
+
ping_task = asyncio.create_task(bound_ping())
|
100
133
|
|
101
134
|
try:
|
102
135
|
await execute_task
|
103
136
|
except asyncio.CancelledError:
|
104
137
|
execute_task.cancel()
|
105
138
|
|
139
|
+
ping_task.cancel()
|
140
|
+
|
141
|
+
await ping_task
|
106
142
|
await execute_task
|
107
143
|
|
108
144
|
cleanup_builtin_status_hooks()
|
@@ -9,7 +9,7 @@ from sentry_sdk.integrations.logging import LoggingIntegration
|
|
9
9
|
logger = getLogger("runtime")
|
10
10
|
|
11
11
|
|
12
|
-
def configure_sentry(dsn: Optional[str]
|
12
|
+
def configure_sentry(dsn: Optional[str]):
|
13
13
|
"""
|
14
14
|
Initialize Sentry for log aggregation.
|
15
15
|
"""
|
@@ -22,7 +22,7 @@ def configure_sentry(dsn: Optional[str], event_level: int = logging.ERROR):
|
|
22
22
|
dsn=dsn,
|
23
23
|
integrations=[
|
24
24
|
LoggingIntegration(
|
25
|
-
event_level=
|
25
|
+
event_level=logging.WARNING,
|
26
26
|
)
|
27
27
|
],
|
28
28
|
release=pkg_resources.get_distribution("virtool-workflow").version,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: virtool-workflow
|
3
|
-
Version: 5.
|
3
|
+
Version: 5.3.1
|
4
4
|
Summary: A framework for developing bioinformatics workflows for Virtool.
|
5
5
|
Home-page: https://github.com/virtool/virtool-workflow
|
6
6
|
License: MIT
|
@@ -10,9 +10,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
11
11
|
Classifier: Programming Language :: Python :: 3.10
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
14
13
|
Classifier: Topic :: Software Development :: Libraries
|
15
|
-
Provides-Extra: test
|
16
14
|
Requires-Dist: aiofiles (>=0.7.0,<0.8.0)
|
17
15
|
Requires-Dist: aiohttp (>=3.8.1,<4.0.0)
|
18
16
|
Requires-Dist: aioredis (==1.3.1)
|
@@ -13,11 +13,11 @@ virtool_workflow/analysis/trimming.py,sha256=u-M7UFnJUrjxZ_vwkjuPFzIuIVRsCXpWSi5
|
|
13
13
|
virtool_workflow/analysis/utils.py,sha256=sxFRlJnablszwwWfiZHbytn23D7cLRtOIC-Ivh4GlLQ,992
|
14
14
|
virtool_workflow/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
15
|
virtool_workflow/api/analysis.py,sha256=koPVudEjnepdggcx-w9Y9mHKJStFaW3HBc6sgSVKfqs,4789
|
16
|
-
virtool_workflow/api/client.py,sha256=
|
16
|
+
virtool_workflow/api/client.py,sha256=1cZOQf8ZEdviM50th3Jky4vyCq3c4J2wBXsdwacKU5U,1528
|
17
17
|
virtool_workflow/api/errors.py,sha256=jehj160u-Cy5vJR714YQ-LRlR6T4yqoJcl156MnN4Eo,2476
|
18
18
|
virtool_workflow/api/hmm.py,sha256=OU8jc00qm-_IaFjlidu6PktDjk0Syi7MHcwCWvvAtPY,2106
|
19
19
|
virtool_workflow/api/indexes.py,sha256=L14yfV1wZXep4HwQ1YTF9846XChuXfOcUI2jgOPUqB4,3616
|
20
|
-
virtool_workflow/api/jobs.py,sha256=
|
20
|
+
virtool_workflow/api/jobs.py,sha256=qGTxsL4qPrHAgMCVFGfLWB2PA12pj-Nq3zXMd0ojokg,4248
|
21
21
|
virtool_workflow/api/samples.py,sha256=NJs_P0MGmSllx3-LIN0EpYIqiGF5nedIEqynb10KL1I,3168
|
22
22
|
virtool_workflow/api/subtractions.py,sha256=NJhNMhwkXGWBIQejBRQfReHQd7eTZl5-VSPTWjy-s5U,4016
|
23
23
|
virtool_workflow/api/uploads.py,sha256=XjUUMVV2LkSG1AhYBps-0k4L9PeochXH3CmJTw-8Mdg,1861
|
@@ -41,17 +41,17 @@ virtool_workflow/runtime/executor.py,sha256=jh5s8xGnc6bQ3Cqvi_mRyauXH8pm2qCDLGA4
|
|
41
41
|
virtool_workflow/runtime/hook.py,sha256=rCWADxp-nPv4vqKVhGgaxAW6eQOqPcC0rlvM-hBuh1w,4389
|
42
42
|
virtool_workflow/runtime/providers.py,sha256=lT0gLAa6pWlu5v-wYQsxwXl0uy7gWYXK4cai3iiZgak,2504
|
43
43
|
virtool_workflow/runtime/redis.py,sha256=l_p3LMF9BDLKUAygJZE4a9zXvX7zLj1oO1BSyL4Vxpk,1566
|
44
|
-
virtool_workflow/runtime/run.py,sha256=
|
44
|
+
virtool_workflow/runtime/run.py,sha256=3PZwHIS2g_J3KezXxCYreoZy7CpJwsunbcW5Sb-YUsU,5618
|
45
45
|
virtool_workflow/runtime/run_subprocess.py,sha256=fDuKRunXBff9wGbFBgh0_-kVXzIsk39d5Bo_RPxkdHI,4636
|
46
|
-
virtool_workflow/runtime/sentry.py,sha256=
|
46
|
+
virtool_workflow/runtime/sentry.py,sha256=5FFerIiKwVhLMWrQKpK2nP8KQtO7qIT7nf2DcaOSU1Q,684
|
47
47
|
virtool_workflow/runtime/states.py,sha256=sKNsSJ0cbU31pZVTq_GHPBiVamhx2JmCvyl5RiaGc58,203
|
48
48
|
virtool_workflow/runtime/step.py,sha256=N1f8FP_AmXyYTRu0wxiiKYbI_S-Ehma_zxafZ7C-G5Y,2437
|
49
49
|
virtool_workflow/runtime/utils.py,sha256=ZzIhA08PsQHUxHycSP8JnTd9b3x1fyCp8fC8NslleKs,432
|
50
50
|
virtool_workflow/testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
51
51
|
virtool_workflow/testing/fixtures.py,sha256=_UuKeUEhC6a0v4WE3gSfrplj2Rrl5GSgHjXicyBuLgs,1609
|
52
52
|
virtool_workflow/workflow.py,sha256=S45QrnhInGulR6wezBVFJbZl3XZ351b6dLnEwmdpbE4,752
|
53
|
-
virtool_workflow-5.
|
54
|
-
virtool_workflow-5.
|
55
|
-
virtool_workflow-5.
|
56
|
-
virtool_workflow-5.
|
57
|
-
virtool_workflow-5.
|
53
|
+
virtool_workflow-5.3.1.dist-info/LICENSE,sha256=nkoVQw9W4aoQM9zgtNzHDmztap5TuXZ1L2-87vNr3w8,1097
|
54
|
+
virtool_workflow-5.3.1.dist-info/METADATA,sha256=GG8GuZTC5dsqrqhhcuRLAl1cZgczVSZp3Ob27fVyVLw,4774
|
55
|
+
virtool_workflow-5.3.1.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
56
|
+
virtool_workflow-5.3.1.dist-info/entry_points.txt,sha256=d4MA8ZDTJOU0jKZ3ymtHZbfLVoRPgItEIN5U4uIqay8,62
|
57
|
+
virtool_workflow-5.3.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|