Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 0 additions & 53 deletions python/cuml/cuml/accel/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import argparse
import sys
import warnings
from textwrap import dedent

import cuml.accel.runners as runners
Expand Down Expand Up @@ -85,26 +84,6 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
action="store_true",
help="Disable UVM (managed memory) allocations.",
)
# --convert-to-sklearn, --format, --output, and --cudf-pandas are deprecated
# and hidden from the CLI --help with `argparse.SUPPRESS
parser.add_argument("--convert-to-sklearn", help=argparse.SUPPRESS)
parser.add_argument(
"--format",
choices=["pickle", "joblib"],
type=str.lower,
default="pickle",
help=argparse.SUPPRESS,
)
parser.add_argument(
"--output",
default="converted_sklearn_model.pkl",
help=argparse.SUPPRESS,
)
parser.add_argument(
"--cudf-pandas",
action="store_true",
help=argparse.SUPPRESS,
)
group = parser.add_mutually_exclusive_group()
group.add_argument(
"-m",
Expand Down Expand Up @@ -159,38 +138,6 @@ def main(argv: list[str] | None = None):
# Parse arguments
ns = parse_args(sys.argv[1:] if argv is None else argv)

# If the user requested a conversion, handle it and exit
if ns.convert_to_sklearn:
warnings.warn(
"`--convert-to-sklearn`, `--format`, and `--output` are deprecated and will "
"be removed in 25.10. Estimators created with `cuml.accel` may now be "
"serialized and loaded in environments without `cuml` without the need for "
"running a conversion step.",
FutureWarning,
)
with open(ns.convert_to_sklearn, "rb") as f:
if ns.format == "pickle":
import pickle as serializer
elif ns.format == "joblib":
import joblib as serializer
estimator = serializer.load(f)

with open(ns.output, "wb") as f:
serializer.dump(estimator, f)
sys.exit()

# Enable cudf.pandas if requested
if ns.cudf_pandas:
warnings.warn(
"`--cudf-pandas` is deprecated and will be removed in 25.10. Instead, please "
"invoke both accelerators explicitly like\n\n"
" $ python -m cudf.pandas -m cuml.accel ...",
FutureWarning,
)
import cudf.pandas

cudf.pandas.install()

# Parse verbose into log_level
log_level = {0: "warn", 1: "info", 2: "debug"}.get(min(ns.verbose, 2))

Expand Down
70 changes: 0 additions & 70 deletions python/cuml/cuml_accel_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import os
import pickle
import pty
import re
import subprocess
Expand Down Expand Up @@ -132,19 +131,6 @@ def test_parse_verbose():
assert ns.verbose == 3


def test_parse_format():
ns = parse_args(["--format", "pickle"])
assert ns.format == "pickle"

ns = parse_args(["--format", "JOBLIB"])
assert ns.format == "joblib"

# Invalid formats error
with pytest.raises(SystemExit) as exc:
parse_args(["--format", "invalid"])
assert exc.value.code != 0


def run(args=None, stdin=None, env=None, expected_returncode=0):
# Run without `CUML_ACCEL_ENABLED` defined by default to test
# the other accelerator loading mechanisms
Expand Down Expand Up @@ -331,23 +317,6 @@ def test_cli_mix_cuml_accel_and_cudf_pandas(first, second, tmpdir):
assert "ok\n" in stdout


def test_cli_cudf_pandas():
script = dedent(
"""
import cuml.accel
import cudf.pandas

assert cuml.accel.enabled()
assert cudf.pandas.LOADED

# Print here to assert the script actually ran by checking the output
print("ok")
"""
)
stdout = run(["-m", "cuml.accel", "--cudf-pandas"], stdin=script)
assert "ok\n" in stdout


@pytest.mark.parametrize(
"args, level", [([], "warn"), (["-v"], "info"), (["-vv"], "debug")]
)
Expand All @@ -362,45 +331,6 @@ def test_cli_verbose(args, level):
run(["-m", "cuml.accel", *args], stdin=script)


def test_cli_convert_to_sklearn(tmpdir):
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression

X, y = make_classification(random_state=42)
lr = LogisticRegression().fit(X, y)

original = tmpdir.join("original.pkl")
original.write(pickle.dumps(lr), mode="wb")
output = tmpdir.join("output.pkl")

script = dedent(
f"""
import cuml.accel
import pickle

with open({str(output)!r}, "rb") as f:
new = pickle.load(f)

assert not cuml.accel.is_proxy(new)
"""
)

# Run the conversion script
run(
[
"-m",
"cuml.accel",
"--convert-to-sklearn",
original,
"--output",
output,
]
)

# Check in a new process if the reloaded estimator is a proxy estimator
run(stdin=script)


@pytest.mark.parametrize("mode", ["script", "module", "cmd", "stdin"])
@pytest.mark.parametrize(
"options",
Expand Down