Skip to content

Commit

Permalink
Renaming start -> upload, adding TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlynch committed Feb 9, 2018
1 parent 947b47e commit 2b071bd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
9 changes: 5 additions & 4 deletions sia_load_tester/dataset_uploader.py
Expand Up @@ -31,11 +31,11 @@ def __init__(self, input_dataset, sia_client, sleep_fn):
self._sia_client = sia_client
self._sleep_fn = sleep_fn

def start(self):
"""Starts the upload process
def upload(self):
"""Uploads the dataset to Sia.
Begins the upload process and does not return until all files in the
dataset are fully uploaded to Sia.
Uploads and does not return until all files in the dataset are fully
uploaded to Sia.
"""
while not self._upload_queue.empty():
if self._too_many_uploads_in_progress():
Expand All @@ -46,6 +46,7 @@ def start(self):
next_file_path = self._upload_queue.get()
logger.info('Uploading next file to Sia: %s', next_file_path)
self._upload_file_to_sia_async(next_file_path)
# TODO(mtlynch): Wait for uploadprogress to reach 100 for all files.

def _too_many_uploads_in_progress(self):
return self._count_uploads_in_progress() >= _MAX_CONCURRENT_UPLOADS
Expand Down
5 changes: 4 additions & 1 deletion sia_load_tester/main.py
Expand Up @@ -24,8 +24,11 @@ def main(args):
configure_logging()
logger.info('Started runnning')
input_dataset = dataset.load_from_path(args.dataset_root)
# TODO(mtlynch): Ensure 50 contracts are formed.
# TODO(mtlynch): Create upload queue.
uploader = dataset_uploader.make_dataset_uploader(input_dataset)
uploader.start()
uploader.upload()
# TODO(mtlynch): Dump state.


if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions tests/test_dataset_uploader.py
Expand Up @@ -56,7 +56,7 @@ def test_exits_when_all_files_are_on_sia(self):
}
uploader = dataset_uploader.DatasetUploader(
dummy_dataset, self.mock_sia_client, self.mock_sleep_fn)
uploader.start()
uploader.upload()
self.assertEqual(0, self.mock_sia_api_impl.set_renter_upload.call_count)

def test_uploads_file_when_one_is_missing_from_sia(self):
Expand Down Expand Up @@ -90,6 +90,6 @@ def test_uploads_file_when_one_is_missing_from_sia(self):
}
uploader = dataset_uploader.DatasetUploader(
dummy_dataset, self.mock_sia_client, self.mock_sleep_fn)
uploader.start()
uploader.upload()
self.mock_sia_api_impl.set_renter_upload.assert_called_once_with(
'c.txt', source='/dummy-path/c.txt')

0 comments on commit 2b071bd

Please sign in to comment.