labtasker-client 2.7.0__tar.gz → 2.8.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.7.0 → labtasker_client-2.8.0}/PKG-INFO +1 -1
  2. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/pyproject.toml +1 -1
  3. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/__init__.py +1 -1
  4. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/api.py +16 -2
  5. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/cli.py +14 -0
  6. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/client.py +18 -1
  7. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/models.py +1 -0
  8. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/types.py +1 -0
  9. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/validation.py +6 -1
  10. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/.gitignore +0 -0
  11. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/LICENSE +0 -0
  12. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/__main__.py +0 -0
  13. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/binding.py +0 -0
  14. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/command_template.py +0 -0
  15. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/command_worker.py +0 -0
  16. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/config.py +0 -0
  17. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/errors.py +0 -0
  18. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/execution.py +0 -0
  19. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/journal.py +0 -0
  20. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/local.py +0 -0
  21. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/observations.py +0 -0
  22. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/paths.py +0 -0
  23. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/py.typed +0 -0
  24. {labtasker_client-2.7.0 → labtasker_client-2.8.0}/src/labtasker/tee.py +0 -0
  25. {labtasker_client-2.7.0 → labtasker_client-2.8.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.7.0
3
+ Version: 2.8.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.7.0"
7
+ version = "2.8.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.7.0"
53
+ __version__ = "2.8.0"
54
54
 
55
55
  __all__ = [
56
56
  "APIError",
@@ -43,6 +43,7 @@ def get_task(task_id: str, *, queue: str | None = None) -> Task:
43
43
 
44
44
  def list_tasks(
45
45
  *,
46
+ include_archived: bool = False,
46
47
  status: TaskStatus | None = None,
47
48
  name: str | None = None,
48
49
  name_fuzzy: str | None = None,
@@ -55,6 +56,7 @@ def list_tasks(
55
56
  ) -> TaskPage:
56
57
  return _client().list_tasks(
57
58
  status=status,
59
+ include_archived=include_archived,
58
60
  name=name,
59
61
  name_fuzzy=name_fuzzy,
60
62
  filter=filter,
@@ -69,6 +71,7 @@ def list_tasks(
69
71
  @overload
70
72
  def count_tasks(
71
73
  *,
74
+ include_archived: bool = False,
72
75
  status: TaskStatus | None = None,
73
76
  name: str | None = None,
74
77
  name_fuzzy: str | None = None,
@@ -83,6 +86,7 @@ def count_tasks(
83
86
  @overload
84
87
  def count_tasks(
85
88
  *,
89
+ include_archived: bool = False,
86
90
  status: TaskStatus | None = None,
87
91
  name: str | None = None,
88
92
  name_fuzzy: str | None = None,
@@ -96,6 +100,7 @@ def count_tasks(
96
100
 
97
101
  def count_tasks(
98
102
  *,
103
+ include_archived: bool = False,
99
104
  status: TaskStatus | None = None,
100
105
  name: str | None = None,
101
106
  name_fuzzy: str | None = None,
@@ -111,10 +116,16 @@ def count_tasks(
111
116
 
112
117
  validate_grouping(None, {"routes", "status"}, limit, cursor)
113
118
  return _client().count_tasks(
114
- status=status, name=name, name_fuzzy=name_fuzzy, filter=filter, queue=queue
119
+ status=status,
120
+ name=name,
121
+ name_fuzzy=name_fuzzy,
122
+ filter=filter,
123
+ queue=queue,
124
+ include_archived=include_archived,
115
125
  )
116
126
  return _client().count_tasks(
117
127
  status=status,
128
+ include_archived=include_archived,
118
129
  name=name,
119
130
  name_fuzzy=name_fuzzy,
120
131
  filter=filter,
@@ -181,11 +192,14 @@ def update_task(
181
192
 
182
193
  def update_tasks(
183
194
  *,
195
+ include_archived: bool = False,
184
196
  filter: str,
185
197
  changes: TaskUpdate,
186
198
  queue: str | None = None,
187
199
  ) -> BulkUpdateResult:
188
- return _client().update_tasks(filter=filter, changes=changes, queue=queue)
200
+ return _client().update_tasks(
201
+ filter=filter, changes=changes, queue=queue, include_archived=include_archived
202
+ )
189
203
 
190
204
 
191
205
  def cancel_task(task_id: str, *, queue: str | None = None) -> Task:
@@ -319,6 +319,9 @@ def task_list(
319
319
  str | None,
320
320
  typer.Option(help="Opaque next_cursor from the same query and ordering."),
321
321
  ] = None,
322
+ include_archived: Annotated[
323
+ bool, typer.Option("--include-archived", help="Include archived Tasks in the filter range.")
324
+ ] = False,
322
325
  queue: Annotated[
323
326
  str | None,
324
327
  typer.Option(help="Task Queue; otherwise use Client configuration."),
@@ -340,6 +343,7 @@ def task_list(
340
343
  lambda: _with_client(
341
344
  lambda client: client.list_tasks(
342
345
  status=status,
346
+ include_archived=include_archived,
343
347
  name=name,
344
348
  name_fuzzy=name_fuzzy,
345
349
  filter=filter,
@@ -391,6 +395,9 @@ def task_count(
391
395
  cursor: Annotated[
392
396
  str | None, typer.Option(help="Next group page cursor; requires --group-by.")
393
397
  ] = None,
398
+ include_archived: Annotated[
399
+ bool, typer.Option("--include-archived", help="Include archived Tasks in the filter range.")
400
+ ] = False,
394
401
  queue: Annotated[
395
402
  str | None,
396
403
  typer.Option(help="Task Queue; otherwise use Client configuration."),
@@ -409,6 +416,7 @@ def task_count(
409
416
  lambda: _with_client(
410
417
  lambda client: client.count_tasks(
411
418
  status=status,
419
+ include_archived=include_archived,
412
420
  name=name,
413
421
  name_fuzzy=name_fuzzy,
414
422
  filter=filter,
@@ -507,6 +515,9 @@ def task_update(
507
515
  str,
508
516
  typer.Option(help="Fields to replace as one strict JSON object."),
509
517
  ] = "",
518
+ include_archived: Annotated[
519
+ bool, typer.Option("--include-archived", help="Include archived Tasks in the filter range.")
520
+ ] = False,
510
521
  queue: Annotated[
511
522
  str | None,
512
523
  typer.Option(help="Task Queue; otherwise use Client configuration."),
@@ -528,6 +539,8 @@ def task_update(
528
539
  """
529
540
  if (task_id is None) == (filter is None):
530
541
  raise typer.BadParameter("provide exactly one of TASK_ID or --filter")
542
+ if task_id is not None and include_archived:
543
+ raise typer.BadParameter("--include-archived requires --filter")
531
544
  if not changes:
532
545
  raise typer.BadParameter("--changes is required")
533
546
  normalized = cast(TaskUpdate, _json_object(changes, option="--changes"))
@@ -543,6 +556,7 @@ def task_update(
543
556
  lambda: _with_client(
544
557
  lambda client: client.update_tasks(
545
558
  filter=filter or "",
559
+ include_archived=include_archived,
546
560
  changes=normalized,
547
561
  queue=queue,
548
562
  )
@@ -231,6 +231,7 @@ class Client:
231
231
  def list_tasks(
232
232
  self,
233
233
  *,
234
+ include_archived: bool = False,
234
235
  status: TaskStatus | None = None,
235
236
  name: str | None = None,
236
237
  name_fuzzy: str | None = None,
@@ -241,6 +242,8 @@ class Client:
241
242
  cursor: str | None = None,
242
243
  queue: str | None = None,
243
244
  ) -> TaskPage:
245
+ if not isinstance(include_archived, bool):
246
+ raise RequestValidationError("include_archived must be a Boolean.")
244
247
  self._ensure_open()
245
248
  queue_name = self._queue(queue)
246
249
  status = validate_status(status)
@@ -264,6 +267,7 @@ class Client:
264
267
  validate_unicode_scalar(cursor, field="cursor")
265
268
  params = _without_none(
266
269
  {
270
+ **({"include_archived": "true"} if include_archived else {}),
267
271
  "status": status,
268
272
  "name": name,
269
273
  "name_fuzzy": name_fuzzy,
@@ -287,6 +291,7 @@ class Client:
287
291
  def count_tasks(
288
292
  self,
289
293
  *,
294
+ include_archived: bool = False,
290
295
  status: TaskStatus | None = None,
291
296
  name: str | None = None,
292
297
  name_fuzzy: str | None = None,
@@ -301,6 +306,7 @@ class Client:
301
306
  def count_tasks(
302
307
  self,
303
308
  *,
309
+ include_archived: bool = False,
304
310
  status: TaskStatus | None = None,
305
311
  name: str | None = None,
306
312
  name_fuzzy: str | None = None,
@@ -314,6 +320,7 @@ class Client:
314
320
  def count_tasks(
315
321
  self,
316
322
  *,
323
+ include_archived: bool = False,
317
324
  status: TaskStatus | None = None,
318
325
  name: str | None = None,
319
326
  name_fuzzy: str | None = None,
@@ -323,6 +330,8 @@ class Client:
323
330
  limit: int | None = None,
324
331
  cursor: str | None = None,
325
332
  ) -> int | GroupCountPage:
333
+ if not isinstance(include_archived, bool):
334
+ raise RequestValidationError("include_archived must be a Boolean.")
326
335
  self._ensure_open()
327
336
  queue_name = self._queue(queue)
328
337
  status = validate_status(status)
@@ -342,6 +351,7 @@ class Client:
342
351
  groups,
343
352
  _without_none(
344
353
  {
354
+ **({"include_archived": "true"} if include_archived else {}),
345
355
  "status": status,
346
356
  "name": name,
347
357
  "name_fuzzy": name_fuzzy,
@@ -471,10 +481,13 @@ class Client:
471
481
  def update_tasks(
472
482
  self,
473
483
  *,
484
+ include_archived: bool = False,
474
485
  filter: str,
475
486
  changes: TaskUpdate,
476
487
  queue: str | None = None,
477
488
  ) -> BulkUpdateResult:
489
+ if not isinstance(include_archived, bool):
490
+ raise RequestValidationError("include_archived must be a Boolean.")
478
491
  self._ensure_open()
479
492
  queue_name = self._queue(queue)
480
493
  normalized_filter = validate_filter(filter, required=True)
@@ -483,7 +496,11 @@ class Client:
483
496
  operation="update_tasks",
484
497
  method="PATCH",
485
498
  path=f"queues/{queue_name}/tasks",
486
- json={"filter": normalized_filter, "changes": normalized_changes},
499
+ json={
500
+ "filter": normalized_filter,
501
+ "changes": normalized_changes,
502
+ **({"include_archived": True} if include_archived else {}),
503
+ },
487
504
  parser=lambda response: _parse_model(response, BulkUpdateResult, {200}),
488
505
  )
489
506
 
@@ -61,6 +61,7 @@ class Task(ResponseModel):
61
61
  id: str
62
62
  queue: str
63
63
  status: TaskStatus
64
+ archived: bool = False
64
65
  name: str | None
65
66
  args: dict[str, JSONValue]
66
67
  metadata: dict[str, JSONValue]
@@ -22,6 +22,7 @@ TaskOrderField: TypeAlias = Literal[
22
22
 
23
23
 
24
24
  class TaskUpdate(TypedDict, total=False):
25
+ archived: bool
25
26
  name: str | None
26
27
  args: dict[str, JSONValue]
27
28
  metadata: dict[str, JSONValue]
@@ -188,6 +188,7 @@ def validate_task_update(changes: object) -> TaskUpdate:
188
188
  if not isinstance(changes, dict) or not changes:
189
189
  raise RequestValidationError("changes must be a non-empty object.")
190
190
  allowed = {
191
+ "archived",
191
192
  "name",
192
193
  "args",
193
194
  "metadata",
@@ -202,7 +203,11 @@ def validate_task_update(changes: object) -> TaskUpdate:
202
203
  raise RequestValidationError(f"changes contains unsupported fields: {sorted(unknown)!r}.")
203
204
  normalized: dict[str, object] = {}
204
205
  for field, value in changes.items():
205
- if field == "name":
206
+ if field == "archived":
207
+ if not isinstance(value, bool):
208
+ raise RequestValidationError("archived must be a Boolean.")
209
+ normalized[field] = value
210
+ elif field == "name":
206
211
  normalized[field] = validate_task_name(value)
207
212
  elif field in {"args", "metadata", "result"}:
208
213
  normalized[field] = validate_json_object(value, field=field)