Skip to content

Commit

Permalink
Add final POST message to Panoptes
Browse files Browse the repository at this point in the history
  • Loading branch information
zwolf committed May 28, 2024
1 parent 71528fe commit 1f8b51f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions panoptes_aggregation/batch_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def run_aggregation(project_id, workflow_id, user_id):
ba.upload_files()

# hit up panoptes, let em know you're done
# This could catch PanoptesAPIException, but what to do if it fails?
ba.create_run_in_panoptes()



class BatchAggregator:
Expand Down Expand Up @@ -115,6 +118,21 @@ def upload_files(self):
zipfile = make_archive(f'tmp/{self.id}', 'zip', self.output_path)
self.upload_file_to_storage(self.id, zipfile)

def create_run_in_panoptes(self):
Panoptes.client().post(
'/aggregations/',
json={
'aggregations': {
'uuid': self.id,
'status': 'completed',
'links': {
'workflow': self.workflow_id,
'user': self.user_id
}
}
}
)

def _generate_uuid(self):
self.id = uuid.uuid4().hex

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ def test_upload_file_to_storage(self):
ba.upload_file_to_storage('container', cls_export)
mock_client.upload_blob.assert_called_once

@patch("panoptes_aggregation.batch_aggregation.Panoptes.post")
def test_create_run_in_panoptes(self, mock_poster):
ba = batch_agg.BatchAggregator(1, 10, 100)
ba.create_run_in_panoptes()
mock_poster.assert_called_with('/aggregations/', json={ 'aggregations': { 'uuid': ba.id, 'status': 'completed', 'links': { 'workflow': 10, 'user': 100 } } })

@patch("panoptes_aggregation.batch_aggregation.BlobServiceClient")
def test_connect_blob_storage(self, mock_client):
ba = batch_agg.BatchAggregator(1, 10, 100)
Expand Down

0 comments on commit 1f8b51f

Please sign in to comment.