From 127d3a3571a85d5af548d4529185d40f5520a478 Mon Sep 17 00:00:00 2001 From: Villu Ruusmann Date: Sun, 8 Dec 2024 10:11:04 +0200 Subject: [PATCH] Added command-line interface --- sklearn2pmml/__main__.py | 4 ++++ sklearn2pmml/cli.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 sklearn2pmml/__main__.py create mode 100644 sklearn2pmml/cli.py diff --git a/sklearn2pmml/__main__.py b/sklearn2pmml/__main__.py new file mode 100644 index 0000000..6c316d5 --- /dev/null +++ b/sklearn2pmml/__main__.py @@ -0,0 +1,4 @@ +from sklearn2pmml.cli import main + +if __name__ == "__main__": + main() diff --git a/sklearn2pmml/cli.py b/sklearn2pmml/cli.py new file mode 100644 index 0000000..8aa9b84 --- /dev/null +++ b/sklearn2pmml/cli.py @@ -0,0 +1,16 @@ +from argparse import ArgumentParser +from sklearn2pmml import sklearn2pmml + +import joblib + +def main(): + parser = ArgumentParser(prog = "sklearn2pmml", description = "SkLearn2PMML command-line application") + parser.add_argument("-i", "--input", type = str, required = True, help = "Input Pickle file") + parser.add_argument("-o", "--output", type = str, required = True, help = "Output PMML file") + parser.add_argument("--schema", type = str, help = "Output PMML schema version") + + args = parser.parse_args() + + estimator = joblib.load(args.input) + + sklearn2pmml(estimator, pmml_path = args.output, pmml_schema = args.schema)