Skip to content

Commit d7dc210

Browse files
committed
Corrected lint errors
1 parent 296f214 commit d7dc210

File tree

3 files changed

+39
-37
lines changed

3 files changed

+39
-37
lines changed

examples/agent_wait_until_ready.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,32 @@
2323
if agent_id:
2424
print(f"Agent created with ID: {agent_id}")
2525
print("Waiting for agent to be ready...")
26-
26+
2727
try:
2828
# Wait for the agent to be deployed and ready
2929
# This will poll the agent status every 5 seconds (default)
3030
# and wait up to 5 minutes (default timeout=300 seconds)
3131
ready_agent = client.agents.wait_until_ready(
3232
agent_id,
3333
poll_interval=5.0, # Check every 5 seconds
34-
timeout=300.0, # Wait up to 5 minutes
34+
timeout=300.0, # Wait up to 5 minutes
3535
)
36-
36+
3737
if ready_agent.agent and ready_agent.agent.deployment:
3838
print(f"Agent is ready! Status: {ready_agent.agent.deployment.status}")
3939
print(f"Agent URL: {ready_agent.agent.url}")
40-
40+
4141
# Now you can use the agent
4242
# ...
43-
43+
4444
except AgentDeploymentError as e:
4545
print(f"Agent deployment failed: {e}")
4646
print(f"Failed status: {e.status}")
47-
47+
4848
except AgentDeploymentTimeoutError as e:
4949
print(f"Agent deployment timed out: {e}")
5050
print(f"Agent ID: {e.agent_id}")
51-
51+
5252
except Exception as e:
5353
print(f"Unexpected error: {e}")
5454

@@ -59,37 +59,37 @@
5959

6060
async def main() -> None:
6161
async_client = AsyncGradient()
62-
62+
6363
# Create a new agent
6464
agent_response = await async_client.agents.create(
6565
name="My Async Agent",
6666
instruction="You are a helpful assistant",
6767
model_uuid="<your-model-uuid>",
6868
region="nyc1",
6969
)
70-
70+
7171
agent_id = agent_response.agent.uuid if agent_response.agent else None
72-
72+
7373
if agent_id:
7474
print(f"Agent created with ID: {agent_id}")
7575
print("Waiting for agent to be ready...")
76-
76+
7777
try:
7878
# Wait for the agent to be deployed and ready (async)
7979
ready_agent = await async_client.agents.wait_until_ready(
8080
agent_id,
8181
poll_interval=5.0,
8282
timeout=300.0,
8383
)
84-
84+
8585
if ready_agent.agent and ready_agent.agent.deployment:
8686
print(f"Agent is ready! Status: {ready_agent.agent.deployment.status}")
8787
print(f"Agent URL: {ready_agent.agent.url}")
88-
88+
8989
except AgentDeploymentError as e:
9090
print(f"Agent deployment failed: {e}")
9191
print(f"Failed status: {e.status}")
92-
92+
9393
except AgentDeploymentTimeoutError as e:
9494
print(f"Agent deployment timed out: {e}")
9595
print(f"Agent ID: {e.agent_id}")

src/gradient/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
APIConnectionError,
3333
AuthenticationError,
3434
InternalServerError,
35+
AgentDeploymentError,
3536
PermissionDeniedError,
3637
UnprocessableEntityError,
3738
APIResponseValidationError,
38-
AgentDeploymentError,
3939
AgentDeploymentTimeoutError,
4040
)
4141
from ._base_client import DefaultHttpxClient, DefaultAioHttpClient, DefaultAsyncHttpxClient

tests/api_resources/test_agents.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,10 @@ def test_path_params_update_status(self, client: Gradient) -> None:
368368
def test_method_wait_until_ready(self, client: Gradient, respx_mock: Any) -> None:
369369
"""Test successful wait_until_ready when agent becomes ready."""
370370
agent_uuid = "test-agent-id"
371-
371+
372372
# Create side effect that returns different responses
373373
call_count = [0]
374+
374375
def get_response(_: httpx.Request) -> httpx.Response:
375376
call_count[0] += 1
376377
if call_count[0] == 1:
@@ -395,9 +396,9 @@ def get_response(_: httpx.Request) -> httpx.Response:
395396
}
396397
},
397398
)
398-
399+
399400
respx_mock.get(f"/v2/gen-ai/agents/{agent_uuid}").mock(side_effect=get_response)
400-
401+
401402
agent = client.agents.wait_until_ready(agent_uuid, poll_interval=0.1, timeout=10.0)
402403
assert_matches_type(AgentRetrieveResponse, agent, path=["response"])
403404
assert agent.agent is not None
@@ -408,9 +409,9 @@ def get_response(_: httpx.Request) -> httpx.Response:
408409
def test_wait_until_ready_timeout(self, client: Gradient, respx_mock: Any) -> None:
409410
"""Test that wait_until_ready raises timeout error."""
410411
from gradient._exceptions import AgentDeploymentTimeoutError
411-
412+
412413
agent_uuid = "test-agent-id"
413-
414+
414415
# Mock always returns deploying
415416
respx_mock.get(f"/v2/gen-ai/agents/{agent_uuid}").mock(
416417
return_value=httpx.Response(
@@ -423,20 +424,20 @@ def test_wait_until_ready_timeout(self, client: Gradient, respx_mock: Any) -> No
423424
},
424425
)
425426
)
426-
427+
427428
with pytest.raises(AgentDeploymentTimeoutError) as exc_info:
428429
client.agents.wait_until_ready(agent_uuid, poll_interval=0.1, timeout=0.5)
429-
430+
430431
assert "did not reach STATUS_RUNNING within" in str(exc_info.value)
431432
assert exc_info.value.agent_id == agent_uuid
432433

433434
@parametrize
434435
def test_wait_until_ready_deployment_failed(self, client: Gradient, respx_mock: Any) -> None:
435436
"""Test that wait_until_ready raises error on deployment failure."""
436437
from gradient._exceptions import AgentDeploymentError
437-
438+
438439
agent_uuid = "test-agent-id"
439-
440+
440441
# Mock returns failed status
441442
respx_mock.get(f"/v2/gen-ai/agents/{agent_uuid}").mock(
442443
return_value=httpx.Response(
@@ -449,10 +450,10 @@ def test_wait_until_ready_deployment_failed(self, client: Gradient, respx_mock:
449450
},
450451
)
451452
)
452-
453+
453454
with pytest.raises(AgentDeploymentError) as exc_info:
454455
client.agents.wait_until_ready(agent_uuid, poll_interval=0.1, timeout=10.0)
455-
456+
456457
assert "deployment failed with status: STATUS_FAILED" in str(exc_info.value)
457458
assert exc_info.value.status == "STATUS_FAILED"
458459

@@ -810,9 +811,10 @@ async def test_path_params_update_status(self, async_client: AsyncGradient) -> N
810811
async def test_method_wait_until_ready(self, async_client: AsyncGradient, respx_mock: Any) -> None:
811812
"""Test successful async wait_until_ready when agent becomes ready."""
812813
agent_uuid = "test-agent-id"
813-
814+
814815
# Create side effect that returns different responses
815816
call_count = [0]
817+
816818
def get_response(_: httpx.Request) -> httpx.Response:
817819
call_count[0] += 1
818820
if call_count[0] == 1:
@@ -837,9 +839,9 @@ def get_response(_: httpx.Request) -> httpx.Response:
837839
}
838840
},
839841
)
840-
842+
841843
respx_mock.get(f"/v2/gen-ai/agents/{agent_uuid}").mock(side_effect=get_response)
842-
844+
843845
agent = await async_client.agents.wait_until_ready(agent_uuid, poll_interval=0.1, timeout=10.0)
844846
assert_matches_type(AgentRetrieveResponse, agent, path=["response"])
845847
assert agent.agent is not None
@@ -850,9 +852,9 @@ def get_response(_: httpx.Request) -> httpx.Response:
850852
async def test_wait_until_ready_timeout(self, async_client: AsyncGradient, respx_mock: Any) -> None:
851853
"""Test that async wait_until_ready raises timeout error."""
852854
from gradient._exceptions import AgentDeploymentTimeoutError
853-
855+
854856
agent_uuid = "test-agent-id"
855-
857+
856858
# Mock always returns deploying
857859
respx_mock.get(f"/v2/gen-ai/agents/{agent_uuid}").mock(
858860
return_value=httpx.Response(
@@ -865,20 +867,20 @@ async def test_wait_until_ready_timeout(self, async_client: AsyncGradient, respx
865867
},
866868
)
867869
)
868-
870+
869871
with pytest.raises(AgentDeploymentTimeoutError) as exc_info:
870872
await async_client.agents.wait_until_ready(agent_uuid, poll_interval=0.1, timeout=0.5)
871-
873+
872874
assert "did not reach STATUS_RUNNING within" in str(exc_info.value)
873875
assert exc_info.value.agent_id == agent_uuid
874876

875877
@parametrize
876878
async def test_wait_until_ready_deployment_failed(self, async_client: AsyncGradient, respx_mock: Any) -> None:
877879
"""Test that async wait_until_ready raises error on deployment failure."""
878880
from gradient._exceptions import AgentDeploymentError
879-
881+
880882
agent_uuid = "test-agent-id"
881-
883+
882884
# Mock returns failed status
883885
respx_mock.get(f"/v2/gen-ai/agents/{agent_uuid}").mock(
884886
return_value=httpx.Response(
@@ -891,9 +893,9 @@ async def test_wait_until_ready_deployment_failed(self, async_client: AsyncGradi
891893
},
892894
)
893895
)
894-
896+
895897
with pytest.raises(AgentDeploymentError) as exc_info:
896898
await async_client.agents.wait_until_ready(agent_uuid, poll_interval=0.1, timeout=10.0)
897-
899+
898900
assert "deployment failed with status: STATUS_FAILED" in str(exc_info.value)
899901
assert exc_info.value.status == "STATUS_FAILED"

0 commit comments

Comments
 (0)