@@ -43,9 +43,19 @@ class Link:
4343 url : str
4444
4545
46+ @dataclasses .dataclass
47+ class File :
48+ """
49+ Link represents a file that gets attached to the report.
50+ """
51+ name : str
52+ message : str
53+ content : bytes
54+
55+
4656class RunResultReport :
4757 def __init__ (self , data = None ):
48- self .data : List [Text | Log | Link ] = data or []
58+ self .data : List [Text | Log | Link | File ] = data or []
4959
5060 def add_text (self , section : str ):
5161 self .data .append (Text (section ))
@@ -56,6 +66,9 @@ def add_log(self, header: str, log: str):
5666 def add_link (self , title : str , text : str , url : str ):
5767 self .data .append (Link (title , text , url ))
5868
69+ def add_file (self , name : str , message : str , content : bytes ):
70+ self .data .append (File (name , message , content ))
71+
5972 def __repr__ (self ):
6073 return f"RunResultReport(data={ self .data } )"
6174
@@ -335,18 +348,28 @@ def generate_report(result: FullResult) -> RunResultReport: # noqa: C901
335348 if _handle_crash_report (report , prof_run ):
336349 return report
337350
338- report .add_log (
339- "Profiling" ,
340- make_profile_log (prof_run .run ),
341- )
342-
343- if prof_run .profile is not None and prof_run .profile .download_url is not None :
344- report .add_link (
345- f"{ prof_run .profile .profiler } profiling output" ,
346- "Download from GitHub" ,
347- prof_run .profile .download_url ,
351+ if prof_run .profile .trace is not None :
352+ report .add_log (
353+ "Profiling" ,
354+ make_profile_log (prof_run .run ),
348355 )
349356
357+ if prof_run .profile .download_url is not None :
358+ report .add_link (
359+ f"{ prof_run .profile .profiler } profiling output" ,
360+ "Download from GitHub" ,
361+ prof_run .profile .download_url ,
362+ )
363+
364+ for prof_run in profile_runs :
365+ if prof_run .profile is not None :
366+ if prof_run .profile .trace is not None :
367+ report .add_file (
368+ "profile.zip" ,
369+ make_profile_log (prof_run .run ),
370+ base64 .b64decode (prof_run .profile .trace ),
371+ )
372+
350373 if "leaderboard" in runs :
351374 bench_run = runs ["leaderboard" ]
352375 if _handle_crash_report (report , bench_run ):
0 commit comments