-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Model linkage #638
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
Model linkage #638
Conversation
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.
Awesome!
Let's modify one integ test with a deep learning framework to delete the model.
Let's add corresponding unit tests for the 1ps and frameworks :( sorry. AHAHA
src/sagemaker/predictor.py
Outdated
"""Access to the SageMaker Python SDK Model object | ||
|
||
Returns: | ||
object: A SageMaker Python SDK Model object |
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.
I think a little bit more description would be better here.
src/sagemaker/predictor.py
Outdated
@@ -49,13 +49,15 @@ def __init__(self, endpoint, sagemaker_session=None, serializer=None, deserializ | |||
content_type (str): The invocation's "ContentType", overriding any ``content_type`` from | |||
the serializer (default: None). | |||
accept (str): The invocation's "Accept", overriding any accept from the deserializer (default: None). | |||
model (sagemaker.model.Model): A SageMaker Python SDK Model object. |
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.
Default? What happens when it is None?
… transformer to delete model.
…on and transformer.
… transformer to delete model.
…on and transformer.
@@ -8,8 +8,8 @@ CHANGELOG | |||
* doc-fix: update information about saving models in the MXNet README | |||
* doc-fix: change ReadTheDocs links from latest to stable | |||
* doc-fix: add ``transform_fn`` information and fix ``input_fn`` signature in the MXNet README | |||
* feature: Support for ``Predictor`` to delete endpoint configuration by default when calling ``delete_endpoint()`` | |||
* feature: Support for ``model`` to delete SageMaker model | |||
* feature: Support for ``Predictor`` to delete model, and delete endpoint configuration by default when calling ``delete_endpoint()`` |
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.
Your feature addition needs to be separate and in a new version, as your last PR go merged and released to PyPI already.
https://github.com/aws/sagemaker-python-sdk/releases/tag/v1.18.3
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.
ohh. So the next version should be 1.18.4.dev?
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.
I would say 'add support for..." to be consistent
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.
even better would be something like "feature: Predictor: delete model and endpoint configuration by default when calling delete_endpoint()
", though we've been extremely inconsistent in keeping that format
src/sagemaker/predictor.py
Outdated
delete_endpoint_config (bool): Flag to indicate whether to delete the corresponding SageMaker endpoint | ||
configuration tied to the endpoint. If False, only the endpoint will be deleted. (default: True) | ||
delete_endpoint_config (bool): Flag to indicate whether to delete endpoint configuration together with | ||
endpoint. If False, only endpoint will be deleted. Default: True. |
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.
Let's follow this for our docstrings.
https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
endpoint_config = self.sagemaker_session.sagemaker_client.describe_endpoint_config( | ||
EndpointConfigName=endpoint_config_name) | ||
production_variants = endpoint_config['ProductionVariants'] | ||
return map(lambda d: d['ModelName'], production_variants) |
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.
It looks like it is possible for multiple models to exist behind an endpoint configuration and endpoint.
Let's make sure this class also has the delete_model functionality as well.
https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/pipeline.py
Here is an example on how it is done:
https://github.com/awslabs/amazon-sagemaker-examples/blob/master/sagemaker-python-sdk/scikit_learn_inference_pipeline/Inference%20Pipeline%20with%20Scikit-learn%20and%20Linear%20Learner.ipynb
We should make sure the deletion of multiple models in the same endpoint configuration is tested in an integ test.
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.
Something to consider is that this solution assumes the endpoint configuration exists. It is possible for a user to call delete_endpoint() and that might error out when they call delete_model().
Technically, the model object does still exist within SageMaker. It arguably makes sense to actually delete the endpoint first, then endpoint configuration and then model since they all have dependency on each other. I believe SageMaker allows you to delete them regardless of order, since they snapshot everything, however this problem can still persist if the user deletes the endpoint first.
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.
Just to confirm, for Pipeline
, delete_model()
should delete all the SageMaker models from the list[sagemaker.Model] and delete the model with name
(if name
is not None)?
And for the order of deletions, if endpoint/endpoint config is deleted before attempting to delete model, should we say something like "model cannot be deleted because the attached endpoint/endpoint config is already gone"?
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.
Let's initialize the model name in the constructor per our in person discussion.
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.
We're going to call describe_endpoint()
and describe_endpoint_config()
once the Predictor
gets endpoint_name
in the constructor, so that we don't restrict the order of deletions to model -> endpoint/endpoint config.
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.
Change the existing delete_endpoint() functionality to depend on the endpoint_configuration_name instead of describing it.
endpoint_description = self.sagemaker_session.sagemaker_client.describe_endpoint(EndpointName=self.endpoint) |
tests/unit/test_predictor.py
Outdated
endpoint_desc = { | ||
'EndpointConfigName': 'my-endpoint-config' | ||
} | ||
endpoint_config_desc = { |
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 unit test an endpoint configuration with multiple models?
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.
Yes, will do this in next revision.
@@ -8,8 +8,8 @@ CHANGELOG | |||
* doc-fix: update information about saving models in the MXNet README | |||
* doc-fix: change ReadTheDocs links from latest to stable | |||
* doc-fix: add ``transform_fn`` information and fix ``input_fn`` signature in the MXNet README | |||
* feature: Support for ``Predictor`` to delete endpoint configuration by default when calling ``delete_endpoint()`` | |||
* feature: Support for ``model`` to delete SageMaker model | |||
* feature: Support for ``Predictor`` to delete model, and delete endpoint configuration by default when calling ``delete_endpoint()`` |
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.
I would say 'add support for..." to be consistent
* feature: Support for ``Predictor`` to delete endpoint configuration by default when calling ``delete_endpoint()`` | ||
* feature: Support for ``model`` to delete SageMaker model | ||
* feature: Support for ``Predictor`` to delete model, and delete endpoint configuration by default when calling ``delete_endpoint()`` | ||
* feature: Support for ``Model`` to delete SageMaker model | ||
* feature: Support for ``Transformer`` to delete SageMaker 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.
I guess we are already not consistent -_- . So it's up to you
endpoint_config = self.sagemaker_session.sagemaker_client.describe_endpoint_config( | ||
EndpointConfigName=endpoint_config_name) | ||
production_variants = endpoint_config['ProductionVariants'] | ||
return map(lambda d: d['ModelName'], production_variants) |
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.
Let's initialize the model name in the constructor per our in person discussion.
src/sagemaker/predictor.py
Outdated
for model_name in self._model_names: | ||
self.sagemaker_session.delete_model(model_name) | ||
|
||
def _get_model_names(self): |
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.
this method does more than get the model names, it also get's the endpoint config name and sets it.
@@ -33,7 +33,7 @@ def read(fname): | |||
required_packages.append('enum34>=1.1.6') | |||
|
|||
setup(name="sagemaker", | |||
version='1.18.2', | |||
version='1.18.3.post1', |
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.
your branch might be out of date?
Closing in favor of #647 |
Issue #, if available:
#447
Description of changes:
Continuation of #630
Let
Predictor
delete SageMaker model directly in align withTransformer
.Merge Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.