@@ -344,23 +344,10 @@ def add_ext_key_value(self, key, value):
344344 return self
345345
346346 @classmethod
347- def generate_pending (cls , name , results = None ):
347+ def create_new (cls , name , status , links = None , info = "" , results = None ):
348348 return Result (
349349 name = name ,
350- status = Result .Status .PENDING ,
351- start_time = None ,
352- duration = None ,
353- results = results or [],
354- files = [],
355- links = [],
356- info = "" ,
357- )
358-
359- @classmethod
360- def generate_skipped (cls , name , links = None , info = "" , results = None ):
361- return Result (
362- name = name ,
363- status = Result .Status .SKIPPED ,
350+ status = status ,
364351 start_time = None ,
365352 duration = None ,
366353 results = results or [],
@@ -511,10 +498,10 @@ def to_stdout_formatted(self, indent="", res=""):
511498
512499class ResultInfo :
513500 SETUP_ENV_JOB_FAILED = (
514- "Failed to set up job env, it's praktika bug or misconfiguration"
501+ "Failed to set up job env, it is praktika bug or misconfiguration"
515502 )
516503 PRE_JOB_FAILED = (
517- "Failed to do a job pre-run step, it's praktika bug or misconfiguration"
504+ "Failed to do a job pre-run step, it is praktika bug or misconfiguration"
518505 )
519506 KILLED = "Job killed or terminated, no Result provided"
520507 NOT_FOUND_IMPOSSIBLE = (
@@ -556,20 +543,21 @@ def copy_result_from_s3_with_version(cls, local_path):
556543 env = _Environment .get ()
557544 file_name = Path (local_path ).name
558545 local_dir = Path (local_path ).parent
559- file_name_pattern = f"{ file_name } _*"
560- for file_path in local_dir .glob (file_name_pattern ):
561- file_path .unlink ()
562- s3_path = f"{ Settings .HTML_S3_PATH } /{ env .get_s3_prefix ()} /"
563- S3 .copy_file_from_s3_matching_pattern (
564- s3_path = s3_path , local_path = local_dir , include = file_name_pattern
546+ s3_path = f"{ Settings .HTML_S3_PATH } /{ env .get_s3_prefix ()} "
547+ latest_result_file = Shell .get_output (
548+ f"aws s3 ls { s3_path } /{ file_name } _ | awk '{{print $4}}' | sort -r | head -n 1" ,
549+ strict = True ,
550+ verbose = True ,
551+ )
552+ version = int (latest_result_file .split ("_" )[- 1 ])
553+ S3 .copy_file_from_s3 (
554+ s3_path = f"{ s3_path } /{ latest_result_file } " , local_path = local_dir
555+ )
556+ Shell .check (
557+ f"cp { local_dir } /{ latest_result_file } { local_path } " ,
558+ strict = True ,
559+ verbose = True ,
565560 )
566- result_files = []
567- for file_path in local_dir .glob (file_name_pattern ):
568- result_files .append (file_path )
569- assert result_files , "No result files found"
570- result_files .sort ()
571- version = int (result_files [- 1 ].name .split ("_" )[- 1 ])
572- Shell .check (f"cp { result_files [- 1 ]} { local_path } " , strict = True , verbose = True )
573561 return version
574562
575563 @classmethod
@@ -698,6 +686,7 @@ def update_workflow_results(
698686 # when multiple concurrent jobs attempt to update the workflow report
699687 time .sleep (random .uniform (0 , 2 ))
700688
689+ print (f"Workflow status changed: [{ prev_status } ] -> [{ new_status } ]" )
701690 if prev_status != new_status :
702691 return new_status
703692 else :
0 commit comments