Skip to content

Commit a36ae42

Browse files
authored
feat(toolbox-core)!: Rename bind_parameters to bind_params (#209)
This aligns with the other orchestration package naming, and is more precise and convenient.
1 parent c7eebbb commit a36ae42

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

packages/toolbox-core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ specific tool instance.
369369
toolbox = ToolboxClient("http://127.0.0.1:5000")
370370
tool = await toolbox.load_tool("my-tool")
371371

372-
bound_tool = tool.bind_parameters({"param": "value"})
372+
bound_tool = tool.bind_params({"param": "value"})
373373
```
374374

375375
### Option B: Binding Parameters While Loading Tools

packages/toolbox-core/src/toolbox_core/sync_tool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def add_auth_token_getters(
153153
new_async_tool = self.__async_tool.add_auth_token_getters(auth_token_getters)
154154
return ToolboxSyncTool(new_async_tool, self.__loop, self.__thread)
155155

156-
def bind_parameters(
156+
def bind_params(
157157
self, bound_params: Mapping[str, Union[Callable[[], Any], Any]]
158158
) -> "ToolboxSyncTool":
159159
"""
@@ -167,5 +167,5 @@ def bind_parameters(
167167
A new ToolboxSyncTool instance with the specified parameters bound.
168168
"""
169169

170-
new_async_tool = self.__async_tool.bind_parameters(bound_params)
170+
new_async_tool = self.__async_tool.bind_params(bound_params)
171171
return ToolboxSyncTool(new_async_tool, self.__loop, self.__thread)

packages/toolbox-core/src/toolbox_core/tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def add_auth_token_getters(
301301
required_authn_params=new_req_authn_params,
302302
)
303303

304-
def bind_parameters(
304+
def bind_params(
305305
self, bound_params: Mapping[str, Union[Callable[[], Any], Any]]
306306
) -> "ToolboxTool":
307307
"""

packages/toolbox-core/tests/test_client.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ async def test_bind_param_success(self, tool_name, client):
442442
assert len(tool.__signature__.parameters) == 2
443443
assert "argA" in tool.__signature__.parameters
444444

445-
tool = tool.bind_parameters({"argA": 5})
445+
tool = tool.bind_params({"argA": 5})
446446

447447
assert len(tool.__signature__.parameters) == 1
448448
assert "argA" not in tool.__signature__.parameters
@@ -458,7 +458,7 @@ async def test_bind_callable_param_success(self, tool_name, client):
458458
assert len(tool.__signature__.parameters) == 2
459459
assert "argA" in tool.__signature__.parameters
460460

461-
tool = tool.bind_parameters({"argA": lambda: 5})
461+
tool = tool.bind_params({"argA": lambda: 5})
462462

463463
assert len(tool.__signature__.parameters) == 1
464464
assert "argA" not in tool.__signature__.parameters
@@ -468,34 +468,34 @@ async def test_bind_callable_param_success(self, tool_name, client):
468468

469469
@pytest.mark.asyncio
470470
async def test_bind_param_fail(self, tool_name, client):
471-
"""Tests 'bind_parameters' with a bound parameter that doesn't exist."""
471+
"""Tests 'bind_params' with a bound parameter that doesn't exist."""
472472
tool = await client.load_tool(tool_name)
473473

474474
assert len(tool.__signature__.parameters) == 2
475475
assert "argA" in tool.__signature__.parameters
476476

477477
with pytest.raises(Exception) as e:
478-
tool.bind_parameters({"argC": lambda: 5})
478+
tool.bind_params({"argC": lambda: 5})
479479
assert "unable to bind parameters: no parameter named argC" in str(e.value)
480480

481481
@pytest.mark.asyncio
482482
async def test_rebind_param_fail(self, tool_name, client):
483483
"""
484-
Tests that 'bind_parameters' fails when attempting to re-bind a
484+
Tests that 'bind_params' fails when attempting to re-bind a
485485
parameter that has already been bound.
486486
"""
487487
tool = await client.load_tool(tool_name)
488488

489489
assert len(tool.__signature__.parameters) == 2
490490
assert "argA" in tool.__signature__.parameters
491491

492-
tool_with_bound_param = tool.bind_parameters({"argA": lambda: 10})
492+
tool_with_bound_param = tool.bind_params({"argA": lambda: 10})
493493

494494
assert len(tool_with_bound_param.__signature__.parameters) == 1
495495
assert "argA" not in tool_with_bound_param.__signature__.parameters
496496

497497
with pytest.raises(ValueError) as e:
498-
tool_with_bound_param.bind_parameters({"argA": lambda: 20})
498+
tool_with_bound_param.bind_params({"argA": lambda: 20})
499499

500500
assert "cannot re-bind parameter: parameter 'argA' is already bound" in str(
501501
e.value
@@ -504,13 +504,13 @@ async def test_rebind_param_fail(self, tool_name, client):
504504
@pytest.mark.asyncio
505505
async def test_bind_param_static_value_success(self, tool_name, client):
506506
"""
507-
Tests bind_parameters method with a static value.
507+
Tests bind_params method with a static value.
508508
"""
509509

510510
bound_value = "Test value"
511511

512512
tool = await client.load_tool(tool_name)
513-
bound_tool = tool.bind_parameters({"argB": bound_value})
513+
bound_tool = tool.bind_params({"argB": bound_value})
514514

515515
assert bound_tool is not tool
516516
assert "argB" not in bound_tool.__signature__.parameters
@@ -524,14 +524,14 @@ async def test_bind_param_static_value_success(self, tool_name, client):
524524
@pytest.mark.asyncio
525525
async def test_bind_param_sync_callable_value_success(self, tool_name, client):
526526
"""
527-
Tests bind_parameters method with a sync callable value.
527+
Tests bind_params method with a sync callable value.
528528
"""
529529

530530
bound_value_result = True
531531
bound_sync_callable = Mock(return_value=bound_value_result)
532532

533533
tool = await client.load_tool(tool_name)
534-
bound_tool = tool.bind_parameters({"argB": bound_sync_callable})
534+
bound_tool = tool.bind_params({"argB": bound_sync_callable})
535535

536536
assert bound_tool is not tool
537537
assert "argB" not in bound_tool.__signature__.parameters
@@ -546,14 +546,14 @@ async def test_bind_param_sync_callable_value_success(self, tool_name, client):
546546
@pytest.mark.asyncio
547547
async def test_bind_param_async_callable_value_success(self, tool_name, client):
548548
"""
549-
Tests bind_parameters method with an async callable value.
549+
Tests bind_params method with an async callable value.
550550
"""
551551

552552
bound_value_result = True
553553
bound_async_callable = AsyncMock(return_value=bound_value_result)
554554

555555
tool = await client.load_tool(tool_name)
556-
bound_tool = tool.bind_parameters({"argB": bound_async_callable})
556+
bound_tool = tool.bind_params({"argB": bound_async_callable})
557557

558558
assert bound_tool is not tool
559559
assert "argB" not in bound_tool.__signature__.parameters

packages/toolbox-core/tests/test_e2e.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ async def test_bind_params(
105105
self, toolbox: ToolboxClient, get_n_rows_tool: ToolboxTool
106106
):
107107
"""Bind a param to an existing tool."""
108-
new_tool = get_n_rows_tool.bind_parameters({"num_rows": "3"})
108+
new_tool = get_n_rows_tool.bind_params({"num_rows": "3"})
109109
response = await new_tool()
110110
assert isinstance(response, str)
111111
assert "row1" in response
@@ -117,7 +117,7 @@ async def test_bind_params_callable(
117117
self, toolbox: ToolboxClient, get_n_rows_tool: ToolboxTool
118118
):
119119
"""Bind a callable param to an existing tool."""
120-
new_tool = get_n_rows_tool.bind_parameters({"num_rows": lambda: "3"})
120+
new_tool = get_n_rows_tool.bind_params({"num_rows": lambda: "3"})
121121
response = await new_tool()
122122
assert isinstance(response, str)
123123
assert "row1" in response

packages/toolbox-core/tests/test_sync_e2e.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_bind_params(
8888
self, toolbox: ToolboxSyncClient, get_n_rows_tool: ToolboxSyncTool
8989
):
9090
"""Bind a param to an existing tool."""
91-
new_tool = get_n_rows_tool.bind_parameters({"num_rows": "3"})
91+
new_tool = get_n_rows_tool.bind_params({"num_rows": "3"})
9292
response = new_tool()
9393
assert isinstance(response, str)
9494
assert "row1" in response
@@ -100,7 +100,7 @@ def test_bind_params_callable(
100100
self, toolbox: ToolboxSyncClient, get_n_rows_tool: ToolboxSyncTool
101101
):
102102
"""Bind a callable param to an existing tool."""
103-
new_tool = get_n_rows_tool.bind_parameters({"num_rows": lambda: "3"})
103+
new_tool = get_n_rows_tool.bind_params({"num_rows": lambda: "3"})
104104
response = new_tool()
105105
assert isinstance(response, str)
106106
assert "row1" in response

0 commit comments

Comments
 (0)