esm icon indicating copy to clipboard operation
esm copied to clipboard

TypeError: ESM3SageMakerClient._post() got an unexpected keyword argument 'return_bytes'

Open kunalaperiambio opened this issue 1 year ago • 2 comments

I am using Cloudformation to deploy ESMC-300M. Then, I am using the code snippet as shared in the Readme of this repo to invoke the model endpoint but I am getting the following error: TypeError: ESM3SageMakerClient._post() got an unexpected keyword argument 'return_bytes'

Here is the code snippet: image

I am also explicitly setting the return_bytes as False but still it isn't working.

Here is the error trace:


TypeError Traceback (most recent call last) Cell In[62], line 13 11 protein = ESMProtein(sequence="AAAAA") 12 protein_tensor = sagemaker_client.encode(protein) ---> 13 logits_output = sagemaker_client.logits( 14 protein_tensor, LogitsConfig(sequence=True, return_embeddings=True), False, 15 ) 16 print(logits_output.logits, logits_output.embeddings)

File ~/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/esm/sdk/forge.py:199, in ESM3ForgeInferenceClient.retry_decorator..wrapper(instance, *args, **kwargs) 188 retry_decorator = retry( 189 retry=retry_if_result(retry_if_specific_error), 190 wait=wait_exponential( (...) 196 before_sleep=log_retry_attempt, 197 ) 198 # Apply the retry decorator to the function --> 199 return retry_decorator(func)(instance, *args, **kwargs)

File ~/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/tenacity/init.py:336, in BaseRetrying.wraps..wrapped_f(*args, **kw) 334 copy = self.copy() 335 wrapped_f.statistics = copy.statistics # type: ignore[attr-defined] --> 336 return copy(f, *args, **kw)

File ~/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/tenacity/init.py:475, in Retrying.call(self, fn, *args, **kwargs) 473 retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs) 474 while True: --> 475 do = self.iter(retry_state=retry_state) 476 if isinstance(do, DoAttempt): 477 try:

File ~/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/tenacity/init.py:376, in BaseRetrying.iter(self, retry_state) 374 result = None 375 for action in self.iter_state.actions: --> 376 result = action(retry_state) 377 return result

File ~/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/tenacity/init.py:398, in BaseRetrying._post_retry_check_actions..(rs) 396 def _post_retry_check_actions(self, retry_state: "RetryCallState") -> None: 397 if not (self.iter_state.is_explicit_retry or self.iter_state.retry_run_result): --> 398 self._add_action_func(lambda rs: rs.outcome.result()) 399 return 401 if self.after is not None:

File ~/anaconda3/envs/pytorch_p310/lib/python3.10/concurrent/futures/_base.py:451, in Future.result(self, timeout) 449 raise CancelledError() 450 elif self._state == FINISHED: --> 451 return self.__get_result() 453 self._condition.wait(timeout) 455 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:

File ~/anaconda3/envs/pytorch_p310/lib/python3.10/concurrent/futures/_base.py:403, in Future.__get_result(self) 401 if self._exception: 402 try: --> 403 raise self._exception 404 finally: 405 # Break a reference cycle with the exception in self._exception 406 self = None

File ~/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/tenacity/init.py:478, in Retrying.call(self, fn, *args, **kwargs) 476 if isinstance(do, DoAttempt): 477 try: --> 478 result = fn(*args, **kwargs) 479 except BaseException: # noqa: B902 480 retry_state.set_exception(sys.exc_info()) # type: ignore[arg-type]

File ~/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/esm/sdk/forge.py:537, in ESM3ForgeInferenceClient.logits(self, input, config, return_bytes) 535 request = {"model": self.model, "inputs": req, "logits_config": logits_config} 536 try: --> 537 data = self._post( 538 "logits", 539 request, 540 input.potential_sequence_of_concern, 541 return_bytes=return_bytes, 542 ) 543 except ESMProteinError as e: 544 return e

TypeError: ESM3SageMakerClient._post() got an unexpected keyword argument 'return_bytes'

Would be happy to share any more requirement needed to debug this issue.

kunalaperiambio avatar Dec 24 '24 15:12 kunalaperiambio

Ah this is a known issue between 3.1.2 and our sagemaker packages. Mind downgrading to 3.1.1?

In the meantime, we're working on a fix.

cmishra avatar Dec 27 '24 20:12 cmishra

Thanks @cmishra , it worked!!

kunalaperiambio avatar Jan 07 '25 13:01 kunalaperiambio

Forgot to update this - but it was fixed in the January update to sagemaker. If folks see this issue they should create a new issue.

cmishra avatar Sep 10 '25 19:09 cmishra