parallel-web 0.1.2__py3-none-any.whl → 0.2.0__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 +2 -1
- parallel/_base_client.py +34 -2
- parallel/_client.py +9 -0
- parallel/_compat.py +1 -0
- parallel/_constants.py +2 -0
- parallel/_files.py +4 -4
- parallel/_models.py +32 -8
- parallel/_types.py +35 -1
- parallel/_utils/__init__.py +1 -0
- parallel/_utils/_typing.py +5 -0
- parallel/_version.py +1 -1
- parallel/lib/_pydantic.py +1 -0
- parallel/lib/_time.py +2 -2
- parallel/resources/__init__.py +14 -0
- parallel/resources/beta/__init__.py +47 -0
- parallel/resources/beta/beta.py +301 -0
- parallel/resources/beta/task_group.py +632 -0
- parallel/resources/beta/task_run.py +499 -0
- parallel/resources/task_run.py +47 -18
- parallel/types/__init__.py +15 -0
- parallel/types/auto_schema.py +13 -0
- parallel/types/auto_schema_param.py +12 -0
- parallel/types/beta/__init__.py +30 -0
- parallel/types/beta/beta_run_input.py +63 -0
- parallel/types/beta/beta_run_input_param.py +65 -0
- parallel/types/beta/beta_search_params.py +47 -0
- parallel/types/beta/beta_task_run_result.py +74 -0
- parallel/types/beta/error_event.py +16 -0
- parallel/types/beta/mcp_server.py +25 -0
- parallel/types/beta/mcp_server_param.py +25 -0
- parallel/types/beta/mcp_tool_call.py +27 -0
- parallel/types/beta/parallel_beta_param.py +12 -0
- parallel/types/beta/search_result.py +16 -0
- parallel/types/beta/task_group.py +24 -0
- parallel/types/beta/task_group_add_runs_params.py +30 -0
- parallel/types/beta/task_group_create_params.py +13 -0
- parallel/types/beta/task_group_events_params.py +16 -0
- parallel/types/beta/task_group_events_response.py +28 -0
- parallel/types/beta/task_group_get_runs_params.py +18 -0
- parallel/types/beta/task_group_get_runs_response.py +12 -0
- parallel/types/beta/task_group_run_response.py +30 -0
- parallel/types/beta/task_group_status.py +27 -0
- parallel/types/beta/task_run_create_params.py +70 -0
- parallel/types/beta/task_run_event.py +32 -0
- parallel/types/beta/task_run_events_response.py +58 -0
- parallel/types/beta/task_run_result_params.py +18 -0
- parallel/types/beta/web_search_result.py +18 -0
- parallel/types/beta/webhook.py +16 -0
- parallel/types/beta/webhook_param.py +16 -0
- parallel/types/citation.py +21 -0
- parallel/types/field_basis.py +25 -0
- parallel/types/json_schema.py +16 -0
- parallel/types/json_schema_param.py +2 -1
- parallel/types/parsed_task_run_result.py +13 -4
- parallel/types/shared/__init__.py +6 -0
- parallel/types/shared/error_object.py +18 -0
- parallel/types/shared/error_response.py +16 -0
- parallel/types/shared/source_policy.py +21 -0
- parallel/types/shared/warning.py +22 -0
- parallel/types/shared_params/__init__.py +3 -0
- parallel/types/shared_params/source_policy.py +22 -0
- parallel/types/task_run.py +17 -18
- parallel/types/task_run_create_params.py +12 -3
- parallel/types/task_run_json_output.py +46 -0
- parallel/types/task_run_result.py +24 -94
- parallel/types/task_run_text_output.py +37 -0
- parallel/types/task_spec.py +31 -0
- parallel/types/task_spec_param.py +3 -2
- parallel/types/text_schema.py +16 -0
- {parallel_web-0.1.2.dist-info → parallel_web-0.2.0.dist-info}/METADATA +48 -136
- parallel_web-0.2.0.dist-info/RECORD +94 -0
- parallel_web-0.1.2.dist-info/RECORD +0 -47
- {parallel_web-0.1.2.dist-info → parallel_web-0.2.0.dist-info}/WHEEL +0 -0
- {parallel_web-0.1.2.dist-info → parallel_web-0.2.0.dist-info}/licenses/LICENSE +0 -0
parallel/__init__.py
CHANGED
|
@@ -36,7 +36,7 @@ from ._exceptions import (
|
|
|
36
36
|
UnprocessableEntityError,
|
|
37
37
|
APIResponseValidationError,
|
|
38
38
|
)
|
|
39
|
-
from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
|
|
39
|
+
from ._base_client import DefaultHttpxClient, DefaultAioHttpClient, DefaultAsyncHttpxClient
|
|
40
40
|
from ._utils._logs import setup_logging as _setup_logging
|
|
41
41
|
|
|
42
42
|
__all__ = [
|
|
@@ -78,6 +78,7 @@ __all__ = [
|
|
|
78
78
|
"DEFAULT_CONNECTION_LIMITS",
|
|
79
79
|
"DefaultHttpxClient",
|
|
80
80
|
"DefaultAsyncHttpxClient",
|
|
81
|
+
"DefaultAioHttpClient",
|
|
81
82
|
]
|
|
82
83
|
|
|
83
84
|
if not _t.TYPE_CHECKING:
|
parallel/_base_client.py
CHANGED
|
@@ -529,6 +529,18 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
|
529
529
|
# work around https://github.com/encode/httpx/discussions/2880
|
|
530
530
|
kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}
|
|
531
531
|
|
|
532
|
+
is_body_allowed = options.method.lower() != "get"
|
|
533
|
+
|
|
534
|
+
if is_body_allowed:
|
|
535
|
+
if isinstance(json_data, bytes):
|
|
536
|
+
kwargs["content"] = json_data
|
|
537
|
+
else:
|
|
538
|
+
kwargs["json"] = json_data if is_given(json_data) else None
|
|
539
|
+
kwargs["files"] = files
|
|
540
|
+
else:
|
|
541
|
+
headers.pop("Content-Type", None)
|
|
542
|
+
kwargs.pop("data", None)
|
|
543
|
+
|
|
532
544
|
# TODO: report this error to httpx
|
|
533
545
|
return self._client.build_request( # pyright: ignore[reportUnknownMemberType]
|
|
534
546
|
headers=headers,
|
|
@@ -540,8 +552,6 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
|
540
552
|
# so that passing a `TypedDict` doesn't cause an error.
|
|
541
553
|
# https://github.com/microsoft/pyright/issues/3526#event-6715453066
|
|
542
554
|
params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None,
|
|
543
|
-
json=json_data if is_given(json_data) else None,
|
|
544
|
-
files=files,
|
|
545
555
|
**kwargs,
|
|
546
556
|
)
|
|
547
557
|
|
|
@@ -1289,6 +1299,24 @@ class _DefaultAsyncHttpxClient(httpx.AsyncClient):
|
|
|
1289
1299
|
super().__init__(**kwargs)
|
|
1290
1300
|
|
|
1291
1301
|
|
|
1302
|
+
try:
|
|
1303
|
+
import httpx_aiohttp
|
|
1304
|
+
except ImportError:
|
|
1305
|
+
|
|
1306
|
+
class _DefaultAioHttpClient(httpx.AsyncClient):
|
|
1307
|
+
def __init__(self, **_kwargs: Any) -> None:
|
|
1308
|
+
raise RuntimeError("To use the aiohttp client you must have installed the package with the `aiohttp` extra")
|
|
1309
|
+
else:
|
|
1310
|
+
|
|
1311
|
+
class _DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
|
|
1312
|
+
def __init__(self, **kwargs: Any) -> None:
|
|
1313
|
+
kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
|
|
1314
|
+
kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
|
|
1315
|
+
kwargs.setdefault("follow_redirects", True)
|
|
1316
|
+
|
|
1317
|
+
super().__init__(**kwargs)
|
|
1318
|
+
|
|
1319
|
+
|
|
1292
1320
|
if TYPE_CHECKING:
|
|
1293
1321
|
DefaultAsyncHttpxClient = httpx.AsyncClient
|
|
1294
1322
|
"""An alias to `httpx.AsyncClient` that provides the same defaults that this SDK
|
|
@@ -1297,8 +1325,12 @@ if TYPE_CHECKING:
|
|
|
1297
1325
|
This is useful because overriding the `http_client` with your own instance of
|
|
1298
1326
|
`httpx.AsyncClient` will result in httpx's defaults being used, not ours.
|
|
1299
1327
|
"""
|
|
1328
|
+
|
|
1329
|
+
DefaultAioHttpClient = httpx.AsyncClient
|
|
1330
|
+
"""An alias to `httpx.AsyncClient` that changes the default HTTP transport to `aiohttp`."""
|
|
1300
1331
|
else:
|
|
1301
1332
|
DefaultAsyncHttpxClient = _DefaultAsyncHttpxClient
|
|
1333
|
+
DefaultAioHttpClient = _DefaultAioHttpClient
|
|
1302
1334
|
|
|
1303
1335
|
|
|
1304
1336
|
class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
|
parallel/_client.py
CHANGED
|
@@ -29,6 +29,7 @@ from ._base_client import (
|
|
|
29
29
|
SyncAPIClient,
|
|
30
30
|
AsyncAPIClient,
|
|
31
31
|
)
|
|
32
|
+
from .resources.beta import beta
|
|
32
33
|
|
|
33
34
|
__all__ = [
|
|
34
35
|
"Timeout",
|
|
@@ -44,6 +45,7 @@ __all__ = [
|
|
|
44
45
|
|
|
45
46
|
class Parallel(SyncAPIClient):
|
|
46
47
|
task_run: task_run.TaskRunResource
|
|
48
|
+
beta: beta.BetaResource
|
|
47
49
|
with_raw_response: ParallelWithRawResponse
|
|
48
50
|
with_streaming_response: ParallelWithStreamedResponse
|
|
49
51
|
|
|
@@ -102,6 +104,7 @@ class Parallel(SyncAPIClient):
|
|
|
102
104
|
)
|
|
103
105
|
|
|
104
106
|
self.task_run = task_run.TaskRunResource(self)
|
|
107
|
+
self.beta = beta.BetaResource(self)
|
|
105
108
|
self.with_raw_response = ParallelWithRawResponse(self)
|
|
106
109
|
self.with_streaming_response = ParallelWithStreamedResponse(self)
|
|
107
110
|
|
|
@@ -212,6 +215,7 @@ class Parallel(SyncAPIClient):
|
|
|
212
215
|
|
|
213
216
|
class AsyncParallel(AsyncAPIClient):
|
|
214
217
|
task_run: task_run.AsyncTaskRunResource
|
|
218
|
+
beta: beta.AsyncBetaResource
|
|
215
219
|
with_raw_response: AsyncParallelWithRawResponse
|
|
216
220
|
with_streaming_response: AsyncParallelWithStreamedResponse
|
|
217
221
|
|
|
@@ -270,6 +274,7 @@ class AsyncParallel(AsyncAPIClient):
|
|
|
270
274
|
)
|
|
271
275
|
|
|
272
276
|
self.task_run = task_run.AsyncTaskRunResource(self)
|
|
277
|
+
self.beta = beta.AsyncBetaResource(self)
|
|
273
278
|
self.with_raw_response = AsyncParallelWithRawResponse(self)
|
|
274
279
|
self.with_streaming_response = AsyncParallelWithStreamedResponse(self)
|
|
275
280
|
|
|
@@ -381,21 +386,25 @@ class AsyncParallel(AsyncAPIClient):
|
|
|
381
386
|
class ParallelWithRawResponse:
|
|
382
387
|
def __init__(self, client: Parallel) -> None:
|
|
383
388
|
self.task_run = task_run.TaskRunResourceWithRawResponse(client.task_run)
|
|
389
|
+
self.beta = beta.BetaResourceWithRawResponse(client.beta)
|
|
384
390
|
|
|
385
391
|
|
|
386
392
|
class AsyncParallelWithRawResponse:
|
|
387
393
|
def __init__(self, client: AsyncParallel) -> None:
|
|
388
394
|
self.task_run = task_run.AsyncTaskRunResourceWithRawResponse(client.task_run)
|
|
395
|
+
self.beta = beta.AsyncBetaResourceWithRawResponse(client.beta)
|
|
389
396
|
|
|
390
397
|
|
|
391
398
|
class ParallelWithStreamedResponse:
|
|
392
399
|
def __init__(self, client: Parallel) -> None:
|
|
393
400
|
self.task_run = task_run.TaskRunResourceWithStreamingResponse(client.task_run)
|
|
401
|
+
self.beta = beta.BetaResourceWithStreamingResponse(client.beta)
|
|
394
402
|
|
|
395
403
|
|
|
396
404
|
class AsyncParallelWithStreamedResponse:
|
|
397
405
|
def __init__(self, client: AsyncParallel) -> None:
|
|
398
406
|
self.task_run = task_run.AsyncTaskRunResourceWithStreamingResponse(client.task_run)
|
|
407
|
+
self.beta = beta.AsyncBetaResourceWithStreamingResponse(client.beta)
|
|
399
408
|
|
|
400
409
|
|
|
401
410
|
Client = Parallel
|
parallel/_compat.py
CHANGED
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/_files.py
CHANGED
|
@@ -69,12 +69,12 @@ def _transform_file(file: FileTypes) -> HttpxFileTypes:
|
|
|
69
69
|
return file
|
|
70
70
|
|
|
71
71
|
if is_tuple_t(file):
|
|
72
|
-
return (file[0],
|
|
72
|
+
return (file[0], read_file_content(file[1]), *file[2:])
|
|
73
73
|
|
|
74
74
|
raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple")
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
def
|
|
77
|
+
def read_file_content(file: FileContent) -> HttpxFileContent:
|
|
78
78
|
if isinstance(file, os.PathLike):
|
|
79
79
|
return pathlib.Path(file).read_bytes()
|
|
80
80
|
return file
|
|
@@ -111,12 +111,12 @@ async def _async_transform_file(file: FileTypes) -> HttpxFileTypes:
|
|
|
111
111
|
return file
|
|
112
112
|
|
|
113
113
|
if is_tuple_t(file):
|
|
114
|
-
return (file[0], await
|
|
114
|
+
return (file[0], await async_read_file_content(file[1]), *file[2:])
|
|
115
115
|
|
|
116
116
|
raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple")
|
|
117
117
|
|
|
118
118
|
|
|
119
|
-
async def
|
|
119
|
+
async def async_read_file_content(file: FileContent) -> HttpxFileContent:
|
|
120
120
|
if isinstance(file, os.PathLike):
|
|
121
121
|
return await anyio.Path(file).read_bytes()
|
|
122
122
|
|
parallel/_models.py
CHANGED
|
@@ -2,9 +2,10 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
import inspect
|
|
5
|
-
from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, cast
|
|
5
|
+
from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, Optional, cast
|
|
6
6
|
from datetime import date, datetime
|
|
7
7
|
from typing_extensions import (
|
|
8
|
+
List,
|
|
8
9
|
Unpack,
|
|
9
10
|
Literal,
|
|
10
11
|
ClassVar,
|
|
@@ -207,14 +208,18 @@ class BaseModel(pydantic.BaseModel):
|
|
|
207
208
|
else:
|
|
208
209
|
fields_values[name] = field_get_default(field)
|
|
209
210
|
|
|
211
|
+
extra_field_type = _get_extra_fields_type(__cls)
|
|
212
|
+
|
|
210
213
|
_extra = {}
|
|
211
214
|
for key, value in values.items():
|
|
212
215
|
if key not in model_fields:
|
|
216
|
+
parsed = construct_type(value=value, type_=extra_field_type) if extra_field_type is not None else value
|
|
217
|
+
|
|
213
218
|
if PYDANTIC_V2:
|
|
214
|
-
_extra[key] =
|
|
219
|
+
_extra[key] = parsed
|
|
215
220
|
else:
|
|
216
221
|
_fields_set.add(key)
|
|
217
|
-
fields_values[key] =
|
|
222
|
+
fields_values[key] = parsed
|
|
218
223
|
|
|
219
224
|
object.__setattr__(m, "__dict__", fields_values)
|
|
220
225
|
|
|
@@ -299,7 +304,7 @@ class BaseModel(pydantic.BaseModel):
|
|
|
299
304
|
exclude_none=exclude_none,
|
|
300
305
|
)
|
|
301
306
|
|
|
302
|
-
return cast(dict[str, Any], json_safe(dumped)) if mode == "json" else dumped
|
|
307
|
+
return cast("dict[str, Any]", json_safe(dumped)) if mode == "json" else dumped
|
|
303
308
|
|
|
304
309
|
@override
|
|
305
310
|
def model_dump_json(
|
|
@@ -366,7 +371,24 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
|
|
|
366
371
|
if type_ is None:
|
|
367
372
|
raise RuntimeError(f"Unexpected field type is None for {key}")
|
|
368
373
|
|
|
369
|
-
return construct_type(value=value, type_=type_)
|
|
374
|
+
return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None))
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def _get_extra_fields_type(cls: type[pydantic.BaseModel]) -> type | None:
|
|
378
|
+
if not PYDANTIC_V2:
|
|
379
|
+
# TODO
|
|
380
|
+
return None
|
|
381
|
+
|
|
382
|
+
schema = cls.__pydantic_core_schema__
|
|
383
|
+
if schema["type"] == "model":
|
|
384
|
+
fields = schema["schema"]
|
|
385
|
+
if fields["type"] == "model-fields":
|
|
386
|
+
extras = fields.get("extras_schema")
|
|
387
|
+
if extras and "cls" in extras:
|
|
388
|
+
# mypy can't narrow the type
|
|
389
|
+
return extras["cls"] # type: ignore[no-any-return]
|
|
390
|
+
|
|
391
|
+
return None
|
|
370
392
|
|
|
371
393
|
|
|
372
394
|
def is_basemodel(type_: type) -> bool:
|
|
@@ -420,7 +442,7 @@ def construct_type_unchecked(*, value: object, type_: type[_T]) -> _T:
|
|
|
420
442
|
return cast(_T, construct_type(value=value, type_=type_))
|
|
421
443
|
|
|
422
444
|
|
|
423
|
-
def construct_type(*, value: object, type_: object) -> object:
|
|
445
|
+
def construct_type(*, value: object, type_: object, metadata: Optional[List[Any]] = None) -> object:
|
|
424
446
|
"""Loose coercion to the expected type with construction of nested values.
|
|
425
447
|
|
|
426
448
|
If the given value does not match the expected type then it is returned as-is.
|
|
@@ -438,8 +460,10 @@ def construct_type(*, value: object, type_: object) -> object:
|
|
|
438
460
|
type_ = type_.__value__ # type: ignore[unreachable]
|
|
439
461
|
|
|
440
462
|
# unwrap `Annotated[T, ...]` -> `T`
|
|
441
|
-
if
|
|
442
|
-
meta: tuple[Any, ...] =
|
|
463
|
+
if metadata is not None and len(metadata) > 0:
|
|
464
|
+
meta: tuple[Any, ...] = tuple(metadata)
|
|
465
|
+
elif is_annotated_type(type_):
|
|
466
|
+
meta = get_args(type_)[1:]
|
|
443
467
|
type_ = extract_type_arg(type_, 0)
|
|
444
468
|
else:
|
|
445
469
|
meta = tuple()
|
parallel/_types.py
CHANGED
|
@@ -13,10 +13,21 @@ from typing import (
|
|
|
13
13
|
Mapping,
|
|
14
14
|
TypeVar,
|
|
15
15
|
Callable,
|
|
16
|
+
Iterator,
|
|
16
17
|
Optional,
|
|
17
18
|
Sequence,
|
|
18
19
|
)
|
|
19
|
-
from typing_extensions import
|
|
20
|
+
from typing_extensions import (
|
|
21
|
+
Set,
|
|
22
|
+
Literal,
|
|
23
|
+
Protocol,
|
|
24
|
+
TypeAlias,
|
|
25
|
+
TypedDict,
|
|
26
|
+
SupportsIndex,
|
|
27
|
+
overload,
|
|
28
|
+
override,
|
|
29
|
+
runtime_checkable,
|
|
30
|
+
)
|
|
20
31
|
|
|
21
32
|
import httpx
|
|
22
33
|
import pydantic
|
|
@@ -217,3 +228,26 @@ class _GenericAlias(Protocol):
|
|
|
217
228
|
class HttpxSendArgs(TypedDict, total=False):
|
|
218
229
|
auth: httpx.Auth
|
|
219
230
|
follow_redirects: bool
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
_T_co = TypeVar("_T_co", covariant=True)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
if TYPE_CHECKING:
|
|
237
|
+
# This works because str.__contains__ does not accept object (either in typeshed or at runtime)
|
|
238
|
+
# https://github.com/hauntsaninja/useful_types/blob/5e9710f3875107d068e7679fd7fec9cfab0eff3b/useful_types/__init__.py#L285
|
|
239
|
+
class SequenceNotStr(Protocol[_T_co]):
|
|
240
|
+
@overload
|
|
241
|
+
def __getitem__(self, index: SupportsIndex, /) -> _T_co: ...
|
|
242
|
+
@overload
|
|
243
|
+
def __getitem__(self, index: slice, /) -> Sequence[_T_co]: ...
|
|
244
|
+
def __contains__(self, value: object, /) -> bool: ...
|
|
245
|
+
def __len__(self) -> int: ...
|
|
246
|
+
def __iter__(self) -> Iterator[_T_co]: ...
|
|
247
|
+
def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ...
|
|
248
|
+
def count(self, value: Any, /) -> int: ...
|
|
249
|
+
def __reversed__(self) -> Iterator[_T_co]: ...
|
|
250
|
+
else:
|
|
251
|
+
# just point this to a normal `Sequence` at runtime to avoid having to special case
|
|
252
|
+
# deserializing our custom sequence type
|
|
253
|
+
SequenceNotStr = Sequence
|
parallel/_utils/__init__.py
CHANGED
|
@@ -39,6 +39,7 @@ from ._typing import (
|
|
|
39
39
|
extract_type_arg as extract_type_arg,
|
|
40
40
|
is_iterable_type as is_iterable_type,
|
|
41
41
|
is_required_type as is_required_type,
|
|
42
|
+
is_sequence_type as is_sequence_type,
|
|
42
43
|
is_annotated_type as is_annotated_type,
|
|
43
44
|
is_type_alias_type as is_type_alias_type,
|
|
44
45
|
strip_annotated_type as strip_annotated_type,
|
parallel/_utils/_typing.py
CHANGED
|
@@ -26,6 +26,11 @@ def is_list_type(typ: type) -> bool:
|
|
|
26
26
|
return (get_origin(typ) or typ) == list
|
|
27
27
|
|
|
28
28
|
|
|
29
|
+
def is_sequence_type(typ: type) -> bool:
|
|
30
|
+
origin = get_origin(typ) or typ
|
|
31
|
+
return origin == typing_extensions.Sequence or origin == typing.Sequence or origin == _c_abc.Sequence
|
|
32
|
+
|
|
33
|
+
|
|
29
34
|
def is_iterable_type(typ: type) -> bool:
|
|
30
35
|
"""If the given type is `typing.Iterable[T]`"""
|
|
31
36
|
origin = get_origin(typ) or typ
|
parallel/_version.py
CHANGED
parallel/lib/_pydantic.py
CHANGED
|
@@ -26,6 +26,7 @@ def to_json_schema(
|
|
|
26
26
|
schema["additionalProperties"] = False
|
|
27
27
|
return schema
|
|
28
28
|
|
|
29
|
+
|
|
29
30
|
def is_basemodel_type(model_type: object) -> TypeGuard[type[pydantic.BaseModel]]:
|
|
30
31
|
"""Check if a type is a Pydantic BaseModel to avoid using type: ignore."""
|
|
31
32
|
return inspect.isclass(model_type) and issubclass(model_type, pydantic.BaseModel)
|
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
|
|
parallel/resources/__init__.py
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
+
from .beta import (
|
|
4
|
+
BetaResource,
|
|
5
|
+
AsyncBetaResource,
|
|
6
|
+
BetaResourceWithRawResponse,
|
|
7
|
+
AsyncBetaResourceWithRawResponse,
|
|
8
|
+
BetaResourceWithStreamingResponse,
|
|
9
|
+
AsyncBetaResourceWithStreamingResponse,
|
|
10
|
+
)
|
|
3
11
|
from .task_run import (
|
|
4
12
|
TaskRunResource,
|
|
5
13
|
AsyncTaskRunResource,
|
|
@@ -16,4 +24,10 @@ __all__ = [
|
|
|
16
24
|
"AsyncTaskRunResourceWithRawResponse",
|
|
17
25
|
"TaskRunResourceWithStreamingResponse",
|
|
18
26
|
"AsyncTaskRunResourceWithStreamingResponse",
|
|
27
|
+
"BetaResource",
|
|
28
|
+
"AsyncBetaResource",
|
|
29
|
+
"BetaResourceWithRawResponse",
|
|
30
|
+
"AsyncBetaResourceWithRawResponse",
|
|
31
|
+
"BetaResourceWithStreamingResponse",
|
|
32
|
+
"AsyncBetaResourceWithStreamingResponse",
|
|
19
33
|
]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from .beta import (
|
|
4
|
+
BetaResource,
|
|
5
|
+
AsyncBetaResource,
|
|
6
|
+
BetaResourceWithRawResponse,
|
|
7
|
+
AsyncBetaResourceWithRawResponse,
|
|
8
|
+
BetaResourceWithStreamingResponse,
|
|
9
|
+
AsyncBetaResourceWithStreamingResponse,
|
|
10
|
+
)
|
|
11
|
+
from .task_run import (
|
|
12
|
+
TaskRunResource,
|
|
13
|
+
AsyncTaskRunResource,
|
|
14
|
+
TaskRunResourceWithRawResponse,
|
|
15
|
+
AsyncTaskRunResourceWithRawResponse,
|
|
16
|
+
TaskRunResourceWithStreamingResponse,
|
|
17
|
+
AsyncTaskRunResourceWithStreamingResponse,
|
|
18
|
+
)
|
|
19
|
+
from .task_group import (
|
|
20
|
+
TaskGroupResource,
|
|
21
|
+
AsyncTaskGroupResource,
|
|
22
|
+
TaskGroupResourceWithRawResponse,
|
|
23
|
+
AsyncTaskGroupResourceWithRawResponse,
|
|
24
|
+
TaskGroupResourceWithStreamingResponse,
|
|
25
|
+
AsyncTaskGroupResourceWithStreamingResponse,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"TaskRunResource",
|
|
30
|
+
"AsyncTaskRunResource",
|
|
31
|
+
"TaskRunResourceWithRawResponse",
|
|
32
|
+
"AsyncTaskRunResourceWithRawResponse",
|
|
33
|
+
"TaskRunResourceWithStreamingResponse",
|
|
34
|
+
"AsyncTaskRunResourceWithStreamingResponse",
|
|
35
|
+
"TaskGroupResource",
|
|
36
|
+
"AsyncTaskGroupResource",
|
|
37
|
+
"TaskGroupResourceWithRawResponse",
|
|
38
|
+
"AsyncTaskGroupResourceWithRawResponse",
|
|
39
|
+
"TaskGroupResourceWithStreamingResponse",
|
|
40
|
+
"AsyncTaskGroupResourceWithStreamingResponse",
|
|
41
|
+
"BetaResource",
|
|
42
|
+
"AsyncBetaResource",
|
|
43
|
+
"BetaResourceWithRawResponse",
|
|
44
|
+
"AsyncBetaResourceWithRawResponse",
|
|
45
|
+
"BetaResourceWithStreamingResponse",
|
|
46
|
+
"AsyncBetaResourceWithStreamingResponse",
|
|
47
|
+
]
|