Skip to content

Commit

Permalink
Remove preflight from workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
BenGalewsky committed Jan 25, 2022
1 parent b645b4d commit 7c4e0e1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/servicex_did_finder_lib/communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def run_file_fetch_loop(did: str, servicex: ServiceXAdapter, info: Dict[st
# Track the file, inject back into the system
summary.add_file(file_info)
if summary.file_count == 1:
servicex.post_preflight_check(file_info)
servicex.post_transform_start()
servicex.put_file_add(file_info)

# Simple error checking and reporting
Expand Down
10 changes: 4 additions & 6 deletions src/servicex_did_finder_lib/servicex_adaptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,20 @@ def put_file_add(self, file_info):
self.logger.error(f'After {attempts} tries, failed to send ServiceX App a put_file '
f'message: {str(file_info)} - Ignoring error.')

def post_preflight_check(self, file_entry):
def post_transform_start(self):
success = False
attempts = 0
while not success and attempts < MAX_RETRIES:
try:
requests.post(self.endpoint + "/preflight", json={
'file_path': file_entry['file_path']
})
requests.post(self.endpoint + "/start")
success = True
except requests.exceptions.ConnectionError:
self.logger.exception(f'Connection error to ServiceX App. Will retry '
f'(try {attempts} out of {MAX_RETRIES}')
attempts += 1
if not success:
self.logger.error(f'After {attempts} tries, failed to send ServiceX App a put_file '
f'message: {str(file_entry)} - Ignoring error.')
self.logger.error(f'After {attempts} tries, failed to send ServiceX App a '
f'transform start message - Ignoring error.')

def put_fileset_complete(self, summary):
success = False
Expand Down
3 changes: 1 addition & 2 deletions tests/servicex_did_finder_lib/test_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ async def my_user_callback(did, info):
yield v

await run_file_fetch_loop("123-456", SXAdaptor, {}, my_user_callback)
SXAdaptor.post_preflight_check.assert_called_once
assert SXAdaptor.post_preflight_check.call_args[0][0]['file_path'] == '/tmp/foo'
SXAdaptor.post_transform_start.assert_called_once()

assert SXAdaptor.put_file_add.call_count == 2
assert SXAdaptor.put_file_add.call_args_list[0][0][0]['file_path'] == '/tmp/foo'
Expand Down
11 changes: 11 additions & 0 deletions tests/servicex_did_finder_lib/test_servicex_did.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,14 @@ def test_put_file_add_with_prefix():
assert submitted['adler32'] == '32'
assert submitted['file_events'] == 3141
assert submitted['file_size'] == 1024


@responses.activate
def test_post_transform_start():
responses.add(responses.POST,
'http://servicex.org/servicex/internal/transformation/123-456/start',
status=206)

sx = ServiceXAdapter("http://servicex.org/servicex/internal/transformation/123-456")
sx.post_transform_start()
assert len(responses.calls) == 1

0 comments on commit 7c4e0e1

Please sign in to comment.