@@ -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
@@ -340,12 +353,20 @@ def generate_report(result: FullResult) -> RunResultReport: # noqa: C901
340353 make_profile_log (prof_run .run ),
341354 )
342355
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 ,
348- )
356+ for prof_run in profile_runs :
357+ if prof_run .profile is not None :
358+ if prof_run .profile .trace is not None :
359+ report .add_file (
360+ "profile.zip" ,
361+ f"{ prof_run .profile .profiler } profiling output" ,
362+ base64 .b64decode (prof_run .profile .trace ),
363+ )
364+ elif prof_run .profile .download_url is not None :
365+ report .add_link (
366+ f"{ prof_run .profile .profiler } profiling output" ,
367+ "Download from GitHub" ,
368+ prof_run .profile .download_url ,
369+ )
349370
350371 if "leaderboard" in runs :
351372 bench_run = runs ["leaderboard" ]
0 commit comments