Skip to content
Prev Previous commit
Next Next commit
Make provider conversion context keyword-only
  • Loading branch information
csadorf committed Nov 10, 2026
commit 214907452db959ae2d700c4759bac4aa69840b74
4 changes: 2 additions & 2 deletions python/cuml/cuml/benchmark/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def _prepare_case(
operation_data = train if is_fit else measured
operation_args = tuple(
provider.convert_data(
case.estimator,
operation_data[name],
estimator=case.estimator,
role=name,
representation=representations[name],
)
Expand All @@ -182,8 +182,8 @@ def _prepare_case(
if is_fit
else tuple(
provider.convert_data(
case.estimator,
train[name],
estimator=case.estimator,
role=name,
representation=representations[name],
)
Expand Down
2 changes: 1 addition & 1 deletion python/cuml/cuml/benchmark/providers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class Provider:

def convert_data(
self,
estimator: str,
value: Any,
*,
estimator: str,
role: Literal["X", "y"],
representation: InputRepresentation,
) -> Any:
Expand Down
7 changes: 5 additions & 2 deletions python/cuml/cuml/benchmark/providers/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ class DaskProvider(Provider):

def convert_data(
self,
estimator: str,
value: Any,
*,
estimator: str,
role: Literal["X", "y"],
representation: InputRepresentation,
) -> Any:
Expand All @@ -83,7 +83,10 @@ def convert_data(
if estimator == "LabelEncoder" and role == "y":
representation = "series"
return super().convert_data(
estimator, value, role=role, representation=representation
value,
estimator=estimator,
role=role,
representation=representation,
)


Expand Down
8 changes: 4 additions & 4 deletions python/cuml/tests/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -2565,10 +2565,10 @@ def test_dask_input_conversion(estimator):
y = np.arange(64, dtype=np.int64) % 3
provider = get_provider("cuml.dask")
converted_X = provider.convert_data(
estimator, X, role="X", representation="array"
X, estimator=estimator, role="X", representation="array"
)
converted_y = provider.convert_data(
estimator, y, role="y", representation="array"
y, estimator=estimator, role="y", representation="array"
)
assert isinstance(converted_X._meta, cp.ndarray)
cp.testing.assert_array_equal(converted_X.compute(), cp.asarray(X))
Expand Down Expand Up @@ -3144,7 +3144,7 @@ def test_harness_converts_selected_host_partitions(monkeypatch, inference):
calls = []

class RecordingProvider(Provider):
def convert_data(self, estimator, value, *, role, representation):
def convert_data(self, value, *, estimator, role, representation):
assert estimator == case.estimator
assert representation == "array"
calls.append((role, value))
Expand Down Expand Up @@ -3197,7 +3197,7 @@ def convert(value, *, representation):

monkeypatch.setattr(provider.backend, "convert_data", convert)
result = provider.convert_data(
estimator, value, role=role, representation="array"
value, estimator=estimator, role=role, representation="array"
)
if provider_name == "cuml.dask" and estimator == "DBSCAN":
assert result is value
Expand Down