Skip to content

Commit 44ae5d0

Browse files
committed
rename _build_params to build (now publicly exposed method)
1 parent 1fffeeb commit 44ae5d0

6 files changed

Lines changed: 26 additions & 26 deletions

File tree

src/runloop_api_client/sdk/async_scenario_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def _build_environment_params(self) -> Optional[ScenarioEnvironmentParam]:
402402
"working_directory": self._working_directory if self._working_directory else None,
403403
}
404404

405-
def _build_params(self) -> ScenarioCreateParams:
405+
def build(self) -> ScenarioCreateParams:
406406
"""Build the scenario creation parameters.
407407
408408
Weights are automatically normalized to sum to 1.0.
@@ -473,6 +473,6 @@ async def push(self, **options: Unpack[LongRequestOptions]) -> AsyncScenario:
473473
:return: Created scenario wrapper
474474
:rtype: AsyncScenario
475475
"""
476-
params = self._build_params()
476+
params = self.build()
477477
scenario_view = await self._client.scenarios.create(**params, **options)
478478
return AsyncScenario(self._client, scenario_view.id)

src/runloop_api_client/sdk/scenario_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def _build_environment_params(self) -> Optional[ScenarioEnvironmentParam]:
402402
"working_directory": self._working_directory if self._working_directory else None,
403403
}
404404

405-
def _build_params(self) -> ScenarioCreateParams:
405+
def build(self) -> ScenarioCreateParams:
406406
"""Build the scenario creation parameters.
407407
408408
Weights are automatically normalized to sum to 1.0.
@@ -473,6 +473,6 @@ def push(self, **options: Unpack[LongRequestOptions]) -> Scenario:
473473
:return: Created scenario wrapper
474474
:rtype: Scenario
475475
"""
476-
params = self._build_params()
476+
params = self.build()
477477
scenario_view = self._client.scenarios.create(**params, **options)
478478
return Scenario(self._client, scenario_view.id)

tests/sdk/test_async_scenario_builder.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,23 @@ def test_add_scorer_rejects_invalid_weight(self, mock_builder: AsyncScenarioBuil
128128
with pytest.raises(ValueError, match="Scorer weight must be positive"):
129129
mock_builder.add_bash_script_scorer("bad", bash_script="echo 1", weight=-1.0)
130130

131-
def test_build_params_validation(self, mock_builder: AsyncScenarioBuilder) -> None:
132-
"""Test _build_params raises for missing required fields."""
131+
def test_build_validation(self, mock_builder: AsyncScenarioBuilder) -> None:
132+
"""Test build raises for missing required fields."""
133133
# Missing problem statement
134134
mock_builder.add_test_command_scorer("test", test_command="pytest")
135135
with pytest.raises(ValueError, match="Problem statement is required"):
136-
mock_builder._build_params()
136+
mock_builder.build()
137137

138138
# Missing scorer (new builder)
139139
builder2 = AsyncScenarioBuilder("test2", mock_builder._client)
140140
builder2.with_problem_statement("Fix the bug")
141141
with pytest.raises(ValueError, match="At least one scorer is required"):
142-
builder2._build_params()
142+
builder2.build()
143143

144-
def test_build_params_with_all_options(
144+
def test_build_with_all_options(
145145
self, mock_builder: AsyncScenarioBuilder, mock_blueprint: AsyncBlueprint
146146
) -> None:
147-
"""Test _build_params with all optional fields set."""
147+
"""Test build with all optional fields set."""
148148
mock_builder.with_problem_statement("Fix the bug")
149149
mock_builder.with_additional_context({"hint": "line 42"})
150150
mock_builder.add_test_command_scorer("tests", test_command="pytest")
@@ -156,7 +156,7 @@ def test_build_params_with_all_options(
156156
mock_builder.with_required_secrets(["db_pass"])
157157
mock_builder.with_validation_type("FORWARD")
158158

159-
params = mock_builder._build_params()
159+
params = mock_builder.build()
160160

161161
assert params["name"] == "test-scenario"
162162
assert params["input_context"]["problem_statement"] == "Fix the bug"
@@ -171,14 +171,14 @@ def test_build_params_with_all_options(
171171
assert params.get("required_secret_names") == ["db_pass"]
172172
assert params.get("validation_type") == "FORWARD"
173173

174-
def test_build_params_normalizes_weights(self, mock_builder: AsyncScenarioBuilder) -> None:
175-
"""Test that _build_params normalizes scorer weights to sum to 1.0."""
174+
def test_build_normalizes_weights(self, mock_builder: AsyncScenarioBuilder) -> None:
175+
"""Test that build normalizes scorer weights to sum to 1.0."""
176176
mock_builder.with_problem_statement("Fix the bug")
177177
mock_builder.add_bash_script_scorer("scorer1", bash_script="echo 1", weight=1.0)
178178
mock_builder.add_bash_script_scorer("scorer2", bash_script="echo 2", weight=2.0)
179179
mock_builder.add_bash_script_scorer("scorer3", bash_script="echo 3", weight=3.0)
180180

181-
params = mock_builder._build_params()
181+
params = mock_builder.build()
182182
scorers = list(params["scoring_contract"]["scoring_function_parameters"])
183183

184184
# Weights 1, 2, 3 should normalize to 1/6, 2/6, 3/6

tests/sdk/test_scenario_builder.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,21 @@ def test_add_scorer_rejects_invalid_weight(self, mock_builder: ScenarioBuilder)
126126
with pytest.raises(ValueError, match="Scorer weight must be positive"):
127127
mock_builder.add_bash_script_scorer("bad", bash_script="echo 1", weight=-1.0)
128128

129-
def test_build_params_validation(self, mock_builder: ScenarioBuilder) -> None:
130-
"""Test _build_params raises for missing required fields."""
129+
def test_build_validation(self, mock_builder: ScenarioBuilder) -> None:
130+
"""Test build raises for missing required fields."""
131131
# Missing problem statement
132132
mock_builder.add_test_command_scorer("test", test_command="pytest")
133133
with pytest.raises(ValueError, match="Problem statement is required"):
134-
mock_builder._build_params()
134+
mock_builder.build()
135135

136136
# Missing scorer (new builder)
137137
builder2 = ScenarioBuilder("test2", mock_builder._client)
138138
builder2.with_problem_statement("Fix the bug")
139139
with pytest.raises(ValueError, match="At least one scorer is required"):
140-
builder2._build_params()
140+
builder2.build()
141141

142-
def test_build_params_with_all_options(self, mock_builder: ScenarioBuilder, mock_blueprint: Blueprint) -> None:
143-
"""Test _build_params with all optional fields set."""
142+
def test_build_with_all_options(self, mock_builder: ScenarioBuilder, mock_blueprint: Blueprint) -> None:
143+
"""Test build with all optional fields set."""
144144
mock_builder.with_problem_statement("Fix the bug")
145145
mock_builder.with_additional_context({"hint": "line 42"})
146146
mock_builder.add_test_command_scorer("tests", test_command="pytest")
@@ -152,7 +152,7 @@ def test_build_params_with_all_options(self, mock_builder: ScenarioBuilder, mock
152152
mock_builder.with_required_secrets(["db_pass"])
153153
mock_builder.with_validation_type("FORWARD")
154154

155-
params = mock_builder._build_params()
155+
params = mock_builder.build()
156156

157157
assert params["name"] == "test-scenario"
158158
assert params["input_context"]["problem_statement"] == "Fix the bug"
@@ -167,14 +167,14 @@ def test_build_params_with_all_options(self, mock_builder: ScenarioBuilder, mock
167167
assert params.get("required_secret_names") == ["db_pass"]
168168
assert params.get("validation_type") == "FORWARD"
169169

170-
def test_build_params_normalizes_weights(self, mock_builder: ScenarioBuilder) -> None:
171-
"""Test that _build_params normalizes scorer weights to sum to 1.0."""
170+
def test_build_normalizes_weights(self, mock_builder: ScenarioBuilder) -> None:
171+
"""Test that build normalizes scorer weights to sum to 1.0."""
172172
mock_builder.with_problem_statement("Fix the bug")
173173
mock_builder.add_bash_script_scorer("scorer1", bash_script="echo 1", weight=1.0)
174174
mock_builder.add_bash_script_scorer("scorer2", bash_script="echo 2", weight=2.0)
175175
mock_builder.add_bash_script_scorer("scorer3", bash_script="echo 3", weight=3.0)
176176

177-
params = mock_builder._build_params()
177+
params = mock_builder.build()
178178
scorers = list(params["scoring_contract"]["scoring_function_parameters"])
179179

180180
# Weights 1, 2, 3 should normalize to 1/6, 2/6, 3/6

tests/smoketests/sdk/test_async_scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async def push_or_update_scenario(sdk_client: AsyncRunloopSDK, builder: AsyncSce
4646
new_snapshot_id = builder._snapshot.id if builder._snapshot else None
4747

4848
# Update existing scenario with builder's params
49-
params = builder._build_params()
49+
params = builder.build()
5050
result = await scenario.update(**filter_params(params, SDKScenarioUpdateParams))
5151

5252
# Delete OLD blueprint/snapshot if they're being replaced

tests/smoketests/sdk/test_scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def push_or_update_scenario(sdk_client: RunloopSDK, builder: ScenarioBuilder) ->
4545
new_snapshot_id = builder._snapshot.id if builder._snapshot else None
4646

4747
# Update existing scenario with builder's params
48-
params = builder._build_params()
48+
params = builder.build()
4949
result = scenario.update(**filter_params(params, SDKScenarioUpdateParams))
5050

5151
# Delete OLD blueprint/snapshot if they're being replaced

0 commit comments

Comments
 (0)