Skip to content

Commit cbe8010

Browse files
committed
rename add_scorer methods to be more clear
1 parent 22821cb commit cbe8010

6 files changed

Lines changed: 40 additions & 40 deletions

File tree

src/runloop_api_client/sdk/async_scenario_builder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _add_scorer(self, name: str, weight: float, scorer: Scorer) -> Self:
151151
self._scorers.append({"name": name, "weight": weight, "scorer": scorer})
152152
return self
153153

154-
def add_test_scorer(
154+
def add_test_command_scorer(
155155
self,
156156
name: str,
157157
*,
@@ -180,7 +180,7 @@ def add_test_scorer(
180180
scorer["test_files"] = test_files
181181
return self._add_scorer(name, weight, scorer)
182182

183-
def add_command_scorer(
183+
def add_shell_command_scorer(
184184
self,
185185
name: str,
186186
*,
@@ -204,7 +204,7 @@ def add_command_scorer(
204204
}
205205
return self._add_scorer(name, weight, scorer)
206206

207-
def add_bash_scorer(
207+
def add_bash_script_scorer(
208208
self,
209209
name: str,
210210
*,
@@ -230,7 +230,7 @@ def add_bash_scorer(
230230
}
231231
return self._add_scorer(name, weight, scorer)
232232

233-
def add_python_scorer(
233+
def add_python_script_scorer(
234234
self,
235235
name: str,
236236
*,

src/runloop_api_client/sdk/scenario_builder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _add_scorer(self, name: str, weight: float, scorer: Scorer) -> Self:
151151
self._scorers.append({"name": name, "weight": weight, "scorer": scorer})
152152
return self
153153

154-
def add_test_scorer(
154+
def add_test_command_scorer(
155155
self,
156156
name: str,
157157
*,
@@ -180,7 +180,7 @@ def add_test_scorer(
180180
scorer["test_files"] = test_files
181181
return self._add_scorer(name, weight, scorer)
182182

183-
def add_command_scorer(
183+
def add_shell_command_scorer(
184184
self,
185185
name: str,
186186
*,
@@ -204,7 +204,7 @@ def add_command_scorer(
204204
}
205205
return self._add_scorer(name, weight, scorer)
206206

207-
def add_bash_scorer(
207+
def add_bash_script_scorer(
208208
self,
209209
name: str,
210210
*,
@@ -230,7 +230,7 @@ def add_bash_scorer(
230230
}
231231
return self._add_scorer(name, weight, scorer)
232232

233-
def add_python_scorer(
233+
def add_python_script_scorer(
234234
self,
235235
name: str,
236236
*,

tests/sdk/test_async_scenario_builder.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_scorers(self, builder: AsyncScenarioBuilder) -> None:
7474
test_files: list[ScorerTestBasedScoringFunctionTestFile] = [
7575
{"file_path": "test_main.py", "file_contents": "def test_foo(): pass"}
7676
]
77-
result = builder.add_test_scorer("test-scorer", test_command="pytest", weight=2.0, test_files=test_files)
77+
result = builder.add_test_command_scorer("test-scorer", test_command="pytest", weight=2.0, test_files=test_files)
7878
assert result is builder
7979
assert builder._scorers[0]["name"] == "test-scorer"
8080
assert builder._scorers[0]["weight"] == 2.0
@@ -83,17 +83,17 @@ def test_scorers(self, builder: AsyncScenarioBuilder) -> None:
8383
assert builder._scorers[0]["scorer"].get("test_files") == test_files
8484

8585
# Command scorer
86-
builder.add_command_scorer("cmd-scorer", command="./check.sh")
86+
builder.add_shell_command_scorer("cmd-scorer", command="./check.sh")
8787
assert builder._scorers[1]["scorer"]["type"] == "command_scorer"
8888
assert builder._scorers[1]["scorer"].get("command") == "./check.sh"
8989

9090
# Bash scorer
91-
builder.add_bash_scorer("bash-scorer", bash_script="echo 'score=1.0'")
91+
builder.add_bash_script_scorer("bash-scorer", bash_script="echo 'score=1.0'")
9292
assert builder._scorers[2]["scorer"]["type"] == "bash_script_scorer"
9393
assert builder._scorers[2]["scorer"].get("bash_script") == "echo 'score=1.0'"
9494

9595
# Python scorer with optional params
96-
builder.add_python_scorer(
96+
builder.add_python_script_scorer(
9797
"python-scorer",
9898
python_script="print('1.0')",
9999
python_version_constraint=">=3.10",
@@ -121,15 +121,15 @@ def test_scorers(self, builder: AsyncScenarioBuilder) -> None:
121121
def test_add_scorer_rejects_invalid_weight(self, builder: AsyncScenarioBuilder) -> None:
122122
"""Test that adding a scorer with zero or negative weight raises ValueError."""
123123
with pytest.raises(ValueError, match="Scorer weight must be positive"):
124-
builder.add_bash_scorer("bad", bash_script="echo 1", weight=0.0)
124+
builder.add_bash_script_scorer("bad", bash_script="echo 1", weight=0.0)
125125

126126
with pytest.raises(ValueError, match="Scorer weight must be positive"):
127-
builder.add_bash_scorer("bad", bash_script="echo 1", weight=-1.0)
127+
builder.add_bash_script_scorer("bad", bash_script="echo 1", weight=-1.0)
128128

129129
def test_build_params_validation(self, builder: AsyncScenarioBuilder) -> None:
130130
"""Test _build_params raises for missing required fields."""
131131
# Missing problem statement
132-
builder.add_test_scorer("test", test_command="pytest")
132+
builder.add_test_command_scorer("test", test_command="pytest")
133133
with pytest.raises(ValueError, match="Problem statement is required"):
134134
builder._build_params()
135135

@@ -143,7 +143,7 @@ def test_build_params_with_all_options(self, builder: AsyncScenarioBuilder, mock
143143
"""Test _build_params with all optional fields set."""
144144
builder.with_problem_statement("Fix the bug")
145145
builder.with_additional_context({"hint": "line 42"})
146-
builder.add_test_scorer("tests", test_command="pytest")
146+
builder.add_test_command_scorer("tests", test_command="pytest")
147147
builder.from_blueprint(mock_blueprint)
148148
builder.with_working_directory("/app")
149149
builder.with_metadata({"team": "infra"})
@@ -168,9 +168,9 @@ def test_build_params_with_all_options(self, builder: AsyncScenarioBuilder, mock
168168
def test_build_params_normalizes_weights(self, builder: AsyncScenarioBuilder) -> None:
169169
"""Test that _build_params normalizes scorer weights to sum to 1.0."""
170170
builder.with_problem_statement("Fix the bug")
171-
builder.add_bash_scorer("scorer1", bash_script="echo 1", weight=1.0)
172-
builder.add_bash_scorer("scorer2", bash_script="echo 2", weight=2.0)
173-
builder.add_bash_scorer("scorer3", bash_script="echo 3", weight=3.0)
171+
builder.add_bash_script_scorer("scorer1", bash_script="echo 1", weight=1.0)
172+
builder.add_bash_script_scorer("scorer2", bash_script="echo 2", weight=2.0)
173+
builder.add_bash_script_scorer("scorer3", bash_script="echo 3", weight=3.0)
174174

175175
params = builder._build_params()
176176
scorers = params["scoring_contract"]["scoring_function_parameters"]
@@ -193,7 +193,7 @@ async def test_push_calls_api_and_returns_scenario(
193193
mock_async_client.scenarios.create.return_value.id = "scn-new-123"
194194

195195
builder.with_problem_statement("Fix the bug")
196-
builder.add_test_scorer("tests", test_command="pytest")
196+
builder.add_test_command_scorer("tests", test_command="pytest")
197197

198198
scenario = await builder.push()
199199

@@ -211,7 +211,7 @@ def test_fluent_chaining(self, builder: AsyncScenarioBuilder, mock_blueprint: As
211211
.with_working_directory("/app")
212212
.with_problem_statement("Fix the bug")
213213
.with_additional_context({"hint": "check main.py"})
214-
.add_test_scorer("tests", test_command="pytest")
214+
.add_test_command_scorer("tests", test_command="pytest")
215215
.with_metadata({"team": "infra"})
216216
.with_reference_output("diff content")
217217
.with_required_env_vars(["API_KEY"])

tests/sdk/test_scenario_builder.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_scorers(self, builder: ScenarioBuilder) -> None:
7272
test_files: list[ScorerTestBasedScoringFunctionTestFile] = [
7373
{"file_path": "test_main.py", "file_contents": "def test_foo(): pass"}
7474
]
75-
result = builder.add_test_scorer("test-scorer", test_command="pytest", weight=2.0, test_files=test_files)
75+
result = builder.add_test_command_scorer("test-scorer", test_command="pytest", weight=2.0, test_files=test_files)
7676
assert result is builder
7777
assert builder._scorers[0]["name"] == "test-scorer"
7878
assert builder._scorers[0]["weight"] == 2.0
@@ -81,17 +81,17 @@ def test_scorers(self, builder: ScenarioBuilder) -> None:
8181
assert builder._scorers[0]["scorer"].get("test_files") == test_files
8282

8383
# Command scorer
84-
builder.add_command_scorer("cmd-scorer", command="./check.sh")
84+
builder.add_shell_command_scorer("cmd-scorer", command="./check.sh")
8585
assert builder._scorers[1]["scorer"]["type"] == "command_scorer"
8686
assert builder._scorers[1]["scorer"].get("command") == "./check.sh"
8787

8888
# Bash scorer
89-
builder.add_bash_scorer("bash-scorer", bash_script="echo 'score=1.0'")
89+
builder.add_bash_script_scorer("bash-scorer", bash_script="echo 'score=1.0'")
9090
assert builder._scorers[2]["scorer"]["type"] == "bash_script_scorer"
9191
assert builder._scorers[2]["scorer"].get("bash_script") == "echo 'score=1.0'"
9292

9393
# Python scorer with optional params
94-
builder.add_python_scorer(
94+
builder.add_python_script_scorer(
9595
"python-scorer",
9696
python_script="print('1.0')",
9797
python_version_constraint=">=3.10",
@@ -119,15 +119,15 @@ def test_scorers(self, builder: ScenarioBuilder) -> None:
119119
def test_add_scorer_rejects_invalid_weight(self, builder: ScenarioBuilder) -> None:
120120
"""Test that adding a scorer with zero or negative weight raises ValueError."""
121121
with pytest.raises(ValueError, match="Scorer weight must be positive"):
122-
builder.add_bash_scorer("bad", bash_script="echo 1", weight=0.0)
122+
builder.add_bash_script_scorer("bad", bash_script="echo 1", weight=0.0)
123123

124124
with pytest.raises(ValueError, match="Scorer weight must be positive"):
125-
builder.add_bash_scorer("bad", bash_script="echo 1", weight=-1.0)
125+
builder.add_bash_script_scorer("bad", bash_script="echo 1", weight=-1.0)
126126

127127
def test_build_params_validation(self, builder: ScenarioBuilder) -> None:
128128
"""Test _build_params raises for missing required fields."""
129129
# Missing problem statement
130-
builder.add_test_scorer("test", test_command="pytest")
130+
builder.add_test_command_scorer("test", test_command="pytest")
131131
with pytest.raises(ValueError, match="Problem statement is required"):
132132
builder._build_params()
133133

@@ -141,7 +141,7 @@ def test_build_params_with_all_options(self, builder: ScenarioBuilder, mock_blue
141141
"""Test _build_params with all optional fields set."""
142142
builder.with_problem_statement("Fix the bug")
143143
builder.with_additional_context({"hint": "line 42"})
144-
builder.add_test_scorer("tests", test_command="pytest")
144+
builder.add_test_command_scorer("tests", test_command="pytest")
145145
builder.from_blueprint(mock_blueprint)
146146
builder.with_working_directory("/app")
147147
builder.with_metadata({"team": "infra"})
@@ -166,9 +166,9 @@ def test_build_params_with_all_options(self, builder: ScenarioBuilder, mock_blue
166166
def test_build_params_normalizes_weights(self, builder: ScenarioBuilder) -> None:
167167
"""Test that _build_params normalizes scorer weights to sum to 1.0."""
168168
builder.with_problem_statement("Fix the bug")
169-
builder.add_bash_scorer("scorer1", bash_script="echo 1", weight=1.0)
170-
builder.add_bash_scorer("scorer2", bash_script="echo 2", weight=2.0)
171-
builder.add_bash_scorer("scorer3", bash_script="echo 3", weight=3.0)
169+
builder.add_bash_script_scorer("scorer1", bash_script="echo 1", weight=1.0)
170+
builder.add_bash_script_scorer("scorer2", bash_script="echo 2", weight=2.0)
171+
builder.add_bash_script_scorer("scorer3", bash_script="echo 3", weight=3.0)
172172

173173
params = builder._build_params()
174174
scorers = params["scoring_contract"]["scoring_function_parameters"]
@@ -188,7 +188,7 @@ def test_push_calls_api_and_returns_scenario(self, builder: ScenarioBuilder, moc
188188
mock_client.scenarios.create.return_value.id = "scn-new-123"
189189

190190
builder.with_problem_statement("Fix the bug")
191-
builder.add_test_scorer("tests", test_command="pytest")
191+
builder.add_test_command_scorer("tests", test_command="pytest")
192192

193193
scenario = builder.push()
194194

@@ -206,7 +206,7 @@ def test_fluent_chaining(self, builder: ScenarioBuilder, mock_blueprint: Bluepri
206206
.with_working_directory("/app")
207207
.with_problem_statement("Fix the bug")
208208
.with_additional_context({"hint": "check main.py"})
209-
.add_test_scorer("tests", test_command="pytest")
209+
.add_test_command_scorer("tests", test_command="pytest")
210210
.with_metadata({"team": "infra"})
211211
.with_reference_output("diff content")
212212
.with_required_env_vars(["API_KEY"])

tests/smoketests/sdk/test_async_scenario.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ async def test_scenario_builder_minimal(self, async_sdk_client: AsyncRunloopSDK)
192192
async_sdk_client.scenario.builder("sdk-smoketest-async-builder-minimal")
193193
.with_problem_statement("Async minimal test problem statement")
194194
.with_metadata(SMOKETEST_METADATA)
195-
.add_command_scorer("async-minimal-scorer", command="echo 1.0")
195+
.add_shell_command_scorer("async-minimal-scorer", command="echo 1.0")
196196
)
197197

198198
info = await push_or_update_scenario(async_sdk_client, builder)
@@ -216,7 +216,7 @@ async def test_scenario_builder_with_blueprint(self, async_sdk_client: AsyncRunl
216216
.with_working_directory("/home/user")
217217
.with_problem_statement("Async blueprint test problem")
218218
.with_metadata(SMOKETEST_METADATA)
219-
.add_command_scorer("async-blueprint-scorer", command="echo 1.0")
219+
.add_shell_command_scorer("async-blueprint-scorer", command="echo 1.0")
220220
)
221221

222222
info = await push_or_update_scenario(async_sdk_client, builder)
@@ -249,7 +249,7 @@ async def test_scenario_builder_with_snapshot(self, async_sdk_client: AsyncRunlo
249249
.from_snapshot(snapshot)
250250
.with_problem_statement("Async snapshot test problem")
251251
.with_metadata(SMOKETEST_METADATA)
252-
.add_command_scorer("async-snapshot-scorer", command="echo 1.0")
252+
.add_shell_command_scorer("async-snapshot-scorer", command="echo 1.0")
253253
)
254254

255255
info = await push_or_update_scenario(async_sdk_client, builder)

tests/smoketests/sdk/test_scenario.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def test_scenario_builder_minimal(self, sdk_client: RunloopSDK) -> None:
191191
sdk_client.scenario.builder("sdk-smoketest-builder-minimal")
192192
.with_problem_statement("Minimal test problem statement")
193193
.with_metadata(SMOKETEST_METADATA)
194-
.add_command_scorer("minimal-scorer", command="echo 1.0")
194+
.add_shell_command_scorer("minimal-scorer", command="echo 1.0")
195195
)
196196

197197
info = push_or_update_scenario(sdk_client, builder)
@@ -215,7 +215,7 @@ def test_scenario_builder_with_blueprint(self, sdk_client: RunloopSDK) -> None:
215215
.with_working_directory("/home/user")
216216
.with_problem_statement("Blueprint test problem")
217217
.with_metadata(SMOKETEST_METADATA)
218-
.add_command_scorer("blueprint-scorer", command="echo 1.0")
218+
.add_shell_command_scorer("blueprint-scorer", command="echo 1.0")
219219
)
220220

221221
info = push_or_update_scenario(sdk_client, builder)
@@ -248,7 +248,7 @@ def test_scenario_builder_with_snapshot(self, sdk_client: RunloopSDK) -> None:
248248
.from_snapshot(snapshot)
249249
.with_problem_statement("Snapshot test problem")
250250
.with_metadata(SMOKETEST_METADATA)
251-
.add_command_scorer("snapshot-scorer", command="echo 1.0")
251+
.add_shell_command_scorer("snapshot-scorer", command="echo 1.0")
252252
)
253253

254254
info = push_or_update_scenario(sdk_client, builder)

0 commit comments

Comments
 (0)