Skip to content

Commit

Permalink
Get logic of using get and files correct
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonwatts committed Apr 3, 2022
1 parent 412cecb commit 2a5e232
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/servicex_did_finder_lib/communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ async def run_file_fetch_loop(did: str, servicex: ServiceXAdapter, info: Dict[st
async for file_info in user_callback(did_info.did, info):
acc.add(file_info)

acc.send_on(did_info.file_count)
except Exception:
if did_info.get_mode == 'all':
raise

# If we've been holding onto any files, we need to send them now.
acc.send_on(did_info.file_count)

# Simple error checking and reporting
if summary.file_count == 0:
servicex.post_status_update(f'DID Finder found zero files for dataset {did}',
Expand Down
29 changes: 29 additions & 0 deletions tests/servicex_did_finder_lib/test_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,35 @@ async def my_callback(did_name: str, info: Dict[str, Any]) \
SXAdaptor.post_status_update.assert_any_call("Completed load of files in 0 seconds")


def test_failed_file_after_good_with_avail_limited_number(rabbitmq, SXAdaptor):
'Files are sent back, only available allowed, but want a certian number'

async def my_callback(did_name: str, info: Dict[str, Any]) \
-> AsyncGenerator[Dict[str, Any], None]:
yield {
'paths': ["fork/it/over1"],
'adler32': 'no clue',
'file_size': 22323,
'file_events': 0,
}
yield {
'paths': ["fork/it/over2"],
'adler32': 'no clue',
'file_size': 22323,
'file_events': 0,
}
raise Exception('that did not work')

init_rabbit_mq(my_callback, 'http://myrabbit.com', 'test_queue_name', retries=12,
retry_interval=10)
rabbitmq.send_did_request('hi-there?get=available&files=1')

# Make sure the file was sent along, along with the completion
SXAdaptor.put_file_add.assert_called_once()
SXAdaptor.put_fileset_complete.assert_called_once()
SXAdaptor.post_status_update.assert_any_call("Completed load of files in 0 seconds")


def test_no_files_returned(rabbitmq, SXAdaptor):
'Test a callback that fails before any files are sent'

Expand Down

0 comments on commit 2a5e232

Please sign in to comment.