From 7c4e0e1a8845a9d6c116e7de90cf4540526c1177 Mon Sep 17 00:00:00 2001 From: Ben Galewsky Date: Thu, 28 Oct 2021 15:53:59 -0500 Subject: [PATCH] Remove preflight from workflow --- src/servicex_did_finder_lib/communication.py | 2 +- src/servicex_did_finder_lib/servicex_adaptor.py | 10 ++++------ tests/servicex_did_finder_lib/test_communication.py | 3 +-- tests/servicex_did_finder_lib/test_servicex_did.py | 11 +++++++++++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/servicex_did_finder_lib/communication.py b/src/servicex_did_finder_lib/communication.py index a0200d0..c0d76f4 100644 --- a/src/servicex_did_finder_lib/communication.py +++ b/src/servicex_did_finder_lib/communication.py @@ -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 diff --git a/src/servicex_did_finder_lib/servicex_adaptor.py b/src/servicex_did_finder_lib/servicex_adaptor.py index cb6f769..7e05d19 100644 --- a/src/servicex_did_finder_lib/servicex_adaptor.py +++ b/src/servicex_did_finder_lib/servicex_adaptor.py @@ -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 diff --git a/tests/servicex_did_finder_lib/test_communication.py b/tests/servicex_did_finder_lib/test_communication.py index 380dad5..2ecbef9 100644 --- a/tests/servicex_did_finder_lib/test_communication.py +++ b/tests/servicex_did_finder_lib/test_communication.py @@ -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' diff --git a/tests/servicex_did_finder_lib/test_servicex_did.py b/tests/servicex_did_finder_lib/test_servicex_did.py index 4f01528..d18d3d6 100644 --- a/tests/servicex_did_finder_lib/test_servicex_did.py +++ b/tests/servicex_did_finder_lib/test_servicex_did.py @@ -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