Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions src/runloop_api_client/resources/devboxes/devboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,8 @@ def await_running(
self,
id: str,
*,
# Use polling_config to configure the "long" polling behavior.
polling_config: PollingConfig | None = None,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> DevboxView:
"""Wait for a devbox to be in running state.

Expand All @@ -392,9 +387,6 @@ def wait_for_devbox_status() -> DevboxView:
return self._post(
f"/v1/devboxes/{id}/wait_for_status",
body={"statuses": ["running", "failure"]},
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=DevboxView,
)

Expand Down Expand Up @@ -495,10 +487,6 @@ def create_and_await_running(
return self.await_running(
devbox.id,
polling_config=polling_config,
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
)

def list(
Expand Down Expand Up @@ -1662,23 +1650,14 @@ async def create_and_await_running(
return await self.await_running(
devbox.id,
polling_config=polling_config,
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
)

async def await_running(
self,
id: str,
*,
# Use polling_config to configure the "long" polling behavior.
polling_config: PollingConfig | None = None,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> DevboxView:
"""Wait for a devbox to be in running state.

Expand All @@ -1705,9 +1684,6 @@ async def wait_for_devbox_status() -> DevboxView:
return await self._post(
f"/v1/devboxes/{id}/wait_for_status",
body={"statuses": ["running", "failure"]},
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=DevboxView,
)
except APIStatusError as error:
Expand Down
24 changes: 4 additions & 20 deletions src/runloop_api_client/resources/devboxes/executions.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,8 @@ def await_completed(
execution_id: str,
devbox_id: str,
*,
config: PollingConfig | None = None,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
# Use polling_config to configure the "long" polling behavior.
polling_config: PollingConfig | None = None,
) -> DevboxAsyncExecutionDetailView:
"""Wait for an execution to complete.

Expand All @@ -128,9 +123,6 @@ def wait_for_execution_status() -> DevboxAsyncExecutionDetailView:
return self._post(
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/wait_for_status",
body={"statuses": ["completed"]},
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=DevboxAsyncExecutionDetailView,
)

Expand All @@ -152,7 +144,7 @@ def handle_timeout_error(error: Exception) -> DevboxAsyncExecutionDetailView:
def is_done(execution: DevboxAsyncExecutionDetailView) -> bool:
return execution.status == "completed"

return poll_until(wait_for_execution_status, is_done, config, handle_timeout_error)
return poll_until(wait_for_execution_status, is_done, polling_config, handle_timeout_error)

def execute_async(
self,
Expand Down Expand Up @@ -390,13 +382,8 @@ async def await_completed(
execution_id: str,
*,
devbox_id: str,
# Use polling_config to configure the "long" polling behavior.
polling_config: PollingConfig | None = None,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> DevboxAsyncExecutionDetailView:
"""Wait for an execution to complete.

Expand All @@ -421,9 +408,6 @@ async def wait_for_execution_status() -> DevboxAsyncExecutionDetailView:
return await self._post(
f"/v1/devboxes/{devbox_id}/executions/{execution_id}/wait_for_status",
body={"statuses": ["completed"]},
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=DevboxAsyncExecutionDetailView,
)
except APIStatusError as error:
Expand Down
4 changes: 0 additions & 4 deletions src/runloop_api_client/resources/scenarios/scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,6 @@ def start_run_and_await_env_ready(
self._client.devboxes.await_running(
run.devbox_id,
polling_config=polling_config,
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
)

return run
Expand Down
4 changes: 2 additions & 2 deletions tests/api_resources/devboxes/test_executions.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def test_method_await_completed_with_config(self, client: Runloop) -> None:
with patch.object(client.devboxes.executions, "_post") as mock_post:
mock_post.return_value = mock_execution_completed

result = client.devboxes.executions.await_completed("execution_id", "devbox_id", config=config)
result = client.devboxes.executions.await_completed("execution_id", "devbox_id", polling_config=config)

assert result.execution_id == "execution_id"
assert result.status == "completed"
Expand All @@ -361,7 +361,7 @@ def test_method_await_completed_polling_timeout(self, client: Runloop) -> None:
mock_post.return_value = mock_execution_running

with pytest.raises(PollingTimeout):
client.devboxes.executions.await_completed("execution_id", "devbox_id", config=config)
client.devboxes.executions.await_completed("execution_id", "devbox_id", polling_config=config)

@parametrize
def test_method_await_completed_various_statuses(self, client: Runloop) -> None:
Expand Down
10 changes: 3 additions & 7 deletions tests/api_resources/test_devboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
from typing import Any, cast
from unittest.mock import ANY, Mock, patch
from unittest.mock import Mock, patch

import httpx
import pytest
Expand Down Expand Up @@ -1171,9 +1171,7 @@ def test_method_create_and_await_running_success(self, client: Runloop) -> None:
assert result.id == "test_id"
assert result.status == "running"
mock_create.assert_called_once()
mock_await.assert_called_once_with(
"test_id", polling_config=None, extra_headers=None, extra_query=None, extra_body=None, timeout=ANY
)
mock_await.assert_called_once_with("test_id", polling_config=None)

@parametrize
def test_method_create_and_await_running_with_config(self, client: Runloop) -> None:
Expand Down Expand Up @@ -1210,9 +1208,7 @@ def test_method_create_and_await_running_with_config(self, client: Runloop) -> N

assert result.id == "test_id"
assert result.status == "running"
mock_await.assert_called_once_with(
"test_id", polling_config=config, extra_headers=None, extra_query=None, extra_body=None, timeout=ANY
)
mock_await.assert_called_once_with("test_id", polling_config=config)

@parametrize
def test_method_create_and_await_running_create_failure(self, client: Runloop) -> None:
Expand Down