aws / sagemaker-core

Apache License 2.0
5 stars 3 forks source link

delete() and stop() - "'Endpoint' object has no attribute 'client'" #27

Closed benieric closed 4 months ago

benieric commented 4 months ago

To reproduce run - https://github.com/aws/sagemaker-core/blob/main/example_notebooks/inference_and_resource_chaining.ipynb

or run below:

from sagemaker_core.generated.resources import Endpoint

for endpoint in Endpoint.get_all(status_equals="InService"):
    endpoint.delete()

Error Message:

{
    "name": "AttributeError",
    "message": "'Endpoint' object has no attribute 'client'",
    "stack": "---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 4
      1 from sagemaker_core.generated.resources import Endpoint
      3 for endpoing in Endpoint.get_all(status_equals=\"InService\"):
----> 4     endpoing.delete()

File ~/.pyenv/versions/3.10.14/envs/py3.10.14/lib/python3.10/site-packages/sagemaker_core/generated/resources.py:3633, in Endpoint.delete(self)
   3628 def delete(self) -> None:
   3630     operation_input_args = {
   3631         \"EndpointName\": self.endpoint_name,
   3632     }
-> 3633     self.client.delete_endpoint(**operation_input_args)

File ~/.pyenv/versions/3.10.14/envs/py3.10.14/lib/python3.10/site-packages/pydantic/main.py:811, in BaseModel.__getattr__(self, item)
    808     return super().__getattribute__(item)  # Raises AttributeError if appropriate
    809 else:
    810     # this is the current error
--> 811     raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')

AttributeError: 'Endpoint' object has no attribute 'client'"
}
benieric commented 4 months ago

Should be fixed in this PR: https://github.com/aws/sagemaker-core/pull/37