-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix joblib model loading #542
Conversation
@@ -109,7 +114,8 @@ def generate_code(args): | |||
sys.setrecursionlimit(args.recursion_limit) | |||
|
|||
with args.infile as f: | |||
model = pickle.load(f) | |||
pickle_lib = __import__(args.lib) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unconditional loading of whatever module name is supplied into the CLI feels like a security concern to me. Can we perhaps maintain a list of supported libraries and check whether the supplied argument matches one of them?
parser.add_argument( | ||
"--saved-by", "-sb", | ||
type=str, | ||
dest="lib", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we be a little more specific? Perhaps pickle_lib
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for submitting this PR! A few comments, but is good to go otherwise.
Thanks for review! Fixed issues you mentioned. Glad to be of service, you make brilliant software :) |
@pinktoxin thanks for addressing comments! Would you mind fixing the following linter errors please:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing comments! 🚀
Hi! I faced the problem that some models that were dumped using joblib cannot be loaded using pickle in m2cgen i.e. DecisionTreeClassifier from scikit-learn. This leads to undefined behavior further down in the code.
Works file:
Won't work:
Traceback looks like:
By the way, I'm not the only one with this problem.
#287