labtasker-client 2.6.0__tar.gz → 2.7.0__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.
Files changed (25) hide show
  1. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/PKG-INFO +1 -1
  2. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/pyproject.toml +1 -1
  3. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/__init__.py +1 -1
  4. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/api.py +2 -0
  5. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/cli.py +8 -0
  6. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/client.py +7 -0
  7. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/command_worker.py +4 -2
  8. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/models.py +7 -0
  9. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/types.py +1 -0
  10. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/validation.py +18 -1
  11. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/.gitignore +0 -0
  12. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/LICENSE +0 -0
  13. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/__main__.py +0 -0
  14. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/binding.py +0 -0
  15. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/command_template.py +0 -0
  16. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/config.py +0 -0
  17. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/errors.py +0 -0
  18. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/execution.py +0 -0
  19. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/journal.py +0 -0
  20. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/local.py +0 -0
  21. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/observations.py +0 -0
  22. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/paths.py +0 -0
  23. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/py.typed +0 -0
  24. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/tee.py +0 -0
  25. {labtasker_client-2.6.0 → labtasker_client-2.7.0}/src/labtasker/worker.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: labtasker-client
3
- Version: 2.6.0
3
+ Version: 2.7.0
4
4
  Summary: A small task queue for parallel model inference and evaluation
5
5
  Project-URL: Homepage, https://github.com/luocfprime/labtasker
6
6
  Project-URL: Repository, https://github.com/luocfprime/labtasker.git
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "labtasker-client"
7
- version = "2.6.0"
7
+ version = "2.7.0"
8
8
  description = "A small task queue for parallel model inference and evaluation"
9
9
  requires-python = ">=3.10"
10
10
  license = "Apache-2.0"
@@ -50,7 +50,7 @@ from labtasker.models import (
50
50
  from labtasker.types import JSONValue, TaskOrderField, TaskStatus, TaskUpdate
51
51
  from labtasker.worker import loop
52
52
 
53
- __version__ = "2.6.0"
53
+ __version__ = "2.7.0"
54
54
 
55
55
  __all__ = [
56
56
  "APIError",
@@ -20,6 +20,7 @@ def submit_task(
20
20
  priority: int = 0,
21
21
  max_attempts: int = 3,
22
22
  routes: list[str] | None = None,
23
+ dependencies: list[str] | None = None,
23
24
  task_id: str | None = None,
24
25
  queue: str | None = None,
25
26
  ) -> Task:
@@ -30,6 +31,7 @@ def submit_task(
30
31
  priority=priority,
31
32
  max_attempts=max_attempts,
32
33
  routes=routes,
34
+ dependencies=dependencies,
33
35
  task_id=task_id,
34
36
  queue=queue,
35
37
  )
@@ -231,6 +231,13 @@ def task_submit(
231
231
  str | None,
232
232
  typer.Option("--id", help="Caller-chosen idempotent Task ID."),
233
233
  ] = None,
234
+ dependencies: Annotated[
235
+ list[str] | None,
236
+ typer.Option(
237
+ "--dependency",
238
+ help="Experimental: same-Queue Task ID required to succeed; repeat as needed.",
239
+ ),
240
+ ] = None,
234
241
  queue: Annotated[
235
242
  str | None,
236
243
  typer.Option(help="Target Queue; otherwise use Client configuration."),
@@ -257,6 +264,7 @@ def task_submit(
257
264
  priority=priority,
258
265
  max_attempts=max_attempts,
259
266
  routes=routes,
267
+ dependencies=dependencies,
260
268
  task_id=task_id,
261
269
  queue=queue,
262
270
  )
@@ -30,6 +30,7 @@ from labtasker.models import (
30
30
  from labtasker.types import JSONValue, TaskOrderField, TaskStatus, TaskUpdate
31
31
  from labtasker.validation import (
32
32
  RequestValidationError,
33
+ validate_dependencies,
33
34
  validate_filter,
34
35
  validate_grouping,
35
36
  validate_identifier,
@@ -170,6 +171,7 @@ class Client:
170
171
  priority: int = 0,
171
172
  max_attempts: int = 3,
172
173
  routes: list[str] | None = None,
174
+ dependencies: list[str] | None = None,
173
175
  task_id: str | None = None,
174
176
  queue: str | None = None,
175
177
  ) -> Task:
@@ -180,6 +182,9 @@ class Client:
180
182
  field="metadata",
181
183
  )
182
184
  normalized_routes = validate_routes(["default"] if routes is None else routes)
185
+ normalized_dependencies = validate_dependencies(
186
+ [] if dependencies is None else dependencies
187
+ )
183
188
  body: dict[str, object] = {
184
189
  "name": validate_task_name(name),
185
190
  "args": normalized_args,
@@ -192,6 +197,8 @@ class Client:
192
197
  ),
193
198
  "routes": normalized_routes,
194
199
  }
200
+ if normalized_dependencies:
201
+ body["dependencies"] = normalized_dependencies
195
202
  queue_name = self._queue(queue)
196
203
  if task_id is not None:
197
204
  selected_id = validate_task_id(task_id)
@@ -422,8 +422,10 @@ def _terminate_process_group(
422
422
  # cooperative signal handler writes cleanup output before exiting.
423
423
  if drain_output is not None:
424
424
  drain_output()
425
- process.poll()
426
- if not _process_group_alive(process.pid):
425
+ # The launcher itself proves that its process group is still alive.
426
+ # Avoid the more expensive group scan until it exits; on Darwin that
427
+ # scan starts /bin/ps and can otherwise starve PTY drainage.
428
+ if process.poll() is not None and not _process_group_alive(process.pid):
427
429
  break
428
430
  if deadline is not None and time.monotonic() >= deadline:
429
431
  _signal_process_group(process.pid, signal.SIGKILL)
@@ -8,6 +8,7 @@ from pydantic import BaseModel, ConfigDict, Field, field_validator, model_valida
8
8
 
9
9
  from labtasker.types import JSONValue, TaskStatus
10
10
  from labtasker.validation import (
11
+ validate_dependencies,
11
12
  validate_identifier,
12
13
  validate_int64,
13
14
  validate_json_object,
@@ -67,6 +68,7 @@ class Task(ResponseModel):
67
68
  attempt: int
68
69
  max_attempts: int
69
70
  routes: list[str]
71
+ dependencies: list[str] = Field(default_factory=list)
70
72
  result: dict[str, JSONValue]
71
73
  progress: dict[str, JSONValue] | None = None
72
74
  progress_updated_at: datetime | None = None
@@ -78,6 +80,11 @@ class Task(ResponseModel):
78
80
  started_at: datetime | None
79
81
  finished_at: datetime | None
80
82
 
83
+ @field_validator("dependencies")
84
+ @classmethod
85
+ def validate_task_dependencies(cls, value: list[str]) -> list[str]:
86
+ return validate_dependencies(value)
87
+
81
88
  @field_validator("id")
82
89
  @classmethod
83
90
  def validate_id(cls, value: str) -> str:
@@ -28,4 +28,5 @@ class TaskUpdate(TypedDict, total=False):
28
28
  priority: int
29
29
  max_attempts: int
30
30
  routes: list[str]
31
+ dependencies: list[str]
31
32
  result: dict[str, JSONValue]
@@ -120,6 +120,12 @@ def validate_run_id(value: object) -> str:
120
120
  return value
121
121
 
122
122
 
123
+ def validate_dependencies(value: object) -> list[str]:
124
+ if not isinstance(value, list):
125
+ raise RequestValidationError("dependencies must be a list of Task IDs.")
126
+ return [validate_task_id(task_id) for task_id in value]
127
+
128
+
123
129
  def validate_task_name(value: object) -> str | None:
124
130
  if value is None:
125
131
  return None
@@ -181,7 +187,16 @@ def validate_order_field(value: object) -> TaskOrderField:
181
187
  def validate_task_update(changes: object) -> TaskUpdate:
182
188
  if not isinstance(changes, dict) or not changes:
183
189
  raise RequestValidationError("changes must be a non-empty object.")
184
- allowed = {"name", "args", "metadata", "priority", "max_attempts", "routes", "result"}
190
+ allowed = {
191
+ "name",
192
+ "args",
193
+ "metadata",
194
+ "priority",
195
+ "max_attempts",
196
+ "routes",
197
+ "dependencies",
198
+ "result",
199
+ }
185
200
  unknown = set(changes) - allowed
186
201
  if unknown:
187
202
  raise RequestValidationError(f"changes contains unsupported fields: {sorted(unknown)!r}.")
@@ -197,6 +212,8 @@ def validate_task_update(changes: object) -> TaskUpdate:
197
212
  normalized[field] = validate_int64(value, field=field, positive=True)
198
213
  elif field == "routes":
199
214
  normalized[field] = validate_routes(value)
215
+ elif field == "dependencies":
216
+ normalized[field] = validate_dependencies(value)
200
217
  return cast(TaskUpdate, normalized)
201
218
 
202
219