parallel-web 0.1.1__py3-none-any.whl → 0.1.3__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 +5 -0
- parallel/_base_client.py +22 -2
- parallel/_constants.py +2 -0
- parallel/_models.py +2 -0
- parallel/_types.py +2 -0
- parallel/_utils/_proxy.py +4 -1
- parallel/_utils/_resources_proxy.py +24 -0
- parallel/_version.py +1 -1
- parallel/lib/_time.py +21 -4
- parallel/resources/task_run.py +4 -4
- {parallel_web-0.1.1.dist-info → parallel_web-0.1.3.dist-info}/METADATA +75 -27
- {parallel_web-0.1.1.dist-info → parallel_web-0.1.3.dist-info}/RECORD +14 -13
- {parallel_web-0.1.1.dist-info → parallel_web-0.1.3.dist-info}/WHEEL +0 -0
- {parallel_web-0.1.1.dist-info → parallel_web-0.1.3.dist-info}/licenses/LICENSE +0 -0
parallel/__init__.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
+
import typing as _t
|
|
4
|
+
|
|
3
5
|
from . import types
|
|
4
6
|
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes
|
|
5
7
|
from ._utils import file_from_path
|
|
@@ -78,6 +80,9 @@ __all__ = [
|
|
|
78
80
|
"DefaultAsyncHttpxClient",
|
|
79
81
|
]
|
|
80
82
|
|
|
83
|
+
if not _t.TYPE_CHECKING:
|
|
84
|
+
from ._utils._resources_proxy import resources as resources
|
|
85
|
+
|
|
81
86
|
_setup_logging()
|
|
82
87
|
|
|
83
88
|
# Update the __module__ attribute for exported symbols so that
|
parallel/_base_client.py
CHANGED
|
@@ -960,6 +960,9 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
|
|
|
960
960
|
if self.custom_auth is not None:
|
|
961
961
|
kwargs["auth"] = self.custom_auth
|
|
962
962
|
|
|
963
|
+
if options.follow_redirects is not None:
|
|
964
|
+
kwargs["follow_redirects"] = options.follow_redirects
|
|
965
|
+
|
|
963
966
|
log.debug("Sending HTTP Request: %s %s", request.method, request.url)
|
|
964
967
|
|
|
965
968
|
response = None
|
|
@@ -1068,7 +1071,14 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
|
|
|
1068
1071
|
) -> ResponseT:
|
|
1069
1072
|
origin = get_origin(cast_to) or cast_to
|
|
1070
1073
|
|
|
1071
|
-
if
|
|
1074
|
+
if (
|
|
1075
|
+
inspect.isclass(origin)
|
|
1076
|
+
and issubclass(origin, BaseAPIResponse)
|
|
1077
|
+
# we only want to actually return the custom BaseAPIResponse class if we're
|
|
1078
|
+
# returning the raw response, or if we're not streaming SSE, as if we're streaming
|
|
1079
|
+
# SSE then `cast_to` doesn't actively reflect the type we need to parse into
|
|
1080
|
+
and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER)))
|
|
1081
|
+
):
|
|
1072
1082
|
if not issubclass(origin, APIResponse):
|
|
1073
1083
|
raise TypeError(f"API Response types must subclass {APIResponse}; Received {origin}")
|
|
1074
1084
|
|
|
@@ -1460,6 +1470,9 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
|
|
|
1460
1470
|
if self.custom_auth is not None:
|
|
1461
1471
|
kwargs["auth"] = self.custom_auth
|
|
1462
1472
|
|
|
1473
|
+
if options.follow_redirects is not None:
|
|
1474
|
+
kwargs["follow_redirects"] = options.follow_redirects
|
|
1475
|
+
|
|
1463
1476
|
log.debug("Sending HTTP Request: %s %s", request.method, request.url)
|
|
1464
1477
|
|
|
1465
1478
|
response = None
|
|
@@ -1568,7 +1581,14 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
|
|
|
1568
1581
|
) -> ResponseT:
|
|
1569
1582
|
origin = get_origin(cast_to) or cast_to
|
|
1570
1583
|
|
|
1571
|
-
if
|
|
1584
|
+
if (
|
|
1585
|
+
inspect.isclass(origin)
|
|
1586
|
+
and issubclass(origin, BaseAPIResponse)
|
|
1587
|
+
# we only want to actually return the custom BaseAPIResponse class if we're
|
|
1588
|
+
# returning the raw response, or if we're not streaming SSE, as if we're streaming
|
|
1589
|
+
# SSE then `cast_to` doesn't actively reflect the type we need to parse into
|
|
1590
|
+
and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER)))
|
|
1591
|
+
):
|
|
1572
1592
|
if not issubclass(origin, AsyncAPIResponse):
|
|
1573
1593
|
raise TypeError(f"API Response types must subclass {AsyncAPIResponse}; Received {origin}")
|
|
1574
1594
|
|
parallel/_constants.py
CHANGED
|
@@ -5,6 +5,8 @@ import httpx
|
|
|
5
5
|
RAW_RESPONSE_HEADER = "X-Stainless-Raw-Response"
|
|
6
6
|
OVERRIDE_CAST_TO_HEADER = "____stainless_override_cast_to"
|
|
7
7
|
|
|
8
|
+
# default timeout for execution requests which wait for results is 1 hour.
|
|
9
|
+
DEFAULT_EXECUTE_TIMEOUT_SECONDS = 3600
|
|
8
10
|
# default timeout for http requests is 10 minutes.
|
|
9
11
|
DEFAULT_TIMEOUT_SECONDS = 600
|
|
10
12
|
DEFAULT_TIMEOUT = httpx.Timeout(timeout=DEFAULT_TIMEOUT_SECONDS, connect=5.0)
|
parallel/_models.py
CHANGED
|
@@ -737,6 +737,7 @@ class FinalRequestOptionsInput(TypedDict, total=False):
|
|
|
737
737
|
idempotency_key: str
|
|
738
738
|
json_data: Body
|
|
739
739
|
extra_json: AnyMapping
|
|
740
|
+
follow_redirects: bool
|
|
740
741
|
|
|
741
742
|
|
|
742
743
|
@final
|
|
@@ -750,6 +751,7 @@ class FinalRequestOptions(pydantic.BaseModel):
|
|
|
750
751
|
files: Union[HttpxRequestFiles, None] = None
|
|
751
752
|
idempotency_key: Union[str, None] = None
|
|
752
753
|
post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven()
|
|
754
|
+
follow_redirects: Union[bool, None] = None
|
|
753
755
|
|
|
754
756
|
# It should be noted that we cannot use `json` here as that would override
|
|
755
757
|
# a BaseModel method in an incompatible fashion.
|
parallel/_types.py
CHANGED
|
@@ -100,6 +100,7 @@ class RequestOptions(TypedDict, total=False):
|
|
|
100
100
|
params: Query
|
|
101
101
|
extra_json: AnyMapping
|
|
102
102
|
idempotency_key: str
|
|
103
|
+
follow_redirects: bool
|
|
103
104
|
|
|
104
105
|
|
|
105
106
|
# Sentinel class used until PEP 0661 is accepted
|
|
@@ -215,3 +216,4 @@ class _GenericAlias(Protocol):
|
|
|
215
216
|
|
|
216
217
|
class HttpxSendArgs(TypedDict, total=False):
|
|
217
218
|
auth: httpx.Auth
|
|
219
|
+
follow_redirects: bool
|
parallel/_utils/_proxy.py
CHANGED
|
@@ -46,7 +46,10 @@ class LazyProxy(Generic[T], ABC):
|
|
|
46
46
|
@property # type: ignore
|
|
47
47
|
@override
|
|
48
48
|
def __class__(self) -> type: # pyright: ignore
|
|
49
|
-
|
|
49
|
+
try:
|
|
50
|
+
proxied = self.__get_proxied__()
|
|
51
|
+
except Exception:
|
|
52
|
+
return type(self)
|
|
50
53
|
if issubclass(type(proxied), LazyProxy):
|
|
51
54
|
return type(proxied)
|
|
52
55
|
return proxied.__class__
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
from typing_extensions import override
|
|
5
|
+
|
|
6
|
+
from ._proxy import LazyProxy
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ResourcesProxy(LazyProxy[Any]):
|
|
10
|
+
"""A proxy for the `parallel.resources` module.
|
|
11
|
+
|
|
12
|
+
This is used so that we can lazily import `parallel.resources` only when
|
|
13
|
+
needed *and* so that users can just import `parallel` and reference `parallel.resources`
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
@override
|
|
17
|
+
def __load__(self) -> Any:
|
|
18
|
+
import importlib
|
|
19
|
+
|
|
20
|
+
mod = importlib.import_module("parallel.resources")
|
|
21
|
+
return mod
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
resources = ResourcesProxy().__as_proxied__()
|
parallel/_version.py
CHANGED
parallel/lib/_time.py
CHANGED
|
@@ -5,7 +5,7 @@ from typing import Union, Iterator, NoReturn
|
|
|
5
5
|
import httpx
|
|
6
6
|
|
|
7
7
|
from .._types import NotGiven
|
|
8
|
-
from .._constants import
|
|
8
|
+
from .._constants import DEFAULT_EXECUTE_TIMEOUT_SECONDS
|
|
9
9
|
from .._exceptions import APIStatusError, APITimeoutError
|
|
10
10
|
from .._utils._utils import is_given
|
|
11
11
|
|
|
@@ -19,7 +19,7 @@ def prepare_timeout_float(timeout: Union[float, httpx.Timeout, None, NotGiven])
|
|
|
19
19
|
timeout = timeout.read
|
|
20
20
|
|
|
21
21
|
if not is_given(timeout) or timeout is None:
|
|
22
|
-
return
|
|
22
|
+
return DEFAULT_EXECUTE_TIMEOUT_SECONDS
|
|
23
23
|
|
|
24
24
|
return timeout
|
|
25
25
|
|
|
@@ -28,6 +28,24 @@ def _raise_timeout(run_id: str, exc: Union[Exception, None]) -> NoReturn:
|
|
|
28
28
|
raise TimeoutError(f"Fetching task run result for run id {run_id} timed out.") from exc
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
def _is_retryable_error(status_code: int) -> bool:
|
|
32
|
+
"""Determine if an error is retryable.
|
|
33
|
+
|
|
34
|
+
We retry the following HTTP status codes within the SDK:
|
|
35
|
+
- 408 (Request Timeout): The server timed out waiting for the request
|
|
36
|
+
- 503 (Service Unavailable): The server is temporarily unable to handle the request
|
|
37
|
+
- 504 (Gateway Timeout): The gateway server timed out
|
|
38
|
+
|
|
39
|
+
These errors typically indicate temporary issues with the server or network
|
|
40
|
+
that may resolve upon retry. We don't include 429 (Too Many Requests) as this
|
|
41
|
+
indicates rate limiting, which requires backing off rather than immediate retries.
|
|
42
|
+
|
|
43
|
+
Note: This is a low-level retry mechanism within the SDK. Customers may want to
|
|
44
|
+
implement their own retry logic at the application level for other error types.
|
|
45
|
+
"""
|
|
46
|
+
return status_code in (408, 503, 504)
|
|
47
|
+
|
|
48
|
+
|
|
31
49
|
@contextlib.contextmanager
|
|
32
50
|
def timeout_retry_context(run_id: str, deadline: float) -> Iterator[None]:
|
|
33
51
|
"""Context manager for handling timeouts and retries when fetching task run results.
|
|
@@ -49,8 +67,7 @@ def timeout_retry_context(run_id: str, deadline: float) -> Iterator[None]:
|
|
|
49
67
|
exc = e
|
|
50
68
|
continue
|
|
51
69
|
except APIStatusError as e:
|
|
52
|
-
|
|
53
|
-
if e.status_code == 408:
|
|
70
|
+
if _is_retryable_error(e.status_code):
|
|
54
71
|
exc = e
|
|
55
72
|
continue
|
|
56
73
|
raise
|
parallel/resources/task_run.py
CHANGED
|
@@ -42,7 +42,7 @@ class TaskRunResource(SyncAPIResource):
|
|
|
42
42
|
This property can be used as a prefix for any HTTP method call to return
|
|
43
43
|
the raw response object instead of the parsed content.
|
|
44
44
|
|
|
45
|
-
For more information, see https://www.github.com/
|
|
45
|
+
For more information, see https://www.github.com/parallel-web/parallel-sdk-python#accessing-raw-response-data-eg-headers
|
|
46
46
|
"""
|
|
47
47
|
return TaskRunResourceWithRawResponse(self)
|
|
48
48
|
|
|
@@ -51,7 +51,7 @@ class TaskRunResource(SyncAPIResource):
|
|
|
51
51
|
"""
|
|
52
52
|
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
53
53
|
|
|
54
|
-
For more information, see https://www.github.com/
|
|
54
|
+
For more information, see https://www.github.com/parallel-web/parallel-sdk-python#with_streaming_response
|
|
55
55
|
"""
|
|
56
56
|
return TaskRunResourceWithStreamingResponse(self)
|
|
57
57
|
|
|
@@ -317,7 +317,7 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
317
317
|
This property can be used as a prefix for any HTTP method call to return
|
|
318
318
|
the raw response object instead of the parsed content.
|
|
319
319
|
|
|
320
|
-
For more information, see https://www.github.com/
|
|
320
|
+
For more information, see https://www.github.com/parallel-web/parallel-sdk-python#accessing-raw-response-data-eg-headers
|
|
321
321
|
"""
|
|
322
322
|
return AsyncTaskRunResourceWithRawResponse(self)
|
|
323
323
|
|
|
@@ -326,7 +326,7 @@ class AsyncTaskRunResource(AsyncAPIResource):
|
|
|
326
326
|
"""
|
|
327
327
|
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
328
328
|
|
|
329
|
-
For more information, see https://www.github.com/
|
|
329
|
+
For more information, see https://www.github.com/parallel-web/parallel-sdk-python#with_streaming_response
|
|
330
330
|
"""
|
|
331
331
|
return AsyncTaskRunResourceWithStreamingResponse(self)
|
|
332
332
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: parallel-web
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: The official Python library for the Parallel API
|
|
5
|
-
Project-URL: Homepage, https://github.com/
|
|
6
|
-
Project-URL: Repository, https://github.com/
|
|
5
|
+
Project-URL: Homepage, https://github.com/parallel-web/parallel-sdk-python
|
|
6
|
+
Project-URL: Repository, https://github.com/parallel-web/parallel-sdk-python
|
|
7
7
|
Author-email: Parallel <support@parallel.ai>
|
|
8
8
|
License: MIT
|
|
9
9
|
Classifier: Intended Audience :: Developers
|
|
@@ -31,7 +31,7 @@ Description-Content-Type: text/markdown
|
|
|
31
31
|
|
|
32
32
|
# Parallel Python API library
|
|
33
33
|
|
|
34
|
-
[](https://pypi.org/project/parallel-web/)
|
|
34
|
+
[>)](https://pypi.org/project/parallel-web/)
|
|
35
35
|
|
|
36
36
|
The Parallel Python library provides convenient access to the Parallel REST API from any Python 3.8+
|
|
37
37
|
application. The library includes type definitions for all request params and response fields,
|
|
@@ -42,8 +42,8 @@ It is generated with [Stainless](https://www.stainless.com/).
|
|
|
42
42
|
|
|
43
43
|
## Documentation
|
|
44
44
|
|
|
45
|
-
The REST API documentation can be found
|
|
46
|
-
The full API of this Python library can be found in [api.md](https://github.com/
|
|
45
|
+
The REST API documentation can be found in our [docs](https://docs.parallel.ai).
|
|
46
|
+
The full API of this Python library can be found in [api.md](https://github.com/parallel-web/parallel-sdk-python/tree/main/api.md).
|
|
47
47
|
|
|
48
48
|
## Installation
|
|
49
49
|
|
|
@@ -54,7 +54,7 @@ pip install parallel-web
|
|
|
54
54
|
|
|
55
55
|
## Usage
|
|
56
56
|
|
|
57
|
-
The full API of this library can be found in [api.md](https://github.com/
|
|
57
|
+
The full API of this library can be found in [api.md](https://github.com/parallel-web/parallel-sdk-python/tree/main/api.md).
|
|
58
58
|
|
|
59
59
|
```python
|
|
60
60
|
import os
|
|
@@ -69,7 +69,7 @@ run_result = client.task_run.execute(
|
|
|
69
69
|
processor="core",
|
|
70
70
|
output="GDP"
|
|
71
71
|
)
|
|
72
|
-
print(run_result.output)
|
|
72
|
+
print(run_result.output.parsed)
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
While you can provide an `api_key` keyword argument,
|
|
@@ -77,6 +77,11 @@ we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
|
|
|
77
77
|
to add `PARALLEL_API_KEY="My API Key"` to your `.env` file
|
|
78
78
|
so that your API Key is not stored in source control.
|
|
79
79
|
|
|
80
|
+
The API also supports typed inputs and outputs via Pydantic objects. See the relevant
|
|
81
|
+
section on [convenience methods](https://github.com/parallel-web/parallel-sdk-python/tree/main/#convenience-methods).
|
|
82
|
+
|
|
83
|
+
For information on what tasks are and how to specify them, see [our docs](https://docs.parallel.ai/task-api/core-concepts/specify-a-task).
|
|
84
|
+
|
|
80
85
|
## Async usage
|
|
81
86
|
|
|
82
87
|
Simply import `AsyncParallel` instead of `Parallel` and use `await` with each API call:
|
|
@@ -97,7 +102,7 @@ async def main() -> None:
|
|
|
97
102
|
processor="core",
|
|
98
103
|
output="GDP"
|
|
99
104
|
)
|
|
100
|
-
print(run_result.output)
|
|
105
|
+
print(run_result.output.parsed)
|
|
101
106
|
|
|
102
107
|
|
|
103
108
|
if __name__ == "__main__":
|
|
@@ -106,16 +111,17 @@ if __name__ == "__main__":
|
|
|
106
111
|
|
|
107
112
|
To get the best performance out of Parallel's API, we recommend
|
|
108
113
|
using the asynchronous client, especially for executing multiple Task Runs concurrently.
|
|
109
|
-
Functionality between the synchronous and asynchronous clients is identical
|
|
114
|
+
Functionality between the synchronous and asynchronous clients is identical, including
|
|
115
|
+
the convenience methods.
|
|
110
116
|
|
|
111
117
|
## Convenience methods
|
|
112
118
|
|
|
113
119
|
### Execute
|
|
114
120
|
|
|
115
|
-
The `execute` method provides a single call
|
|
116
|
-
polling until
|
|
121
|
+
The `execute` method provides a single call that combines creating a task run,
|
|
122
|
+
polling until completion, and parsing structured outputs (if specified).
|
|
117
123
|
|
|
118
|
-
If an output type
|
|
124
|
+
If an output type that inherits from `BaseModel` is
|
|
119
125
|
specified in the call to `.execute()`, the response content will be parsed into an
|
|
120
126
|
instance of the provided output type. The parsed output can be accessed via the
|
|
121
127
|
`parsed` property on the output field of the response.
|
|
@@ -146,15 +152,15 @@ async def main() -> None:
|
|
|
146
152
|
processor="core",
|
|
147
153
|
output="GDP"
|
|
148
154
|
)
|
|
149
|
-
print(run_result.output)
|
|
155
|
+
print(run_result.output.parsed)
|
|
150
156
|
|
|
151
157
|
|
|
152
158
|
if __name__ == "__main__":
|
|
153
159
|
asyncio.run(main())
|
|
154
160
|
```
|
|
155
161
|
|
|
156
|
-
The async client
|
|
157
|
-
To
|
|
162
|
+
The async client lets you create multiple task runs without blocking.
|
|
163
|
+
To submit several at once, call `execute()` and gather the results at the end.
|
|
158
164
|
|
|
159
165
|
```python
|
|
160
166
|
import asyncio
|
|
@@ -212,9 +218,51 @@ if __name__ == "__main__":
|
|
|
212
218
|
asyncio.run(main())
|
|
213
219
|
```
|
|
214
220
|
|
|
215
|
-
|
|
221
|
+
#### `execute()` vs `create()`
|
|
222
|
+
|
|
223
|
+
The `execute` and `create` methods differ slightly in their signatures and
|
|
224
|
+
behavior — `create` requires a Task Spec object that contains the output schema,
|
|
225
|
+
while `execute` accepts an output schema as a top‑level parameter. `execute` is
|
|
226
|
+
also a one‑shot method that combines creation, polling, and parsing for you.
|
|
227
|
+
|
|
228
|
+
Use `create` when you want a run ID immediately and prefer to control polling
|
|
229
|
+
yourself. `execute` is best for one‑shot task execution and for typed inputs and
|
|
230
|
+
outputs — note that no outputs are available until the call finishes. Finally, for
|
|
231
|
+
the output of `execute`, parsed content is available via `run_result.output.parsed`.
|
|
232
|
+
|
|
233
|
+
Both `execute` and `create` validate inputs when appropriate input types are
|
|
234
|
+
provided. For `execute`, validation happens when a pydantic input is provided. For
|
|
235
|
+
`create`, validation occurs when the input schema is specified inside the task spec
|
|
236
|
+
parameter. Additionally, in both calls, the un-parsed result content is accessible via
|
|
237
|
+
the `run_result.output.content`.
|
|
238
|
+
|
|
239
|
+
## Frequently Asked Questions
|
|
240
|
+
|
|
241
|
+
**Does the Task API accept prompts or objectives?**
|
|
242
|
+
|
|
243
|
+
No, there are no `objective` or `prompt` parameters that can be specified for calls to
|
|
244
|
+
the Task API. Instead, provide any directives or instructions via the schemas. For
|
|
245
|
+
more information, check [our docs](https://docs.parallel.ai/task-api/core-concepts/specify-a-task).
|
|
246
|
+
|
|
247
|
+
**Can I access beta parameters or endpoints via the SDK?**
|
|
248
|
+
|
|
249
|
+
The SDK currently does not support beta parameters in the Task API. You can consider
|
|
250
|
+
using [custom requests](https://github.com/parallel-web/parallel-sdk-python/tree/main/#making-customundocumented-requests) in conjunction with
|
|
251
|
+
[low level APIs](https://github.com/parallel-web/parallel-sdk-python/tree/main/#lowlevel-api-access).
|
|
252
|
+
|
|
253
|
+
**Can I specify a timeout for API calls?**
|
|
254
|
+
|
|
255
|
+
Yes, all methods support a timeout. For more information, see [Timeouts](https://github.com/parallel-web/parallel-sdk-python/tree/main/#timeouts).
|
|
256
|
+
|
|
257
|
+
**Can I specify retries via the SDK?**
|
|
258
|
+
|
|
259
|
+
Yes, errors can be retried via the SDK — the default retry count is 2. The maximum number
|
|
260
|
+
of retries can be configured at the client level. For information on which errors
|
|
261
|
+
are automatically retried and how to configure retry settings, see [Retries](https://github.com/parallel-web/parallel-sdk-python/tree/main/#retries).
|
|
262
|
+
|
|
263
|
+
## Low‑level API access
|
|
216
264
|
|
|
217
|
-
The library also provides
|
|
265
|
+
The library also provides low‑level access to the Parallel API.
|
|
218
266
|
|
|
219
267
|
```python
|
|
220
268
|
from parallel import Parallel
|
|
@@ -262,13 +310,13 @@ task_run = client.task_run.create(
|
|
|
262
310
|
)
|
|
263
311
|
|
|
264
312
|
run_result = client.task_run.result(task_run.run_id)
|
|
265
|
-
print(run_result.output)
|
|
313
|
+
print(run_result.output.content)
|
|
266
314
|
```
|
|
267
315
|
|
|
268
316
|
For more information, please check out the relevant section in our docs:
|
|
269
317
|
|
|
270
|
-
- [Task Spec](https://docs.parallel.ai/core-concepts/task
|
|
271
|
-
- [Task Runs](https://docs.parallel.ai/core-concepts/task-
|
|
318
|
+
- [Task Spec](https://docs.parallel.ai/task-api/core-concepts/specify-a-task)
|
|
319
|
+
- [Task Runs](https://docs.parallel.ai/task-api/core-concepts/execute-task-run)
|
|
272
320
|
|
|
273
321
|
## Handling errors
|
|
274
322
|
|
|
@@ -343,7 +391,7 @@ client.with_options(max_retries=5).task_run.execute(
|
|
|
343
391
|
### Timeouts
|
|
344
392
|
|
|
345
393
|
By default requests time out after 1 minute. You can configure this with a `timeout` option,
|
|
346
|
-
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
|
|
394
|
+
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:
|
|
347
395
|
|
|
348
396
|
```python
|
|
349
397
|
from parallel import Parallel
|
|
@@ -369,7 +417,7 @@ client.with_options(timeout=5.0).task_run.execute(
|
|
|
369
417
|
|
|
370
418
|
On timeout, an `APITimeoutError` is thrown.
|
|
371
419
|
|
|
372
|
-
Note that requests that time out are [retried twice by default](https://github.com/
|
|
420
|
+
Note that requests that time out are [retried twice by default](https://github.com/parallel-web/parallel-sdk-python/tree/main/#retries).
|
|
373
421
|
|
|
374
422
|
## Advanced
|
|
375
423
|
|
|
@@ -416,9 +464,9 @@ task_run = response.parse() # get the object that `task_run.execute()` would ha
|
|
|
416
464
|
print(task_run.output)
|
|
417
465
|
```
|
|
418
466
|
|
|
419
|
-
These methods return an [`APIResponse`](https://github.com/
|
|
467
|
+
These methods return an [`APIResponse`](https://github.com/parallel-web/parallel-sdk-python/tree/main/src/parallel/_response.py) object.
|
|
420
468
|
|
|
421
|
-
The async client returns an [`AsyncAPIResponse`](https://github.com/
|
|
469
|
+
The async client returns an [`AsyncAPIResponse`](https://github.com/parallel-web/parallel-sdk-python/tree/main/src/parallel/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
|
|
422
470
|
|
|
423
471
|
#### `.with_streaming_response`
|
|
424
472
|
|
|
@@ -526,7 +574,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
526
574
|
|
|
527
575
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
528
576
|
|
|
529
|
-
We are keen for your feedback; please open an [issue](https://www.github.com/
|
|
577
|
+
We are keen for your feedback; please open an [issue](https://www.github.com/parallel-web/parallel-sdk-python/issues) with questions, bugs, or suggestions.
|
|
530
578
|
|
|
531
579
|
### Determining the installed version
|
|
532
580
|
|
|
@@ -545,4 +593,4 @@ Python 3.8 or higher.
|
|
|
545
593
|
|
|
546
594
|
## Contributing
|
|
547
595
|
|
|
548
|
-
See [the contributing documentation](https://github.com/
|
|
596
|
+
See [the contributing documentation](https://github.com/parallel-web/parallel-sdk-python/tree/main/./CONTRIBUTING.md).
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
parallel/__init__.py,sha256=
|
|
2
|
-
parallel/_base_client.py,sha256=
|
|
1
|
+
parallel/__init__.py,sha256=DLcZySDPIMWxygZrS91n0h7XUblDa7R2CKSqJCeBD-U,2587
|
|
2
|
+
parallel/_base_client.py,sha256=CvhCKe_bvHxjG_KkjU7MN8epnRjDAoZercR16F7hKXo,65886
|
|
3
3
|
parallel/_client.py,sha256=-33nTbpzQe0MaMSXkPisZdlPG_phXweSGfssI4UXIKQ,15024
|
|
4
4
|
parallel/_compat.py,sha256=Bdw3skNpgAyCAWXJRUwTLiM0lOD1sLHEFKtw7peWp5U,6981
|
|
5
|
-
parallel/_constants.py,sha256=
|
|
5
|
+
parallel/_constants.py,sha256=B00HbROOxQXqSFOIFQjSmdePfscyYNuXyY__j2qBljg,681
|
|
6
6
|
parallel/_exceptions.py,sha256=lP7_D_HALN-Nt5bfw4AefEB7tYkrQ8ZcjCRdxm_HrsQ,3224
|
|
7
7
|
parallel/_files.py,sha256=mf4dOgL4b0ryyZlbqLhggD3GVgDf6XxdGFAgce01ugE,3549
|
|
8
|
-
parallel/_models.py,sha256=
|
|
8
|
+
parallel/_models.py,sha256=G1vczEodX0vUySeVKbF-mbzlaObNL1oVAYH4c65agRk,29131
|
|
9
9
|
parallel/_qs.py,sha256=AOkSz4rHtK4YI3ZU_kzea-zpwBUgEY8WniGmTPyEimc,4846
|
|
10
10
|
parallel/_resource.py,sha256=QvY8l_r03hNBsFTTn3g7Pkx8OrDwIwROHaSEViWcYLA,1112
|
|
11
11
|
parallel/_response.py,sha256=zJKnQ9YzrMZCTPWis4CdyGCAH0kzT4m1OHE74jiF0jA,28800
|
|
12
12
|
parallel/_streaming.py,sha256=vH45vK3-83ruFalbvSgpE70zfwy8fjW9UwrO1TwjIfE,10108
|
|
13
|
-
parallel/_types.py,sha256=
|
|
14
|
-
parallel/_version.py,sha256=
|
|
13
|
+
parallel/_types.py,sha256=gdnumvz_C0ka1W865rehBsLCOgZyyHpKRedjJg7uRPY,6199
|
|
14
|
+
parallel/_version.py,sha256=KMXAJ_Bhy6F94HtkIbgFS_dFgeIsvbC6RKi-WdhkV28,160
|
|
15
15
|
parallel/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
parallel/_utils/__init__.py,sha256=Z5F2puD-cRsBEwlAuuuXDuIuKuJyLhtg0667MRHeBj4,2084
|
|
17
17
|
parallel/_utils/_logs.py,sha256=5tqZJRHHRqxJfftED6vN1CHcwhRZDSvzy9SaxozEAe4,780
|
|
18
|
-
parallel/_utils/_proxy.py,sha256=
|
|
18
|
+
parallel/_utils/_proxy.py,sha256=aglnj2yBTDyGX9Akk2crZHrl10oqRmceUy2Zp008XEs,1975
|
|
19
19
|
parallel/_utils/_reflection.py,sha256=ZmGkIgT_PuwedyNBrrKGbxoWtkpytJNU1uU4QHnmEMU,1364
|
|
20
|
+
parallel/_utils/_resources_proxy.py,sha256=xx_chZr_cBmnGMejQaqdjjzS6gjyOBjVARwb2lM7qm4,599
|
|
20
21
|
parallel/_utils/_streams.py,sha256=SMC90diFFecpEg_zgDRVbdR3hSEIgVVij4taD-noMLM,289
|
|
21
22
|
parallel/_utils/_sync.py,sha256=TpGLrrhRNWTJtODNE6Fup3_k7zrWm1j2RlirzBwre-0,2862
|
|
22
23
|
parallel/_utils/_transform.py,sha256=n7kskEWz6o__aoNvhFoGVyDoalNe6mJwp-g7BWkdj88,15617
|
|
@@ -25,12 +26,12 @@ parallel/_utils/_utils.py,sha256=nJWF6GJgM2imb1AYa1nZoE1f-Alo1EI0Y8L_q3a1gkw,123
|
|
|
25
26
|
parallel/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
|
|
26
27
|
parallel/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
28
|
parallel/lib/_pydantic.py,sha256=B_-msp3_jrPP09s-f73Xv4WEG212ECDfc0a_Gf-YZGE,1115
|
|
28
|
-
parallel/lib/_time.py,sha256=
|
|
29
|
+
parallel/lib/_time.py,sha256=54M_YhwW8WUa2KEUjYNdt3GkyQC9s_3u36-IH5hZr2U,2558
|
|
29
30
|
parallel/lib/_parsing/__init__.py,sha256=aEM9F2sU4s-CFpQgjydjfCAdxpusJ81jXI6KCoB8VPs,150
|
|
30
31
|
parallel/lib/_parsing/_task_run_result.py,sha256=9o95RcH4bX0UbI7ow5bnECrXMS6Ll0SEQR4leTK3VQU,3608
|
|
31
32
|
parallel/lib/_parsing/_task_spec.py,sha256=XkNWo2Ovu-anld8PAOIsi722vOXbDf2ex4p9rwWW51I,3067
|
|
32
33
|
parallel/resources/__init__.py,sha256=jGILtGZMcUjnm_PAOAkggRZlretqp_r24lMj7qFWqIg,566
|
|
33
|
-
parallel/resources/task_run.py,sha256=
|
|
34
|
+
parallel/resources/task_run.py,sha256=5FEtuqwYbR1Ict8s8zpkFHF6b0XGtgxVBxlnvKMfc0Y,25327
|
|
34
35
|
parallel/types/__init__.py,sha256=7EXEF1xwgzRtPbtywm1_PnOzShi_mN3TfU8p_PErz5s,653
|
|
35
36
|
parallel/types/json_schema_param.py,sha256=rn_85_uPZYkLYLZiM5erOuQ_trY4DcoB3XEpP4uvqyw,457
|
|
36
37
|
parallel/types/parsed_task_run_result.py,sha256=Qw_QFQNmMcykdBKlMnx6hl5cua5wwv5BZEs3Oo3_5NE,1098
|
|
@@ -40,7 +41,7 @@ parallel/types/task_run_result.py,sha256=yd3Lz_YzCQGe5ynK5iI6J17tAs5nSG7FUJ3fSLO
|
|
|
40
41
|
parallel/types/task_run_result_params.py,sha256=tL4CK5c0-Wo21O1pmT4pDvwzG-svtEwYujyCp0ZgATs,360
|
|
41
42
|
parallel/types/task_spec_param.py,sha256=qTENHBp7vRg-VDzK8HsLpTn3EJWIV0UVQaf45r9SfCs,1179
|
|
42
43
|
parallel/types/text_schema_param.py,sha256=M9WEl2aOh4_hNSdGm2BOmtm1VGqxxTh3f-Hs4OB4aCQ,445
|
|
43
|
-
parallel_web-0.1.
|
|
44
|
-
parallel_web-0.1.
|
|
45
|
-
parallel_web-0.1.
|
|
46
|
-
parallel_web-0.1.
|
|
44
|
+
parallel_web-0.1.3.dist-info/METADATA,sha256=fuS5BSxEaWrVTBlSb0OCUkUIgxCVP13QEqpqc9YR2TM,20379
|
|
45
|
+
parallel_web-0.1.3.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
46
|
+
parallel_web-0.1.3.dist-info/licenses/LICENSE,sha256=1rFsV0HhxaZBP55JM8Cu2w0Bw-uxTFtyTja_DE94oEM,1048
|
|
47
|
+
parallel_web-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|