parallel-web 0.2.0__py3-none-any.whl → 0.2.2__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.
Potentially problematic release.
This version of parallel-web might be problematic. Click here for more details.
- parallel/__init__.py +3 -1
- parallel/_base_client.py +12 -12
- parallel/_client.py +8 -8
- parallel/_compat.py +54 -54
- parallel/_models.py +50 -44
- parallel/_qs.py +7 -7
- parallel/_types.py +18 -11
- parallel/_utils/__init__.py +8 -2
- parallel/_utils/_compat.py +45 -0
- parallel/_utils/_datetime_parse.py +136 -0
- parallel/_utils/_transform.py +13 -3
- parallel/_utils/_typing.py +1 -1
- parallel/_utils/_utils.py +4 -5
- parallel/_version.py +1 -1
- parallel/lib/_parsing/_task_run_result.py +2 -3
- parallel/lib/_parsing/_task_spec.py +4 -4
- parallel/lib/_pydantic.py +3 -3
- parallel/resources/beta/beta.py +16 -16
- parallel/resources/beta/task_group.py +53 -35
- parallel/resources/beta/task_run.py +41 -41
- parallel/resources/task_run.py +33 -33
- parallel/types/beta/beta_run_input.py +6 -6
- parallel/types/beta/beta_run_input_param.py +6 -6
- parallel/types/beta/beta_search_params.py +3 -2
- parallel/types/beta/mcp_server_param.py +4 -2
- parallel/types/beta/search_result.py +1 -1
- parallel/types/beta/task_run_create_params.py +6 -6
- parallel/types/beta/task_run_events_response.py +6 -0
- parallel/types/shared_params/source_policy.py +4 -3
- parallel/types/text_schema.py +1 -1
- parallel/types/text_schema_param.py +3 -2
- {parallel_web-0.2.0.dist-info → parallel_web-0.2.2.dist-info}/METADATA +1 -1
- {parallel_web-0.2.0.dist-info → parallel_web-0.2.2.dist-info}/RECORD +35 -33
- {parallel_web-0.2.0.dist-info → parallel_web-0.2.2.dist-info}/WHEEL +0 -0
- {parallel_web-0.2.0.dist-info → parallel_web-0.2.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -7,7 +7,7 @@ from typing_extensions import Literal
|
|
|
7
7
|
|
|
8
8
|
import httpx
|
|
9
9
|
|
|
10
|
-
from ..._types import
|
|
10
|
+
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
11
11
|
from ..._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform
|
|
12
12
|
from ..._compat import cached_property
|
|
13
13
|
from ..._resource import SyncAPIResource, AsyncAPIResource
|
|
@@ -59,13 +59,13 @@ class TaskGroupResource(SyncAPIResource):
|
|
|
59
59
|
def create(
|
|
60
60
|
self,
|
|
61
61
|
*,
|
|
62
|
-
metadata: Optional[Dict[str, Union[str, float, bool]]] |
|
|
62
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
|
|
63
63
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
64
64
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
65
65
|
extra_headers: Headers | None = None,
|
|
66
66
|
extra_query: Query | None = None,
|
|
67
67
|
extra_body: Body | None = None,
|
|
68
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
68
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
69
69
|
) -> TaskGroup:
|
|
70
70
|
"""
|
|
71
71
|
Initiates a TaskGroup to group and track multiple runs.
|
|
@@ -99,7 +99,7 @@ class TaskGroupResource(SyncAPIResource):
|
|
|
99
99
|
extra_headers: Headers | None = None,
|
|
100
100
|
extra_query: Query | None = None,
|
|
101
101
|
extra_body: Body | None = None,
|
|
102
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
102
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
103
103
|
) -> TaskGroup:
|
|
104
104
|
"""
|
|
105
105
|
Retrieves aggregated status across runs in a TaskGroup.
|
|
@@ -128,14 +128,14 @@ class TaskGroupResource(SyncAPIResource):
|
|
|
128
128
|
task_group_id: str,
|
|
129
129
|
*,
|
|
130
130
|
inputs: Iterable[BetaRunInputParam],
|
|
131
|
-
default_task_spec: Optional[TaskSpecParam] |
|
|
132
|
-
betas: List[ParallelBetaParam] |
|
|
131
|
+
default_task_spec: Optional[TaskSpecParam] | Omit = omit,
|
|
132
|
+
betas: List[ParallelBetaParam] | Omit = omit,
|
|
133
133
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
134
134
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
135
135
|
extra_headers: Headers | None = None,
|
|
136
136
|
extra_query: Query | None = None,
|
|
137
137
|
extra_body: Body | None = None,
|
|
138
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
138
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
139
139
|
) -> TaskGroupRunResponse:
|
|
140
140
|
"""
|
|
141
141
|
Initiates multiple task runs within a TaskGroup.
|
|
@@ -163,7 +163,7 @@ class TaskGroupResource(SyncAPIResource):
|
|
|
163
163
|
if not task_group_id:
|
|
164
164
|
raise ValueError(f"Expected a non-empty value for `task_group_id` but received {task_group_id!r}")
|
|
165
165
|
extra_headers = {
|
|
166
|
-
**strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else
|
|
166
|
+
**strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
|
|
167
167
|
**(extra_headers or {}),
|
|
168
168
|
}
|
|
169
169
|
return self._post(
|
|
@@ -185,20 +185,20 @@ class TaskGroupResource(SyncAPIResource):
|
|
|
185
185
|
self,
|
|
186
186
|
task_group_id: str,
|
|
187
187
|
*,
|
|
188
|
-
last_event_id: Optional[str] |
|
|
189
|
-
api_timeout: Optional[float] |
|
|
188
|
+
last_event_id: Optional[str] | Omit = omit,
|
|
189
|
+
api_timeout: Optional[float] | Omit = omit,
|
|
190
190
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
191
191
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
192
192
|
extra_headers: Headers | None = None,
|
|
193
193
|
extra_query: Query | None = None,
|
|
194
194
|
extra_body: Body | None = None,
|
|
195
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
195
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
196
196
|
) -> Stream[TaskGroupEventsResponse]:
|
|
197
197
|
"""
|
|
198
198
|
Streams events from a TaskGroup: status updates and run completions.
|
|
199
199
|
|
|
200
|
-
The connection will remain open for up to
|
|
201
|
-
|
|
200
|
+
The connection will remain open for up to an hour as long as at least one run in
|
|
201
|
+
the group is still active.
|
|
202
202
|
|
|
203
203
|
Args:
|
|
204
204
|
extra_headers: Send extra headers
|
|
@@ -238,23 +238,32 @@ class TaskGroupResource(SyncAPIResource):
|
|
|
238
238
|
self,
|
|
239
239
|
task_group_id: str,
|
|
240
240
|
*,
|
|
241
|
-
include_input: bool |
|
|
242
|
-
include_output: bool |
|
|
243
|
-
last_event_id: Optional[str] |
|
|
241
|
+
include_input: bool | Omit = omit,
|
|
242
|
+
include_output: bool | Omit = omit,
|
|
243
|
+
last_event_id: Optional[str] | Omit = omit,
|
|
244
244
|
status: Optional[
|
|
245
245
|
Literal["queued", "action_required", "running", "completed", "failed", "cancelling", "cancelled"]
|
|
246
246
|
]
|
|
247
|
-
|
|
|
247
|
+
| Omit = omit,
|
|
248
248
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
249
249
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
250
250
|
extra_headers: Headers | None = None,
|
|
251
251
|
extra_query: Query | None = None,
|
|
252
252
|
extra_body: Body | None = None,
|
|
253
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
253
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
254
254
|
) -> Stream[TaskGroupGetRunsResponse]:
|
|
255
255
|
"""
|
|
256
256
|
Retrieves task runs in a TaskGroup and optionally their inputs and outputs.
|
|
257
257
|
|
|
258
|
+
All runs within a TaskGroup are returned as a stream. To get the inputs and/or
|
|
259
|
+
outputs back in the stream, set the corresponding `include_input` and
|
|
260
|
+
`include_output` parameters to `true`.
|
|
261
|
+
|
|
262
|
+
The stream is resumable using the `event_id` as the cursor. To resume a stream,
|
|
263
|
+
specify the `last_event_id` parameter with the `event_id` of the last event in
|
|
264
|
+
the stream. The stream will resume from the next event after the
|
|
265
|
+
`last_event_id`.
|
|
266
|
+
|
|
258
267
|
Args:
|
|
259
268
|
extra_headers: Send extra headers
|
|
260
269
|
|
|
@@ -315,13 +324,13 @@ class AsyncTaskGroupResource(AsyncAPIResource):
|
|
|
315
324
|
async def create(
|
|
316
325
|
self,
|
|
317
326
|
*,
|
|
318
|
-
metadata: Optional[Dict[str, Union[str, float, bool]]] |
|
|
327
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
|
|
319
328
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
320
329
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
321
330
|
extra_headers: Headers | None = None,
|
|
322
331
|
extra_query: Query | None = None,
|
|
323
332
|
extra_body: Body | None = None,
|
|
324
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
333
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
325
334
|
) -> TaskGroup:
|
|
326
335
|
"""
|
|
327
336
|
Initiates a TaskGroup to group and track multiple runs.
|
|
@@ -355,7 +364,7 @@ class AsyncTaskGroupResource(AsyncAPIResource):
|
|
|
355
364
|
extra_headers: Headers | None = None,
|
|
356
365
|
extra_query: Query | None = None,
|
|
357
366
|
extra_body: Body | None = None,
|
|
358
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
367
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
359
368
|
) -> TaskGroup:
|
|
360
369
|
"""
|
|
361
370
|
Retrieves aggregated status across runs in a TaskGroup.
|
|
@@ -384,14 +393,14 @@ class AsyncTaskGroupResource(AsyncAPIResource):
|
|
|
384
393
|
task_group_id: str,
|
|
385
394
|
*,
|
|
386
395
|
inputs: Iterable[BetaRunInputParam],
|
|
387
|
-
default_task_spec: Optional[TaskSpecParam] |
|
|
388
|
-
betas: List[ParallelBetaParam] |
|
|
396
|
+
default_task_spec: Optional[TaskSpecParam] | Omit = omit,
|
|
397
|
+
betas: List[ParallelBetaParam] | Omit = omit,
|
|
389
398
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
390
399
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
391
400
|
extra_headers: Headers | None = None,
|
|
392
401
|
extra_query: Query | None = None,
|
|
393
402
|
extra_body: Body | None = None,
|
|
394
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
403
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
395
404
|
) -> TaskGroupRunResponse:
|
|
396
405
|
"""
|
|
397
406
|
Initiates multiple task runs within a TaskGroup.
|
|
@@ -419,7 +428,7 @@ class AsyncTaskGroupResource(AsyncAPIResource):
|
|
|
419
428
|
if not task_group_id:
|
|
420
429
|
raise ValueError(f"Expected a non-empty value for `task_group_id` but received {task_group_id!r}")
|
|
421
430
|
extra_headers = {
|
|
422
|
-
**strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else
|
|
431
|
+
**strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
|
|
423
432
|
**(extra_headers or {}),
|
|
424
433
|
}
|
|
425
434
|
return await self._post(
|
|
@@ -441,20 +450,20 @@ class AsyncTaskGroupResource(AsyncAPIResource):
|
|
|
441
450
|
self,
|
|
442
451
|
task_group_id: str,
|
|
443
452
|
*,
|
|
444
|
-
last_event_id: Optional[str] |
|
|
445
|
-
api_timeout: Optional[float] |
|
|
453
|
+
last_event_id: Optional[str] | Omit = omit,
|
|
454
|
+
api_timeout: Optional[float] | Omit = omit,
|
|
446
455
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
447
456
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
448
457
|
extra_headers: Headers | None = None,
|
|
449
458
|
extra_query: Query | None = None,
|
|
450
459
|
extra_body: Body | None = None,
|
|
451
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
460
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
452
461
|
) -> AsyncStream[TaskGroupEventsResponse]:
|
|
453
462
|
"""
|
|
454
463
|
Streams events from a TaskGroup: status updates and run completions.
|
|
455
464
|
|
|
456
|
-
The connection will remain open for up to
|
|
457
|
-
|
|
465
|
+
The connection will remain open for up to an hour as long as at least one run in
|
|
466
|
+
the group is still active.
|
|
458
467
|
|
|
459
468
|
Args:
|
|
460
469
|
extra_headers: Send extra headers
|
|
@@ -494,23 +503,32 @@ class AsyncTaskGroupResource(AsyncAPIResource):
|
|
|
494
503
|
self,
|
|
495
504
|
task_group_id: str,
|
|
496
505
|
*,
|
|
497
|
-
include_input: bool |
|
|
498
|
-
include_output: bool |
|
|
499
|
-
last_event_id: Optional[str] |
|
|
506
|
+
include_input: bool | Omit = omit,
|
|
507
|
+
include_output: bool | Omit = omit,
|
|
508
|
+
last_event_id: Optional[str] | Omit = omit,
|
|
500
509
|
status: Optional[
|
|
501
510
|
Literal["queued", "action_required", "running", "completed", "failed", "cancelling", "cancelled"]
|
|
502
511
|
]
|
|
503
|
-
|
|
|
512
|
+
| Omit = omit,
|
|
504
513
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
505
514
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
506
515
|
extra_headers: Headers | None = None,
|
|
507
516
|
extra_query: Query | None = None,
|
|
508
517
|
extra_body: Body | None = None,
|
|
509
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
518
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
510
519
|
) -> AsyncStream[TaskGroupGetRunsResponse]:
|
|
511
520
|
"""
|
|
512
521
|
Retrieves task runs in a TaskGroup and optionally their inputs and outputs.
|
|
513
522
|
|
|
523
|
+
All runs within a TaskGroup are returned as a stream. To get the inputs and/or
|
|
524
|
+
outputs back in the stream, set the corresponding `include_input` and
|
|
525
|
+
`include_output` parameters to `true`.
|
|
526
|
+
|
|
527
|
+
The stream is resumable using the `event_id` as the cursor. To resume a stream,
|
|
528
|
+
specify the `last_event_id` parameter with the `event_id` of the last event in
|
|
529
|
+
the stream. The stream will resume from the next event after the
|
|
530
|
+
`last_event_id`.
|
|
531
|
+
|
|
514
532
|
Args:
|
|
515
533
|
extra_headers: Send extra headers
|
|
516
534
|
|
|
@@ -6,7 +6,7 @@ from typing import Any, Dict, List, Union, Iterable, Optional, cast
|
|
|
6
6
|
|
|
7
7
|
import httpx
|
|
8
8
|
|
|
9
|
-
from ..._types import
|
|
9
|
+
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
10
10
|
from ..._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform
|
|
11
11
|
from ..._compat import cached_property
|
|
12
12
|
from ..._resource import SyncAPIResource, AsyncAPIResource
|
|
@@ -56,19 +56,19 @@ class TaskRunResource(SyncAPIResource):
|
|
|
56
56
|
*,
|
|
57
57
|
input: Union[str, Dict[str, object]],
|
|
58
58
|
processor: str,
|
|
59
|
-
enable_events: Optional[bool] |
|
|
60
|
-
mcp_servers: Optional[Iterable[McpServerParam]] |
|
|
61
|
-
metadata: Optional[Dict[str, Union[str, float, bool]]] |
|
|
62
|
-
source_policy: Optional[SourcePolicy] |
|
|
63
|
-
task_spec: Optional[TaskSpecParam] |
|
|
64
|
-
webhook: Optional[WebhookParam] |
|
|
65
|
-
betas: List[ParallelBetaParam] |
|
|
59
|
+
enable_events: Optional[bool] | Omit = omit,
|
|
60
|
+
mcp_servers: Optional[Iterable[McpServerParam]] | Omit = omit,
|
|
61
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
|
|
62
|
+
source_policy: Optional[SourcePolicy] | Omit = omit,
|
|
63
|
+
task_spec: Optional[TaskSpecParam] | Omit = omit,
|
|
64
|
+
webhook: Optional[WebhookParam] | Omit = omit,
|
|
65
|
+
betas: List[ParallelBetaParam] | Omit = omit,
|
|
66
66
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
67
67
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
68
68
|
extra_headers: Headers | None = None,
|
|
69
69
|
extra_query: Query | None = None,
|
|
70
70
|
extra_body: Body | None = None,
|
|
71
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
71
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
72
72
|
) -> TaskRun:
|
|
73
73
|
"""
|
|
74
74
|
Initiates a task run.
|
|
@@ -87,13 +87,13 @@ class TaskRunResource(SyncAPIResource):
|
|
|
87
87
|
[Task Run events](https://platform.parallel.ai/api-reference) endpoint. When
|
|
88
88
|
false, no progress events are tracked. Note that progress tracking cannot be
|
|
89
89
|
enabled after a run has been created. The flag is set to true by default for
|
|
90
|
-
premium processors (pro and above).
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
premium processors (pro and above). To enable this feature in your requests,
|
|
91
|
+
specify `events-sse-2025-07-24` as one of the values in `parallel-beta` header
|
|
92
|
+
(for API calls) or `betas` param (for the SDKs).
|
|
93
93
|
|
|
94
|
-
mcp_servers: Optional list of MCP servers to use for the run.
|
|
95
|
-
|
|
96
|
-
`parallel-beta` header
|
|
94
|
+
mcp_servers: Optional list of MCP servers to use for the run. To enable this feature in your
|
|
95
|
+
requests, specify `mcp-server-2025-07-17` as one of the values in
|
|
96
|
+
`parallel-beta` header (for API calls) or `betas` param (for the SDKs).
|
|
97
97
|
|
|
98
98
|
metadata: User-provided metadata stored with the run. Keys and values must be strings with
|
|
99
99
|
a maximum length of 16 and 512 characters respectively.
|
|
@@ -122,7 +122,7 @@ class TaskRunResource(SyncAPIResource):
|
|
|
122
122
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
123
123
|
"""
|
|
124
124
|
extra_headers = {
|
|
125
|
-
**strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else
|
|
125
|
+
**strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
|
|
126
126
|
**(extra_headers or {}),
|
|
127
127
|
}
|
|
128
128
|
return self._post(
|
|
@@ -155,7 +155,7 @@ class TaskRunResource(SyncAPIResource):
|
|
|
155
155
|
extra_headers: Headers | None = None,
|
|
156
156
|
extra_query: Query | None = None,
|
|
157
157
|
extra_body: Body | None = None,
|
|
158
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
158
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
159
159
|
) -> Stream[TaskRunEventsResponse]:
|
|
160
160
|
"""
|
|
161
161
|
Streams events for a task run.
|
|
@@ -192,14 +192,14 @@ class TaskRunResource(SyncAPIResource):
|
|
|
192
192
|
self,
|
|
193
193
|
run_id: str,
|
|
194
194
|
*,
|
|
195
|
-
api_timeout: int |
|
|
196
|
-
betas: List[ParallelBetaParam] |
|
|
195
|
+
api_timeout: int | Omit = omit,
|
|
196
|
+
betas: List[ParallelBetaParam] | Omit = omit,
|
|
197
197
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
198
198
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
199
199
|
extra_headers: Headers | None = None,
|
|
200
200
|
extra_query: Query | None = None,
|
|
201
201
|
extra_body: Body | None = None,
|
|
202
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
202
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
203
203
|
) -> BetaTaskRunResult:
|
|
204
204
|
"""
|
|
205
205
|
Retrieves a run result by run_id, blocking until the run is completed.
|
|
@@ -218,7 +218,7 @@ class TaskRunResource(SyncAPIResource):
|
|
|
218
218
|
if not run_id:
|
|
219
219
|
raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
|
|
220
220
|
extra_headers = {
|
|
221
|
-
**strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else
|
|
221
|
+
**strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
|
|
222
222
|
**(extra_headers or {}),
|
|
223
223
|
}
|
|
224
224
|
return self._get(
|
|
@@ -259,19 +259,19 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
259
259
|
*,
|
|
260
260
|
input: Union[str, Dict[str, object]],
|
|
261
261
|
processor: str,
|
|
262
|
-
enable_events: Optional[bool] |
|
|
263
|
-
mcp_servers: Optional[Iterable[McpServerParam]] |
|
|
264
|
-
metadata: Optional[Dict[str, Union[str, float, bool]]] |
|
|
265
|
-
source_policy: Optional[SourcePolicy] |
|
|
266
|
-
task_spec: Optional[TaskSpecParam] |
|
|
267
|
-
webhook: Optional[WebhookParam] |
|
|
268
|
-
betas: List[ParallelBetaParam] |
|
|
262
|
+
enable_events: Optional[bool] | Omit = omit,
|
|
263
|
+
mcp_servers: Optional[Iterable[McpServerParam]] | Omit = omit,
|
|
264
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
|
|
265
|
+
source_policy: Optional[SourcePolicy] | Omit = omit,
|
|
266
|
+
task_spec: Optional[TaskSpecParam] | Omit = omit,
|
|
267
|
+
webhook: Optional[WebhookParam] | Omit = omit,
|
|
268
|
+
betas: List[ParallelBetaParam] | Omit = omit,
|
|
269
269
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
270
270
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
271
271
|
extra_headers: Headers | None = None,
|
|
272
272
|
extra_query: Query | None = None,
|
|
273
273
|
extra_body: Body | None = None,
|
|
274
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
274
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
275
275
|
) -> TaskRun:
|
|
276
276
|
"""
|
|
277
277
|
Initiates a task run.
|
|
@@ -290,13 +290,13 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
290
290
|
[Task Run events](https://platform.parallel.ai/api-reference) endpoint. When
|
|
291
291
|
false, no progress events are tracked. Note that progress tracking cannot be
|
|
292
292
|
enabled after a run has been created. The flag is set to true by default for
|
|
293
|
-
premium processors (pro and above).
|
|
294
|
-
|
|
295
|
-
|
|
293
|
+
premium processors (pro and above). To enable this feature in your requests,
|
|
294
|
+
specify `events-sse-2025-07-24` as one of the values in `parallel-beta` header
|
|
295
|
+
(for API calls) or `betas` param (for the SDKs).
|
|
296
296
|
|
|
297
|
-
mcp_servers: Optional list of MCP servers to use for the run.
|
|
298
|
-
|
|
299
|
-
`parallel-beta` header
|
|
297
|
+
mcp_servers: Optional list of MCP servers to use for the run. To enable this feature in your
|
|
298
|
+
requests, specify `mcp-server-2025-07-17` as one of the values in
|
|
299
|
+
`parallel-beta` header (for API calls) or `betas` param (for the SDKs).
|
|
300
300
|
|
|
301
301
|
metadata: User-provided metadata stored with the run. Keys and values must be strings with
|
|
302
302
|
a maximum length of 16 and 512 characters respectively.
|
|
@@ -325,7 +325,7 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
325
325
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
326
326
|
"""
|
|
327
327
|
extra_headers = {
|
|
328
|
-
**strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else
|
|
328
|
+
**strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
|
|
329
329
|
**(extra_headers or {}),
|
|
330
330
|
}
|
|
331
331
|
return await self._post(
|
|
@@ -358,7 +358,7 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
358
358
|
extra_headers: Headers | None = None,
|
|
359
359
|
extra_query: Query | None = None,
|
|
360
360
|
extra_body: Body | None = None,
|
|
361
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
361
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
362
362
|
) -> AsyncStream[TaskRunEventsResponse]:
|
|
363
363
|
"""
|
|
364
364
|
Streams events for a task run.
|
|
@@ -395,14 +395,14 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
395
395
|
self,
|
|
396
396
|
run_id: str,
|
|
397
397
|
*,
|
|
398
|
-
api_timeout: int |
|
|
399
|
-
betas: List[ParallelBetaParam] |
|
|
398
|
+
api_timeout: int | Omit = omit,
|
|
399
|
+
betas: List[ParallelBetaParam] | Omit = omit,
|
|
400
400
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
401
401
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
402
402
|
extra_headers: Headers | None = None,
|
|
403
403
|
extra_query: Query | None = None,
|
|
404
404
|
extra_body: Body | None = None,
|
|
405
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
405
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
406
406
|
) -> BetaTaskRunResult:
|
|
407
407
|
"""
|
|
408
408
|
Retrieves a run result by run_id, blocking until the run is completed.
|
|
@@ -421,7 +421,7 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
421
421
|
if not run_id:
|
|
422
422
|
raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
|
|
423
423
|
extra_headers = {
|
|
424
|
-
**strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else
|
|
424
|
+
**strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
|
|
425
425
|
**(extra_headers or {}),
|
|
426
426
|
}
|
|
427
427
|
return await self._get(
|
parallel/resources/task_run.py
CHANGED
|
@@ -10,7 +10,7 @@ import httpx
|
|
|
10
10
|
from parallel.lib._time import prepare_timeout_float
|
|
11
11
|
|
|
12
12
|
from ..types import task_run_create_params, task_run_result_params
|
|
13
|
-
from .._types import
|
|
13
|
+
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
14
14
|
from .._utils import maybe_transform, async_maybe_transform
|
|
15
15
|
from .._compat import cached_property
|
|
16
16
|
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
@@ -61,15 +61,15 @@ class TaskRunResource(SyncAPIResource):
|
|
|
61
61
|
*,
|
|
62
62
|
input: Union[str, Dict[str, object]],
|
|
63
63
|
processor: str,
|
|
64
|
-
metadata: Optional[Dict[str, Union[str, float, bool]]] |
|
|
65
|
-
source_policy: Optional[SourcePolicy] |
|
|
66
|
-
task_spec: Optional[TaskSpecParam] |
|
|
64
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
|
|
65
|
+
source_policy: Optional[SourcePolicy] | Omit = omit,
|
|
66
|
+
task_spec: Optional[TaskSpecParam] | Omit = omit,
|
|
67
67
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
68
68
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
69
69
|
extra_headers: Headers | None = None,
|
|
70
70
|
extra_query: Query | None = None,
|
|
71
71
|
extra_body: Body | None = None,
|
|
72
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
72
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
73
73
|
) -> TaskRun:
|
|
74
74
|
"""
|
|
75
75
|
Initiates a task run.
|
|
@@ -132,7 +132,7 @@ class TaskRunResource(SyncAPIResource):
|
|
|
132
132
|
extra_headers: Headers | None = None,
|
|
133
133
|
extra_query: Query | None = None,
|
|
134
134
|
extra_body: Body | None = None,
|
|
135
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
135
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
136
136
|
) -> TaskRun:
|
|
137
137
|
"""
|
|
138
138
|
Retrieves run status by run_id.
|
|
@@ -162,13 +162,13 @@ class TaskRunResource(SyncAPIResource):
|
|
|
162
162
|
self,
|
|
163
163
|
run_id: str,
|
|
164
164
|
*,
|
|
165
|
-
api_timeout: int |
|
|
165
|
+
api_timeout: int | Omit = omit,
|
|
166
166
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
167
167
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
168
168
|
extra_headers: Headers | None = None,
|
|
169
169
|
extra_query: Query | None = None,
|
|
170
170
|
extra_body: Body | None = None,
|
|
171
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
171
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
172
172
|
) -> TaskRunResult:
|
|
173
173
|
"""
|
|
174
174
|
Retrieves a run result by run_id, blocking until the run is completed.
|
|
@@ -201,7 +201,7 @@ class TaskRunResource(SyncAPIResource):
|
|
|
201
201
|
*,
|
|
202
202
|
run_id: str,
|
|
203
203
|
deadline: float,
|
|
204
|
-
output: Optional[OutputSchema] | Type[OutputT] |
|
|
204
|
+
output: Optional[OutputSchema] | Type[OutputT] | Omit = omit,
|
|
205
205
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
206
206
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
207
207
|
extra_headers: Headers | None = None,
|
|
@@ -229,14 +229,14 @@ class TaskRunResource(SyncAPIResource):
|
|
|
229
229
|
*,
|
|
230
230
|
input: Union[str, Dict[str, object]],
|
|
231
231
|
processor: str,
|
|
232
|
-
metadata: Optional[Dict[str, Union[str, float, bool]]] |
|
|
233
|
-
output: Optional[OutputSchema] |
|
|
232
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
|
|
233
|
+
output: Optional[OutputSchema] | Omit = omit,
|
|
234
234
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
235
235
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
236
236
|
extra_headers: Headers | None = None,
|
|
237
237
|
extra_query: Query | None = None,
|
|
238
238
|
extra_body: Body | None = None,
|
|
239
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
239
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
240
240
|
) -> TaskRunResult: ...
|
|
241
241
|
@overload
|
|
242
242
|
def execute(
|
|
@@ -244,28 +244,28 @@ class TaskRunResource(SyncAPIResource):
|
|
|
244
244
|
*,
|
|
245
245
|
input: Union[str, Dict[str, object]],
|
|
246
246
|
processor: str,
|
|
247
|
-
metadata: Optional[Dict[str, Union[str, float, bool]]] |
|
|
247
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
|
|
248
248
|
output: Type[OutputT],
|
|
249
249
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
250
250
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
251
251
|
extra_headers: Headers | None = None,
|
|
252
252
|
extra_query: Query | None = None,
|
|
253
253
|
extra_body: Body | None = None,
|
|
254
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
254
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
255
255
|
) -> ParsedTaskRunResult[OutputT]: ...
|
|
256
256
|
def execute(
|
|
257
257
|
self,
|
|
258
258
|
*,
|
|
259
259
|
input: Union[str, Dict[str, object]],
|
|
260
260
|
processor: str,
|
|
261
|
-
metadata: Optional[Dict[str, Union[str, float, bool]]] |
|
|
262
|
-
output: Optional[OutputSchema] | Type[OutputT] |
|
|
261
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
|
|
262
|
+
output: Optional[OutputSchema] | Type[OutputT] | Omit = omit,
|
|
263
263
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
264
264
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
265
265
|
extra_headers: Headers | None = None,
|
|
266
266
|
extra_query: Query | None = None,
|
|
267
267
|
extra_body: Body | None = None,
|
|
268
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
268
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
269
269
|
) -> TaskRunResult | ParsedTaskRunResult[OutputT]:
|
|
270
270
|
"""
|
|
271
271
|
Convenience method to create and execute a task run in a single call.
|
|
@@ -350,15 +350,15 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
350
350
|
*,
|
|
351
351
|
input: Union[str, Dict[str, object]],
|
|
352
352
|
processor: str,
|
|
353
|
-
metadata: Optional[Dict[str, Union[str, float, bool]]] |
|
|
354
|
-
source_policy: Optional[SourcePolicy] |
|
|
355
|
-
task_spec: Optional[TaskSpecParam] |
|
|
353
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
|
|
354
|
+
source_policy: Optional[SourcePolicy] | Omit = omit,
|
|
355
|
+
task_spec: Optional[TaskSpecParam] | Omit = omit,
|
|
356
356
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
357
357
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
358
358
|
extra_headers: Headers | None = None,
|
|
359
359
|
extra_query: Query | None = None,
|
|
360
360
|
extra_body: Body | None = None,
|
|
361
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
361
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
362
362
|
) -> TaskRun:
|
|
363
363
|
"""
|
|
364
364
|
Initiates a task run.
|
|
@@ -421,7 +421,7 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
421
421
|
extra_headers: Headers | None = None,
|
|
422
422
|
extra_query: Query | None = None,
|
|
423
423
|
extra_body: Body | None = None,
|
|
424
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
424
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
425
425
|
) -> TaskRun:
|
|
426
426
|
"""
|
|
427
427
|
Retrieves run status by run_id.
|
|
@@ -451,13 +451,13 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
451
451
|
self,
|
|
452
452
|
run_id: str,
|
|
453
453
|
*,
|
|
454
|
-
api_timeout: int |
|
|
454
|
+
api_timeout: int | Omit = omit,
|
|
455
455
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
456
456
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
457
457
|
extra_headers: Headers | None = None,
|
|
458
458
|
extra_query: Query | None = None,
|
|
459
459
|
extra_body: Body | None = None,
|
|
460
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
460
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
461
461
|
) -> TaskRunResult:
|
|
462
462
|
"""
|
|
463
463
|
Retrieves a run result by run_id, blocking until the run is completed.
|
|
@@ -492,7 +492,7 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
492
492
|
*,
|
|
493
493
|
run_id: str,
|
|
494
494
|
deadline: float,
|
|
495
|
-
output: Optional[OutputSchema] | Type[OutputT] |
|
|
495
|
+
output: Optional[OutputSchema] | Type[OutputT] | Omit = omit,
|
|
496
496
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
497
497
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
498
498
|
extra_headers: Headers | None = None,
|
|
@@ -520,12 +520,12 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
520
520
|
*,
|
|
521
521
|
input: Union[str, Dict[str, object]],
|
|
522
522
|
processor: str,
|
|
523
|
-
metadata: Optional[Dict[str, Union[str, float, bool]]] |
|
|
524
|
-
output: Optional[OutputSchema] |
|
|
523
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
|
|
524
|
+
output: Optional[OutputSchema] | Omit = omit,
|
|
525
525
|
extra_headers: Headers | None = None,
|
|
526
526
|
extra_query: Query | None = None,
|
|
527
527
|
extra_body: Body | None = None,
|
|
528
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
528
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
529
529
|
) -> TaskRunResult: ...
|
|
530
530
|
@overload
|
|
531
531
|
async def execute(
|
|
@@ -533,26 +533,26 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
533
533
|
*,
|
|
534
534
|
input: Union[str, Dict[str, object]],
|
|
535
535
|
processor: str,
|
|
536
|
-
metadata: Optional[Dict[str, Union[str, float, bool]]] |
|
|
536
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
|
|
537
537
|
output: Type[OutputT],
|
|
538
538
|
extra_headers: Headers | None = None,
|
|
539
539
|
extra_query: Query | None = None,
|
|
540
540
|
extra_body: Body | None = None,
|
|
541
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
541
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
542
542
|
) -> ParsedTaskRunResult[OutputT]: ...
|
|
543
543
|
async def execute(
|
|
544
544
|
self,
|
|
545
545
|
*,
|
|
546
546
|
input: Union[str, Dict[str, object]],
|
|
547
547
|
processor: str,
|
|
548
|
-
metadata: Optional[Dict[str, Union[str, float, bool]]] |
|
|
549
|
-
output: Optional[OutputSchema] | Type[OutputT] |
|
|
548
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
|
|
549
|
+
output: Optional[OutputSchema] | Type[OutputT] | Omit = omit,
|
|
550
550
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
551
551
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
552
552
|
extra_headers: Headers | None = None,
|
|
553
553
|
extra_query: Query | None = None,
|
|
554
554
|
extra_body: Body | None = None,
|
|
555
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
555
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
556
556
|
) -> TaskRunResult | ParsedTaskRunResult[OutputT]:
|
|
557
557
|
"""
|
|
558
558
|
Convenience method to create and execute a task run in a single call.
|