Skip to content

Commit

Permalink
Hide the '--language' argument
Browse files Browse the repository at this point in the history
  • Loading branch information
nok committed Sep 9, 2017
1 parent 41b93a0 commit fc14a3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,20 @@ joblib.dump(clf, 'estimator.pkl')

After that the model can be transpiled by using the following command:

```bash
python -m sklearn_porter --input <PICKLE_FILE> [--output <DEST_DIR>] [--language {c,go,java,js,php,ruby}] [--c] [--java] [--js] [--go] [--php] [--ruby]
python -m sklearn_porter -i <PICKLE_FILE> [-o <DEST_DIR>] [-l {c,go,java,js,php,ruby}] [--c] [--java] [--js] [--go] [--php] [--ruby]
```
python -m sklearn_porter --input <PICKLE_FILE> [--output <DEST_DIR>] [--c] [--java] [--js] [--go] [--php] [--ruby]
python -m sklearn_porter -i <PICKLE_FILE> [-o <DEST_DIR>] [--c] [--java] [--js] [--go] [--php] [--ruby]
```

For instance the following command transpiles the estimator to the target programming language Java:

```bash
```
python -m sklearn_porter -i estimator.pkl --java
```

You can change the target programming language on the fly:

```bash
```
python -m sklearn_porter -i estimator.pkl --c
python -m sklearn_porter -i estimator.pkl --go
python -m sklearn_porter -i estimator.pkl --js
Expand All @@ -261,7 +261,7 @@ python -m sklearn_porter -i estimator.pkl --ruby

Further information will be shown by using the `--help` parameter:

```bash
```
python -m sklearn_porter --help
python -m sklearn_porter -h
```
Expand Down
15 changes: 6 additions & 9 deletions sklearn_porter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def parse_args(args):
'--input', '-i',
required=True,
help=(
'Set the path of an exported model '
'Set the path of an exported estimator '
'in pickle (.pkl) format.'))
parser.add_argument(
'--output', '-o',
Expand All @@ -41,10 +41,7 @@ def parse_args(args):
choices=languages.keys(),
default='java',
required=False,
help=(
'Set the target programming language '
'({}).'.format(', '.join(['"{}"'.format(key)
for key in languages.keys()]))))
help=argparse.SUPPRESS)
for key, lang in list(languages.items()):
parser.add_argument(
'--{}'.format(key),
Expand All @@ -62,7 +59,7 @@ def main():

# Load data:
from sklearn.externals import joblib
model = joblib.load(input_path)
estimator = joblib.load(input_path)

# Determine the target programming language:
language = str(args['language']) # with default language
Expand All @@ -72,8 +69,8 @@ def main():
language = key
break

# Port model:
porter = Porter(model, language=language)
# Port estimator:
porter = Porter(estimator, language=language)
details = porter.export(details=True)
filename = details.get('filename')

Expand All @@ -92,7 +89,7 @@ def main():
with open(dest_path, 'w') as file_:
file_.write(details.get('model'))
else:
raise ValueError('No valid model in pickle format was found.')
raise ValueError('No valid estimator in pickle format was found.')

if __name__ == "__main__":
main()

0 comments on commit fc14a3b

Please sign in to comment.