mik-laj commented on a change in pull request #4842: [AIRFLOW-4014] Change
DatastoreHook and add tests
URL: https://github.com/apache/airflow/pull/4842#discussion_r262879681
##########
File path: airflow/contrib/hooks/datastore_hook.py
##########
@@ -80,45 +103,55 @@ def commit(self, body):
.. seealso::
https://cloud.google.com/datastore/docs/reference/rest/v1/projects/commit
- :param body: the body of the commit request
- :return: the response body of the commit request
+ :param body: the body of the commit request.
+ :type body: dict
+ :return: the response body of the commit request.
+ :rtype: dict
"""
- resp = self.connection.projects().commit(
- projectId=self.project_id, body=body).execute()
+ self.get_conn()
+
+ resp = self.connection.projects().commit(projectId=self.project_id,
body=body).execute()
return resp
def lookup(self, keys, read_consistency=None, transaction=None):
"""
- Lookup some entities by key
+ Lookup some entities by key.
.. seealso::
https://cloud.google.com/datastore/docs/reference/rest/v1/projects/lookup
- :param keys: the keys to lookup
+ :param keys: the keys to lookup.
+ :type keys: list
:param read_consistency: the read consistency to use. default, strong
or eventual.
- Cannot be used with a transaction.
+ Cannot be used with a transaction.
+ :type read_consistency: str
:param transaction: the transaction to use, if any.
+ :type transaction: str
:return: the response body of the lookup request.
+ :rtype: dict
"""
+ self.get_conn()
+
body = {'keys': keys}
if read_consistency:
body['readConsistency'] = read_consistency
if transaction:
body['transaction'] = transaction
- return self.connection.projects().lookup(
- projectId=self.project_id, body=body).execute()
+ return self.connection.projects().lookup(projectId=self.project_id,
body=body).execute()
def rollback(self, transaction):
"""
- Roll back a transaction
+ Roll back a transaction.
.. seealso::
https://cloud.google.com/datastore/docs/reference/rest/v1/projects/rollback
- :param transaction: the transaction to roll back
+ :param transaction: the transaction to roll back.
+ :type transaction: str
"""
- self.connection.projects().rollback(
- projectId=self.project_id, body={'transaction': transaction})\
+ self.get_conn()
Review comment:
I think you should save the result of the call and use it in the line below.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services