PynamoDB uses deprecated (now removed) botocore services API
Our table name is 'Session', upon trying to Query it we now get the error 'Session' object has no attribute 'get_service'.
/usr/local/lib/python2.7/site-packages/pynamodb/connection/table.py", line 83, in put_item\n return_item_collection_metrics=return_item_collection_metrics)\n File "/usr/local/lib/python2.7/site-packages/pynamodb/connection/base.py", line 656, in put_item\n operation_kwargs.update(self.get_identifier_map(table_name, hash_key, range_key, key=ITEM))\n File "/usr/local/lib/python2.7/site-packages/pynamodb/connection/base.py", line 497, in get_identifier_map\n tbl = self.get_meta_table(table_name)\n File "/usr/local/lib/python2.7/site-packages/pynamodb/connection/base.py", line 265, in get_meta_table\n response, data = self.dispatch(DESCRIBE_TABLE, operation_kwargs)\n File "/usr/local/lib/python2.7/site-packages/pynamodb/connection/base.py", line 213, in dispatch\n response, data = self.service.get_operation(operation_name).call(self.endpoint, **operation_kwargs)\n File "/usr/local/lib/python2.7/site-packages/pynamodb/connection/base.py", line 244, in service\n return self.session.get_service(SERVICE_NAME)\nAttributeError: 'Session' object has no attribute 'get_service'
The issue seems to be that PynamoDB uses deprecated method session.get_service instead of create_client in botocore module. Perhaps updating to 1.3.7 updated the botocore depedency version and thats what broke it. In any case, I think the fix is to switch to create_client inside of /pynamodb/connection/base.py (line 244).
Okay here is an article explaining the botocore change: http://botocore.readthedocs.org/en/latest/client_upgrades.html
+1
I've been seeing the following 5 warnings for quite some time, they probably did what they promissed :)
...site-packages/botocore/session.py:564: ImminentRemovalWarning: get_service is deprecated and will be removed. Use create_client instead.
"Use create_client instead.", ImminentRemovalWarning)
...site-packages/botocore/service.py:231: ImminentRemovalWarning: get_service is deprecated and will be removed. Use Session.create_client instead.
ImminentRemovalWarning)
...site-packages/botocore/service.py:189: ImminentRemovalWarning: get_operation is deprecated and will be removed. Use create_client instead.
"Use create_client instead.", ImminentRemovalWarning)
...site-packages/botocore/service.py:161: ImminentRemovalWarning: get_endpoint is deprecated and will be removed. Use create_client instead.
"Use create_client instead.", ImminentRemovalWarning)
...site-packages/botocore/operation.py:105: ImminentRemovalWarning: call() is deprecated and will be removed. Use clients instead.
"Use clients instead.", ImminentRemovalWarning)
Tried a basic fix for this. kind of hackey.
https://github.com/finiteint/PynamoDB/tree/botocore-clients-only
The changes are limited to:
-
switching to client -- added a
clientproperty as a replacement for theserviceproperty which creates the client like this:self.session.create_client(SERVICE_NAME, region_name=self.region) -
updating
dispatchto convert snake-case names to camel-case (did this to reduce the amount code to change, but ideally we would want to make the call sites not convert the original camel-case to snake-case in the first place):data = getattr(self.client, pythonic(operation_name))(**dict( (unpythonic(key), value) for key, value in operation_kwargs.items() )) -
checking for exceptions instead of checking the HTTP response code, e.g.:
try: return self.dispatch(DELETE_TABLE, operation_kwargs) except (ClientError, BotoCoreError) as e: raise TableError("Failed to delete table: {0}".format(e))
Note: the new API uses the AWS API's camel-case for the method parameters (unlike the old one which used snake-case.)
Old API:
operation.call(an_arg='blah')
New API:
operation(AnArg='balh')
I had the same issue. Pynamodb does not work with botocore 1.0. When can Pynamodb upgrade to support botocore 1.0?