datatorch 0.8.3__tar.gz → 0.8.4__tar.gz
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.
- {datatorch-0.8.3 → datatorch-0.8.4}/PKG-INFO +1 -1
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/runner/runner.py +82 -4
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch.egg-info/PKG-INFO +1 -1
- {datatorch-0.8.3 → datatorch-0.8.4}/setup.py +1 -1
- {datatorch-0.8.3 → datatorch-0.8.4}/README.md +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/agent/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/api.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/client.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/annotation.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/base.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/dataset.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/file.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/label.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/project.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/settings.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/sources/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/sources/image/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/sources/image/bounding_box.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/sources/image/segmentations.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/sources/image/typings.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/sources/source.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/storage_link.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/entity/user.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/pull.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/scripts/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/scripts/import_coco.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/scripts/import_coco_server.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/scripts/import_pixmask.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/scripts/utils/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/scripts/utils/simplify.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/utils.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/api/where.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/action/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/action/create.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/action/pull.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/action/run.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/groups.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/import_cmds/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/import_cmds/coco.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/import_cmds/pixmask.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/main/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/main/login.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/main/logout.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/main/pull.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/main/upgrade.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/main/version.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/pipeline/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/pipeline/generate.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/pipeline/run.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/pipeline/upload.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/runner/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/runner/create.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/runner/dir.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/runner/start.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/spinner.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/upload/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/upload/folder.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/cli/utils.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/core/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/core/env.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/core/folder.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/core/settings.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/client.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/daemon.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/directory.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/log_handler.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/logging.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/monitoring.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/action/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/action/action.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/action/cache.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/action/config.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/job/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/job/job.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/pipeline.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/resolver.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/runner/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/runner/command.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/runner/docker.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/runner/factory.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/runner/node.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/runner/python.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/runner/shell.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/step/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/step/step.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/pipelines/template.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/services/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/utils/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/utils/docker.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/runner/utils/process.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/utils/__init__.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/utils/converters.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/utils/files.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/utils/hash_table.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/utils/objects.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/utils/package.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/utils/string_style.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch/utils/url.py +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch.egg-info/SOURCES.txt +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch.egg-info/dependency_links.txt +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch.egg-info/entry_points.txt +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch.egg-info/not-zip-safe +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch.egg-info/requires.txt +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/datatorch.egg-info/top_level.txt +0 -0
- {datatorch-0.8.3 → datatorch-0.8.4}/setup.cfg +0 -0
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import json
|
|
3
|
+
import time
|
|
4
|
+
import signal
|
|
3
5
|
import typing
|
|
4
6
|
import asyncio
|
|
5
7
|
|
|
8
|
+
import psutil
|
|
9
|
+
|
|
6
10
|
from typing import Any, Awaitable, Dict
|
|
7
11
|
from ..template import Variables
|
|
8
12
|
|
|
@@ -19,6 +23,51 @@ class ProcessCodeError(Exception):
|
|
|
19
23
|
# output value (e.g. an http-request body), not ordinary log lines.
|
|
20
24
|
STDOUT_LINE_LIMIT = 16 * 1024 * 1024
|
|
21
25
|
|
|
26
|
+
# How long a stopped step's processes get to exit by themselves (SIGTERM)
|
|
27
|
+
# before they are killed. The server has already closed the step by then,
|
|
28
|
+
# so nothing waits on this except the processes' own cleanup.
|
|
29
|
+
TERMINATE_GRACE_SECONDS = 5.0
|
|
30
|
+
|
|
31
|
+
# Windows has no process groups in this sense and no SIGKILL.
|
|
32
|
+
_POSIX = os.name == "posix"
|
|
33
|
+
_SIGKILL = getattr(signal, "SIGKILL", signal.SIGTERM)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _descendants(pid: int) -> list:
|
|
37
|
+
"""Every process under `pid` right now, as psutil handles (which
|
|
38
|
+
refuse to signal a pid that has since been reused)."""
|
|
39
|
+
try:
|
|
40
|
+
return psutil.Process(pid).children(recursive=True)
|
|
41
|
+
except psutil.Error:
|
|
42
|
+
return []
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _alive(proc) -> bool:
|
|
46
|
+
try:
|
|
47
|
+
return proc.is_running() and proc.status() != psutil.STATUS_ZOMBIE
|
|
48
|
+
except psutil.Error:
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _signal_tree(process, tree: list, sig: int) -> None:
|
|
53
|
+
"""Send `sig` to the step's process group and to every noted
|
|
54
|
+
descendant, wherever it now lives. A process already gone is fine."""
|
|
55
|
+
if process.returncode is None:
|
|
56
|
+
try:
|
|
57
|
+
if _POSIX:
|
|
58
|
+
# run_cmd gives each step its own session, so its group id
|
|
59
|
+
# is the shell's pid and never the runner's own group.
|
|
60
|
+
os.killpg(process.pid, sig)
|
|
61
|
+
else:
|
|
62
|
+
process.send_signal(sig)
|
|
63
|
+
except (ProcessLookupError, PermissionError, OSError):
|
|
64
|
+
pass
|
|
65
|
+
for proc in tree:
|
|
66
|
+
try:
|
|
67
|
+
proc.send_signal(sig)
|
|
68
|
+
except (psutil.Error, OSError):
|
|
69
|
+
pass
|
|
70
|
+
|
|
22
71
|
|
|
23
72
|
class Runner(object):
|
|
24
73
|
def __init__(self, config: dict, action: "Action"):
|
|
@@ -44,8 +93,8 @@ class Runner(object):
|
|
|
44
93
|
|
|
45
94
|
Streams stdout live (rather than waiting then draining) so that if
|
|
46
95
|
the step is canceled or times out server-side — the asyncio task
|
|
47
|
-
running it receives ``CancelledError`` — the child process
|
|
48
|
-
|
|
96
|
+
running it receives ``CancelledError`` — the child process and
|
|
97
|
+
everything it started are stopped instead of being orphaned.
|
|
49
98
|
"""
|
|
50
99
|
process = await self.run_cmd(command, wait=False, env=env)
|
|
51
100
|
|
|
@@ -69,11 +118,36 @@ class Runner(object):
|
|
|
69
118
|
)
|
|
70
119
|
|
|
71
120
|
async def _terminate(self, process):
|
|
72
|
-
"""
|
|
121
|
+
"""Stop a still-running step: the whole process tree, not only the
|
|
122
|
+
shell that wraps the command (best effort).
|
|
123
|
+
|
|
124
|
+
`run_cmd` starts the command through a shell, so `process` is that
|
|
125
|
+
shell. Killing it alone left everything under it running: on
|
|
126
|
+
2026-11-11 a timed-out seed step's `claude` process worked on for
|
|
127
|
+
40 minutes after the server had closed the step. So: note every
|
|
128
|
+
descendant first (a process that moved to its own group is found by
|
|
129
|
+
parentage, and once its parent dies that link is gone), ask the
|
|
130
|
+
tree to stop with SIGTERM so a process that manages children of its
|
|
131
|
+
own can stop them, then kill whatever is left after
|
|
132
|
+
`TERMINATE_GRACE_SECONDS`.
|
|
133
|
+
"""
|
|
73
134
|
if process.returncode is not None:
|
|
74
135
|
return
|
|
136
|
+
|
|
137
|
+
tree = _descendants(process.pid)
|
|
138
|
+
_signal_tree(process, tree, signal.SIGTERM)
|
|
139
|
+
|
|
140
|
+
deadline = time.monotonic() + TERMINATE_GRACE_SECONDS
|
|
141
|
+
while time.monotonic() < deadline:
|
|
142
|
+
if process.returncode is not None and not any(
|
|
143
|
+
_alive(proc) for proc in tree
|
|
144
|
+
):
|
|
145
|
+
break
|
|
146
|
+
await asyncio.sleep(0.1)
|
|
147
|
+
else:
|
|
148
|
+
_signal_tree(process, tree, _SIGKILL)
|
|
149
|
+
|
|
75
150
|
try:
|
|
76
|
-
process.kill()
|
|
77
151
|
await process.wait()
|
|
78
152
|
except ProcessLookupError:
|
|
79
153
|
pass
|
|
@@ -157,6 +231,10 @@ class Runner(object):
|
|
|
157
231
|
# page body — asyncio's 64KB default readline limit kills the
|
|
158
232
|
# stream with LimitOverrunError on anything larger.
|
|
159
233
|
limit=STDOUT_LINE_LIMIT,
|
|
234
|
+
# Its own session and process group, so a stop can signal the
|
|
235
|
+
# step's whole tree at once without touching the runner (see
|
|
236
|
+
# _terminate). Ignored on Windows.
|
|
237
|
+
start_new_session=True,
|
|
160
238
|
)
|
|
161
239
|
if wait:
|
|
162
240
|
await process.wait()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|