Skip to content

Commit 49d9d2f

Browse files
authored
Merge pull request #640 from runloopai/tode/add-defaults-for-streaming-output
Add default offset='0', request_header for streaming
2 parents f9da9f1 + a48a400 commit 49d9d2f

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

src/runloop_api_client/resources/devboxes/executions.py

Lines changed: 33 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,15 @@ 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: Headers = {'Accept': 'text/event-stream'}
366+
merged_headers = default_headers if extra_headers is None else {**default_headers, **extra_headers}
367+
368+
if merged_headers and merged_headers.get(RAW_RESPONSE_HEADER):
365369
return self._get(
366370
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stderr_updates",
367371
options=make_request_options(
368-
extra_headers=extra_headers,
372+
extra_headers=merged_headers,
369373
extra_query=extra_query,
370374
extra_body=extra_body,
371375
timeout=timeout,
@@ -383,7 +387,7 @@ def create_stream(last_offset: str | None) -> Stream[ExecutionUpdateChunk]:
383387
return self._get(
384388
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stderr_updates",
385389
options=make_request_options(
386-
extra_headers=extra_headers,
390+
extra_headers=merged_headers,
387391
extra_query=extra_query,
388392
extra_body=extra_body,
389393
timeout=timeout,
@@ -415,7 +419,7 @@ def stream_stdout_updates(
415419
execution_id: str,
416420
*,
417421
devbox_id: str,
418-
offset: str | NotGiven = NOT_GIVEN,
422+
offset: str | NotGiven = '0',
419423
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
420424
# The extra values given here take precedence over values defined on the client or passed to this method.
421425
extra_headers: Headers | None = None,
@@ -441,11 +445,15 @@ def stream_stdout_updates(
441445
raise ValueError(f"Expected a non-empty value for `devbox_id` but received {devbox_id!r}")
442446
if not execution_id:
443447
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):
448+
449+
default_headers: Headers = {'Accept': 'text/event-stream'}
450+
merged_headers = default_headers if extra_headers is None else {**default_headers, **extra_headers}
451+
452+
if merged_headers and merged_headers.get(RAW_RESPONSE_HEADER):
445453
return self._get(
446454
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stdout_updates",
447455
options=make_request_options(
448-
extra_headers=extra_headers,
456+
extra_headers=merged_headers,
449457
extra_query=extra_query,
450458
extra_body=extra_body,
451459
timeout=timeout,
@@ -463,7 +471,7 @@ def create_stream(last_offset: str | None) -> Stream[ExecutionUpdateChunk]:
463471
return self._get(
464472
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stdout_updates",
465473
options=make_request_options(
466-
extra_headers=extra_headers,
474+
extra_headers=merged_headers,
467475
extra_query=extra_query,
468476
extra_body=extra_body,
469477
timeout=timeout,
@@ -779,7 +787,7 @@ async def stream_stderr_updates(
779787
execution_id: str,
780788
*,
781789
devbox_id: str,
782-
offset: str | NotGiven = NOT_GIVEN,
790+
offset: str | NotGiven = '0',
783791
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
784792
# The extra values given here take precedence over values defined on the client or passed to this method.
785793
extra_headers: Headers | None = None,
@@ -805,11 +813,15 @@ async def stream_stderr_updates(
805813
raise ValueError(f"Expected a non-empty value for `devbox_id` but received {devbox_id!r}")
806814
if not execution_id:
807815
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):
816+
817+
default_headers: Headers = {'Accept': 'text/event-stream'}
818+
merged_headers = default_headers if extra_headers is None else {**default_headers, **extra_headers}
819+
820+
if merged_headers and merged_headers.get(RAW_RESPONSE_HEADER):
809821
return await self._get(
810822
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stderr_updates",
811823
options=make_request_options(
812-
extra_headers=extra_headers,
824+
extra_headers=merged_headers,
813825
extra_query=extra_query,
814826
extra_body=extra_body,
815827
timeout=timeout,
@@ -827,7 +839,7 @@ async def create_stream(last_offset: str | None) -> AsyncStream[ExecutionUpdateC
827839
return await self._get(
828840
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stderr_updates",
829841
options=make_request_options(
830-
extra_headers=extra_headers,
842+
extra_headers=merged_headers,
831843
extra_query=extra_query,
832844
extra_body=extra_body,
833845
timeout=timeout,
@@ -859,7 +871,7 @@ async def stream_stdout_updates(
859871
execution_id: str,
860872
*,
861873
devbox_id: str,
862-
offset: str | NotGiven = NOT_GIVEN,
874+
offset: str | NotGiven = '0',
863875
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
864876
# The extra values given here take precedence over values defined on the client or passed to this method.
865877
extra_headers: Headers | None = None,
@@ -885,12 +897,17 @@ async def stream_stdout_updates(
885897
raise ValueError(f"Expected a non-empty value for `devbox_id` but received {devbox_id!r}")
886898
if not execution_id:
887899
raise ValueError(f"Expected a non-empty value for `execution_id` but received {execution_id!r}")
900+
901+
default_headers: Headers = {'Accept': 'text/event-stream'}
902+
merged_headers = default_headers if extra_headers is None else {**default_headers, **extra_headers}
903+
904+
888905
# 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):
906+
if merged_headers and merged_headers.get(RAW_RESPONSE_HEADER):
890907
return await self._get(
891908
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stdout_updates",
892909
options=make_request_options(
893-
extra_headers=extra_headers,
910+
extra_headers=merged_headers,
894911
extra_query=extra_query,
895912
extra_body=extra_body,
896913
timeout=timeout,
@@ -908,7 +925,7 @@ async def create_stream(last_offset: str | None) -> AsyncStream[ExecutionUpdateC
908925
return await self._get(
909926
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/stream_stdout_updates",
910927
options=make_request_options(
911-
extra_headers=extra_headers,
928+
extra_headers=merged_headers,
912929
extra_query=extra_query,
913930
extra_body=extra_body,
914931
timeout=timeout,

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)