Skip to content

Commit e0723f5

Browse files
update custom code
1 parent db5980c commit e0723f5

3 files changed

Lines changed: 24 additions & 25 deletions

File tree

src/parallel/lib/_parsing/_task_run_result.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55
from .._time import timeout_retry_context
66
from ...types import TaskRunResult, ParsedTaskRunResult
7-
from ..._types import NotGiven
7+
from ..._types import Omit
88
from ..._utils import is_str, is_given
99
from ..._compat import model_parse, model_parse_json
1010
from ..._models import construct_type_unchecked
1111
from .._pydantic import is_basemodel_type
1212
from ._task_spec import is_output_schema_param
1313
from ...types.task_spec_param import OutputT, OutputSchema
14-
from ...types.parsed_task_run_result import ParsedTaskRunResult
1514

1615

1716
def wait_for_result(
@@ -37,7 +36,7 @@ async def wait_for_result_async(
3736

3837

3938
def task_run_result_parser(
40-
run_result: TaskRunResult, output_format: Union[OutputSchema, Type[OutputT]] | None | NotGiven
39+
run_result: TaskRunResult, output_format: Union[OutputSchema, Type[OutputT]] | Omit | None
4140
) -> TaskRunResult | ParsedTaskRunResult[OutputT]:
4241
"""Parse a TaskRunResult object into a ParsedTaskRunResult based on output_format."""
4342
if not is_given(output_format) or output_format is None or is_output_schema_param(output_format):

src/parallel/lib/_parsing/_task_spec.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pydantic
77

8-
from ..._types import NOT_GIVEN, NotGiven
8+
from ..._types import Omit
99
from ..._utils import is_str, is_dict, is_given
1010
from .._pydantic import to_json_schema, is_basemodel_type
1111
from ...types.task_spec_param import (
@@ -81,12 +81,12 @@ def _generate_output_schema(output_format: OutputSchema | Type[OutputT]) -> Outp
8181

8282

8383
def build_task_spec_param(
84-
output_format: OutputSchema | Type[OutputT] | None | NotGiven,
84+
output_format: OutputSchema | Type[OutputT] | Omit | None,
8585
_: Union[str, object], # placeholder for input
86-
) -> TaskSpecParam | NotGiven:
86+
) -> TaskSpecParam | Omit:
8787
"""Build a TaskSpecParam from an OutputSchema or Type[OutputT] if provided."""
8888
if not is_given(output_format) or output_format is None:
89-
return NOT_GIVEN
89+
return Omit()
9090

9191
# output format has type OutputSchema | Type[OutputT] here
9292
output_schema = _generate_output_schema(output_format) # type: ignore[arg-type]

src/parallel/resources/task_run.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def _wait_for_result(
201201
*,
202202
run_id: str,
203203
deadline: float,
204-
output: Optional[OutputSchema] | Type[OutputT] | NotGiven = NOT_GIVEN,
204+
output: Optional[OutputSchema] | Type[OutputT] | Omit = omit,
205205
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
206206
# The extra values given here take precedence over values defined on the client or passed to this method.
207207
extra_headers: Headers | None = None,
@@ -229,43 +229,43 @@ def execute(
229229
*,
230230
input: Union[str, Dict[str, object]],
231231
processor: str,
232-
metadata: Optional[Dict[str, Union[str, float, bool]]] | NotGiven = NOT_GIVEN,
233-
output: Optional[OutputSchema] | NotGiven = NOT_GIVEN,
232+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
233+
output: Optional[OutputSchema] | Omit = omit,
234234
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
235235
# The extra values given here take precedence over values defined on the client or passed to this method.
236236
extra_headers: Headers | None = None,
237237
extra_query: Query | None = None,
238238
extra_body: Body | None = None,
239-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
239+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
240240
) -> TaskRunResult: ...
241241
@overload
242242
def execute(
243243
self,
244244
*,
245245
input: Union[str, Dict[str, object]],
246246
processor: str,
247-
metadata: Optional[Dict[str, Union[str, float, bool]]] | NotGiven = NOT_GIVEN,
247+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
248248
output: Type[OutputT],
249249
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
250250
# The extra values given here take precedence over values defined on the client or passed to this method.
251251
extra_headers: Headers | None = None,
252252
extra_query: Query | None = None,
253253
extra_body: Body | None = None,
254-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
254+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
255255
) -> ParsedTaskRunResult[OutputT]: ...
256256
def execute(
257257
self,
258258
*,
259259
input: Union[str, Dict[str, object]],
260260
processor: str,
261-
metadata: Optional[Dict[str, Union[str, float, bool]]] | NotGiven = NOT_GIVEN,
262-
output: Optional[OutputSchema] | Type[OutputT] | NotGiven = NOT_GIVEN,
261+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
262+
output: Optional[OutputSchema] | Type[OutputT] | Omit = omit,
263263
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
264264
# The extra values given here take precedence over values defined on the client or passed to this method.
265265
extra_headers: Headers | None = None,
266266
extra_query: Query | None = None,
267267
extra_body: Body | None = None,
268-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
268+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
269269
) -> TaskRunResult | ParsedTaskRunResult[OutputT]:
270270
"""
271271
Convenience method to create and execute a task run in a single call.
@@ -492,7 +492,7 @@ async def _wait_for_result(
492492
*,
493493
run_id: str,
494494
deadline: float,
495-
output: Optional[OutputSchema] | Type[OutputT] | NotGiven = NOT_GIVEN,
495+
output: Optional[OutputSchema] | Type[OutputT] | Omit = omit,
496496
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
497497
# The extra values given here take precedence over values defined on the client or passed to this method.
498498
extra_headers: Headers | None = None,
@@ -520,39 +520,39 @@ async def execute(
520520
*,
521521
input: Union[str, Dict[str, object]],
522522
processor: str,
523-
metadata: Optional[Dict[str, Union[str, float, bool]]] | NotGiven = NOT_GIVEN,
524-
output: Optional[OutputSchema] | NotGiven = NOT_GIVEN,
523+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
524+
output: Optional[OutputSchema] | Omit = omit,
525525
extra_headers: Headers | None = None,
526526
extra_query: Query | None = None,
527527
extra_body: Body | None = None,
528-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
528+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
529529
) -> TaskRunResult: ...
530530
@overload
531531
async def execute(
532532
self,
533533
*,
534534
input: Union[str, Dict[str, object]],
535535
processor: str,
536-
metadata: Optional[Dict[str, Union[str, float, bool]]] | NotGiven = NOT_GIVEN,
536+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
537537
output: Type[OutputT],
538538
extra_headers: Headers | None = None,
539539
extra_query: Query | None = None,
540540
extra_body: Body | None = None,
541-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
541+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
542542
) -> ParsedTaskRunResult[OutputT]: ...
543543
async def execute(
544544
self,
545545
*,
546546
input: Union[str, Dict[str, object]],
547547
processor: str,
548-
metadata: Optional[Dict[str, Union[str, float, bool]]] | NotGiven = NOT_GIVEN,
549-
output: Optional[OutputSchema] | Type[OutputT] | NotGiven = NOT_GIVEN,
548+
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
549+
output: Optional[OutputSchema] | Type[OutputT] | Omit = omit,
550550
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
551551
# The extra values given here take precedence over values defined on the client or passed to this method.
552552
extra_headers: Headers | None = None,
553553
extra_query: Query | None = None,
554554
extra_body: Body | None = None,
555-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
555+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
556556
) -> TaskRunResult | ParsedTaskRunResult[OutputT]:
557557
"""
558558
Convenience method to create and execute a task run in a single call.

0 commit comments

Comments
 (0)