5555 60 * 60
5656) # 1 hour - timeout should never happen if cancel on deadline exceeded works
5757
58- TEST_APPLICATION_SUBMIT_AND_FIND_DEADLINE_SECONDS = 60 * 60 * 12 # 24 hours
59- TEST_APPLICATION_SUBMIT_AND_FIND_DUE_DATE_SECONDS = 60 * 60 * 12 # 24 hours
58+ TEST_APPLICATION_SUBMIT_AND_FIND_DEADLINE_SECONDS = 60 * 60 * 1 # 1 hours
59+ TEST_APPLICATION_SUBMIT_AND_FIND_DUE_DATE_SECONDS = 60 * 60 * 1 # 1 hours
6060TEST_APPLICATION_SUBMIT_AND_FIND_SUBMIT_TIMEOUT_SECONDS = 60 * 10 # 10 minutes
6161TEST_APPLICATION_SUBMIT_AND_FIND_FIND_AND_VALIDATE_TIMEOUT_SECONDS = 60 * 30 # 30 minutes
6262
6666 60 * 60 * 5
6767) # 5 hours - timeout should never happen if cancel on deadline exceeded works
6868
69- HETA_APPLICATION_SUBMIT_AND_FIND_DUE_DATE_SECONDS = 60 * 60 * 12 # 24 hours
70- HETA_APPLICATION_SUBMIT_AND_FIND_DEADLINE_SECONDS = 60 * 60 * 12 # 24 hours
69+ HETA_APPLICATION_SUBMIT_AND_FIND_DUE_DATE_SECONDS = 60 * 60 * 12 # 12 hours
70+ HETA_APPLICATION_SUBMIT_AND_FIND_DEADLINE_SECONDS = 60 * 60 * 12 # 12 hours
7171HETA_APPLICATION_SUBMIT_AND_FIND_SUBMIT_TIMEOUT_SECONDS = 60 * 10 # 10 minutes
7272HETA_APPLICATION_SUBMIT_AND_FIND_FIND_AND_VALIDATE_TIMEOUT_SECONDS = 60 * 30 # 30 minutes
7373
@@ -278,12 +278,14 @@ def _submit_and_wait( # noqa: PLR0913, PLR0917
278278 _validate_output (run , Path (temp_dir ), checksum_attribute_key )
279279
280280
281- def _find_and_validate (
281+ def _find_and_validate ( # noqa: PLR0913, PLR0917
282282 application_id : str ,
283283 application_version : str ,
284284 payload : list [platform .InputItem ],
285285 due_date_seconds : int ,
286286 deadline_seconds : int ,
287+ timeout_seconds : int ,
288+ checksum_attribute_key : str = "checksum_base64_crc32c" ,
287289) -> Run :
288290 """Find application run submitted earlier and validate its details.
289291
@@ -293,13 +295,35 @@ def _find_and_validate(
293295 payload (list[platform.InputItem]): The input items for the application run.
294296 due_date_seconds (int): The due date in seconds from now for the application run.
295297 deadline_seconds (int): The deadline in seconds from now for the application run.
298+ timeout_seconds (int): The timeout in seconds to wait for the application run to complete.
299+ checksum_attribute_key (str): The key used to validate the checksum of the output artifacts.
296300
297301 Raises:
298302 AssertionError: If any of the validation checks fail.
299303 """
300304 client = platform .Client ()
301305 assert client is not None , "Failed to create platform client"
302- # TODO(Helmut): Build logic to find the run based on metadata once supported
306+ now = datetime .now (tz = UTC )
307+ check_this_hour_tag = f"find_and_validate:{ now .month } _{ now .day } _{ now .hour } "
308+ runs = client .runs .list (
309+ application_id = application_id ,
310+ application_version = application_version ,
311+ custom_metadata = f'$.sdk.tags[*] ? (@ == "{ check_this_hour_tag } ")' ,
312+ )
313+ checked_runs = 0
314+ for run in runs :
315+ checked_runs += 1
316+ details = run .details ()
317+ assert details .application_id == application_id , (
318+ f"Listed run `{ run .run_id } ` has unexpected application id `{ details .application_id } `"
319+ )
320+ assert details .version_number == application_version , (
321+ f"Listed run `{ run .run_id } ` has unexpected application version `{ details .version_number } `"
322+ )
323+ with tempfile .TemporaryDirectory () as temp_dir :
324+ run .download_to_folder (temp_dir , checksum_attribute_key , timeout_seconds = timeout_seconds )
325+ _validate_output (run , Path (temp_dir ), checksum_attribute_key )
326+ assert checked_runs > 0 , "Expected to find at least one run to validate, but found none."
303327
304328
305329@pytest .mark .e2e
@@ -360,7 +384,7 @@ def test_platform_heta_app_submit_and_wait(record_property) -> None:
360384 )
361385
362386
363- @pytest .mark .skip (reason = "Trialing post having moved HETA to submit and find approach" )
387+ @pytest .mark .skip (reason = "Using submit and wait approach" )
364388@pytest .mark .e2e
365389@pytest .mark .long_running
366390@pytest .mark .timeout (timeout = TEST_APPLICATION_SUBMIT_AND_FIND_SUBMIT_TIMEOUT_SECONDS )
@@ -384,11 +408,10 @@ def test_platform_test_app_submit() -> None:
384408 )
385409
386410
387- @pytest .mark .skip (reason = "To be implemented by Helmut EOD" )
388411@pytest .mark .e2e
389412@pytest .mark .very_long_running
390413@pytest .mark .scheduled_only
391- @pytest .mark .timeout (timeout = TEST_APPLICATION_SUBMIT_AND_FIND_FIND_AND_VALIDATE_TIMEOUT_SECONDS )
414+ @pytest .mark .timeout (timeout = TEST_APPLICATION_SUBMIT_AND_FIND_FIND_AND_VALIDATE_TIMEOUT_SECONDS + 60 * 5 )
392415def test_platform_test_app_find_and_validate () -> None :
393416 """Test application runs with the test application.
394417
@@ -406,6 +429,7 @@ def test_platform_test_app_find_and_validate() -> None:
406429 ),
407430 deadline_seconds = TEST_APPLICATION_SUBMIT_AND_FIND_DEADLINE_SECONDS ,
408431 due_date_seconds = TEST_APPLICATION_SUBMIT_AND_FIND_DUE_DATE_SECONDS ,
432+ timeout_seconds = TEST_APPLICATION_SUBMIT_AND_FIND_FIND_AND_VALIDATE_TIMEOUT_SECONDS ,
409433 )
410434
411435
@@ -433,11 +457,10 @@ def test_platform_heta_app_submit() -> None:
433457 )
434458
435459
436- @pytest .mark .skip (reason = "To be implemented by Helmut EOD" )
437460@pytest .mark .e2e
438461@pytest .mark .very_long_running
439462@pytest .mark .scheduled_only
440- @pytest .mark .timeout (timeout = HETA_APPLICATION_SUBMIT_AND_FIND_FIND_AND_VALIDATE_TIMEOUT_SECONDS )
463+ @pytest .mark .timeout (timeout = HETA_APPLICATION_SUBMIT_AND_FIND_FIND_AND_VALIDATE_TIMEOUT_SECONDS + 60 * 5 )
441464def test_platform_heta_app_find_and_validate () -> None :
442465 """Test application runs with the HETA application.
443466
@@ -455,6 +478,7 @@ def test_platform_heta_app_find_and_validate() -> None:
455478 ),
456479 deadline_seconds = HETA_APPLICATION_SUBMIT_AND_FIND_DEADLINE_SECONDS ,
457480 due_date_seconds = HETA_APPLICATION_SUBMIT_AND_FIND_DUE_DATE_SECONDS ,
481+ timeout_seconds = TEST_APPLICATION_SUBMIT_AND_FIND_FIND_AND_VALIDATE_TIMEOUT_SECONDS ,
458482 )
459483
460484
@@ -473,7 +497,7 @@ def _validate_output(
473497 checksum_attribute_key (str): The key used to validate the checksum of the output artifacts.
474498 """
475499 # validate run state
476- run_details = application_run .details ()
500+ run_details = application_run .details (nocache = True )
477501 assert run_details .state == RunState .TERMINATED , (
478502 f"Run `{ application_run .run_id } `: "
479503 f"Did not finish in state `TERMINATED`, but `{ run_details .state } `.\n "
0 commit comments