Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Read from s3 #16

Merged
merged 8 commits into from
Nov 2, 2018
Merged

Read from s3 #16

merged 8 commits into from
Nov 2, 2018

Conversation

oliver-tarrant-tessella
Copy link
Collaborator

#3

@@ -3,4 +3,4 @@
.idea/
.pytest_cache/
deployment/
venv/
venv/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have files end with a new line

ditto_web_api/DittoWebApi/main.py Outdated Show resolved Hide resolved

class ListPresentHandler(tornado.web.RequestHandler):
def initialize(self, data_replication_service):
self.data_replication_service = data_replication_service
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to self._data_replication_service (i.e. add underscore)

@@ -7,3 +9,14 @@ def __init__(self, configuration):
configuration.s3_access_key,
configuration.s3_secret_key,
configuration.s3_use_secure)
self._buckets = self.s3_client.list_buckets()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably fine, but in case the buckets change while the service is running please call this inside get_buckets() instead.

Also, could you please add an underscore at the start of s3_client? My mistake!

self.test_service = DataReplicationService(self.mock_external_data_service, self.mock_internal_data_service,
self.mock_logger)

def test_retrieve_objects_returns_all_json_objects(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the name of this method appropriate? I don't see any JSON here.
Also, as in list_present_handler_test.py, please test more scenarios (no objects, multiple objects, etc)

@@ -48,5 +48,6 @@ def setup_logger(log_file_location, level):
app = tornado.web.Application([
(r"/", MainHandler, dict(data_replication_service=data_replication_service)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should change to

(r"/listpresent/", ListPresentHandler, dict(data_replication_service=data_replication_service)),

(you'll need to update the imports too)

We can delete the main_handler.py file at that stage, as it's no longer needed.

buckets = self._external_data_service.get_buckets()
objects = self._external_data_service.get_objects(buckets)
object_dicts = [obj.to_dict for obj in objects]
self._logger.info("Found {} objects".format(len(objects)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we now have the buckets here, could we add the number of them to the log message?

self._logger.info("Found {} objects in {} buckets".format(len(objects), len(buckets))

@robert-clegg-tessella robert-clegg-tessella merged commit 722f382 into master Nov 2, 2018
@robert-clegg-tessella robert-clegg-tessella deleted the Read_from_S3 branch November 2, 2018 11:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
ditto
  
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

2 participants