-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Stabilizing methods in Python Models modules #1226
Conversation
Cool! |
Error from providing only a subset:
seems fine! |
Yeah we could make them optional and put validation inside the methods for them if this turns out to be confusing, but I think it is okay for now. |
mlflow/utils/annotations.py
Outdated
@wraps(func) | ||
def wrapper(*args, **kwargs): | ||
if len(args) > 0: | ||
raise TypeError("Method %s only accepts keyword arguments." % func.__name__) |
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.
-> requires
let's add keyword_only to mleap as well |
|
||
FLAVOR_NAME = "mleap" | ||
|
||
|
||
@keyword_only |
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.
@dbczumar I think you mentioned these might be used in sagemaker container? i didn't see them used anywhere actually - let me know if I'm missing something (hopefully the tests will tell me if I am but just in case)
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.
add_to_model
is used in mlflow.spark.save_model
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.
right, I wasn't going to keyword_only add_to_model
since the sample_df
param is the last one. i guess we might as well... :-/
To make the methods in Models modules stable in MLflow 1.0, we want to future-proof them against any potential changes in the underlying frameworks (e.g. sklearn, spark, tensorflow). To do so, here we propose to make some methods take in keyword arguments only, by introducing a keyword_only decorator that enforces such. We apply the keyword_only decorator to `log_model`, `save_model` and `add_to_model` methods in the `tensorflow` and `mleap` modules.
What changes are proposed in this pull request?
To make the methods in Models modules stable in MLflow 1.0, we want to future-proof them against any potential changes in the underlying frameworks (e.g. sklearn, spark, tensorflow). To do so, here we propose to make some methods take in keyword arguments only, by introducing a
keyword_only
decorator that enforces such.The change is breaking for any current usages of the APIs, so here we recommend changing only the TensorFlow APIs which may need to change in the near future:
Alternatively, we could not put any restrictions and create new modules (e.g.
tensorflow2
) in the future as needed.If we go with the
keyword_only
decorator route, the following also may merit the decorator if we think the requirement for asample_df
inmleap
will change in the future:but the current PR does not mark them as so.
How is this patch tested?
Existing & new unit tests
Release Notes
Is this a user-facing change?
We now require the arguments of
save_model
andlog_model
methods in thetensorflow
andmleap
modules to be keyword arguments. This is to future-proof their usages against API changes involving the TensorFlow model specification.What component(s) does this PR affect?
How should the PR be classified in the release notes? Choose one:
rn/breaking-change
- The PR will be mentioned in the "Breaking Changes" section