Skip to content

Commit 03ea4d4

Browse files
committed
default offset='0', request_headers for output
1 parent f9da9f1 commit 03ea4d4

File tree

1 file changed

+44
-16
lines changed

1 file changed

+44
-16
lines changed

src/runloop_api_client/resources/devboxes/executions.py

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def stream_stderr_updates(
335335
execution_id: str,
336336
*,
337337
devbox_id: str,
338-
offset: str | NotGiven = NOT_GIVEN,
338+
offset: str | NotGiven = '0',
339339
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
340340
# The extra values given here take precedence over values defined on the client or passed to this method.
341341
extra_headers: Headers | None = None,
@@ -361,11 +361,18 @@ def stream_stderr_updates(
361361
raise ValueError(f"Expected a non-empty value for `devbox_id` but received {devbox_id!r}")
362362
if not execution_id:
363363
raise ValueError(f"Expected a non-empty value for `execution_id` but received {execution_id!r}")
364-
if extra_headers and extra_headers.get(RAW_RESPONSE_HEADER):
364+
365+
default_headers = {'Accept': 'text/event-stream'}
366+
if extra_headers:
367+
merged_headers = {**default_headers, **extra_headers}
368+
else:
369+
merged_headers = default_headers
370+
371+
if merged_headers and merged_headers.get(RAW_RESPONSE_HEADER):
365372
return self._get(
366373
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stderr_updates",
367374
options=make_request_options(
368-
extra_headers=extra_headers,
375+
extra_headers=merged_headers,
369376
extra_query=extra_query,
370377
extra_body=extra_body,
371378
timeout=timeout,
@@ -383,7 +390,7 @@ def create_stream(last_offset: str | None) -> Stream[ExecutionUpdateChunk]:
383390
return self._get(
384391
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stderr_updates",
385392
options=make_request_options(
386-
extra_headers=extra_headers,
393+
extra_headers=merged_headers,
387394
extra_query=extra_query,
388395
extra_body=extra_body,
389396
timeout=timeout,
@@ -415,7 +422,7 @@ def stream_stdout_updates(
415422
execution_id: str,
416423
*,
417424
devbox_id: str,
418-
offset: str | NotGiven = NOT_GIVEN,
425+
offset: str | NotGiven = '0',
419426
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
420427
# The extra values given here take precedence over values defined on the client or passed to this method.
421428
extra_headers: Headers | None = None,
@@ -441,11 +448,18 @@ def stream_stdout_updates(
441448
raise ValueError(f"Expected a non-empty value for `devbox_id` but received {devbox_id!r}")
442449
if not execution_id:
443450
raise ValueError(f"Expected a non-empty value for `execution_id` but received {execution_id!r}")
444-
if extra_headers and extra_headers.get(RAW_RESPONSE_HEADER):
451+
452+
default_headers = {'Accept': 'text/event-stream'}
453+
if extra_headers:
454+
merged_headers = {**default_headers, **extra_headers}
455+
else:
456+
merged_headers = default_headers
457+
458+
if merged_headers and merged_headers.get(RAW_RESPONSE_HEADER):
445459
return self._get(
446460
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stdout_updates",
447461
options=make_request_options(
448-
extra_headers=extra_headers,
462+
extra_headers=merged_headers,
449463
extra_query=extra_query,
450464
extra_body=extra_body,
451465
timeout=timeout,
@@ -463,7 +477,7 @@ def create_stream(last_offset: str | None) -> Stream[ExecutionUpdateChunk]:
463477
return self._get(
464478
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stdout_updates",
465479
options=make_request_options(
466-
extra_headers=extra_headers,
480+
extra_headers=merged_headers,
467481
extra_query=extra_query,
468482
extra_body=extra_body,
469483
timeout=timeout,
@@ -779,7 +793,7 @@ async def stream_stderr_updates(
779793
execution_id: str,
780794
*,
781795
devbox_id: str,
782-
offset: str | NotGiven = NOT_GIVEN,
796+
offset: str | NotGiven = '0',
783797
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
784798
# The extra values given here take precedence over values defined on the client or passed to this method.
785799
extra_headers: Headers | None = None,
@@ -805,11 +819,18 @@ async def stream_stderr_updates(
805819
raise ValueError(f"Expected a non-empty value for `devbox_id` but received {devbox_id!r}")
806820
if not execution_id:
807821
raise ValueError(f"Expected a non-empty value for `execution_id` but received {execution_id!r}")
808-
if extra_headers and extra_headers.get(RAW_RESPONSE_HEADER):
822+
823+
default_headers = {'Accept': 'text/event-stream'}
824+
if extra_headers:
825+
merged_headers = {**default_headers, **extra_headers}
826+
else:
827+
merged_headers = default_headers
828+
829+
if merged_headers and merged_headers.get(RAW_RESPONSE_HEADER):
809830
return await self._get(
810831
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stderr_updates",
811832
options=make_request_options(
812-
extra_headers=extra_headers,
833+
extra_headers=merged_headers,
813834
extra_query=extra_query,
814835
extra_body=extra_body,
815836
timeout=timeout,
@@ -827,7 +848,7 @@ async def create_stream(last_offset: str | None) -> AsyncStream[ExecutionUpdateC
827848
return await self._get(
828849
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stderr_updates",
829850
options=make_request_options(
830-
extra_headers=extra_headers,
851+
extra_headers=merged_headers,
831852
extra_query=extra_query,
832853
extra_body=extra_body,
833854
timeout=timeout,
@@ -859,7 +880,7 @@ async def stream_stdout_updates(
859880
execution_id: str,
860881
*,
861882
devbox_id: str,
862-
offset: str | NotGiven = NOT_GIVEN,
883+
offset: str | NotGiven = '0',
863884
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
864885
# The extra values given here take precedence over values defined on the client or passed to this method.
865886
extra_headers: Headers | None = None,
@@ -885,12 +906,19 @@ async def stream_stdout_updates(
885906
raise ValueError(f"Expected a non-empty value for `devbox_id` but received {devbox_id!r}")
886907
if not execution_id:
887908
raise ValueError(f"Expected a non-empty value for `execution_id` but received {execution_id!r}")
909+
910+
default_headers = {'Accept': 'text/event-stream'}
911+
if extra_headers:
912+
merged_headers = {**default_headers, **extra_headers}
913+
else:
914+
merged_headers = default_headers
915+
888916
# If caller requested a raw or streaming response wrapper, return the underlying stream as-is
889-
if extra_headers and extra_headers.get(RAW_RESPONSE_HEADER):
917+
if merged_headers and merged_headers.get(RAW_RESPONSE_HEADER):
890918
return await self._get(
891919
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stdout_updates",
892920
options=make_request_options(
893-
extra_headers=extra_headers,
921+
extra_headers=merged_headers,
894922
extra_query=extra_query,
895923
extra_body=extra_body,
896924
timeout=timeout,
@@ -908,7 +936,7 @@ async def create_stream(last_offset: str | None) -> AsyncStream[ExecutionUpdateC
908936
return await self._get(
909937
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stdout_updates",
910938
options=make_request_options(
911-
extra_headers=extra_headers,
939+
extra_headers=merged_headers,
912940
extra_query=extra_query,
913941
extra_body=extra_body,
914942
timeout=timeout,

0 commit comments

Comments
 (0)