1+ import os
12from typing import Any , Dict , List , Optional , Union
23
34from rich .markup import escape
@@ -35,7 +36,7 @@ def print_run_plan(
3536
3637 req = job_plan .job_spec .requirements
3738 pretty_req = req .pretty_format (resources_only = True )
38- max_price = f"${ req .max_price :g } " if req .max_price else "-"
39+ max_price = f"${ req .max_price :3f } " . rstrip ( "0" ). rstrip ( "." ) if req .max_price else "-"
3940 max_duration = (
4041 format_pretty_duration (job_plan .job_spec .max_duration )
4142 if job_plan .job_spec .max_duration
@@ -93,14 +94,12 @@ def th(s: str) -> str:
9394 props .add_row (th ("Inactivity duration" ), inactivity_duration )
9495 props .add_row (th ("Reservation" ), run_plan .run_spec .configuration .reservation or "-" )
9596
96- offers = Table (box = None )
97+ offers = Table (box = None , expand = os . get_terminal_size ()[ 0 ] <= 110 )
9798 offers .add_column ("#" )
98- offers .add_column ("BACKEND" )
99- offers .add_column ("REGION" )
100- offers .add_column ("INSTANCE TYPE" )
101- offers .add_column ("RESOURCES" )
102- offers .add_column ("SPOT" )
103- offers .add_column ("PRICE" )
99+ offers .add_column ("BACKEND" , style = "grey58" , ratio = 2 )
100+ offers .add_column ("RESOURCES" , ratio = 4 )
101+ offers .add_column ("INSTANCE TYPE" , style = "grey58" , ratio = 2 )
102+ offers .add_column ("PRICE" , style = "grey58" , ratio = 1 )
104103 offers .add_column ()
105104
106105 job_plan .offers = job_plan .offers [:max_offers ] if max_offers else job_plan .offers
@@ -121,14 +120,12 @@ def th(s: str) -> str:
121120 instance += f" ({ offer .blocks } /{ offer .total_blocks } )"
122121 offers .add_row (
123122 f"{ i } " ,
124- offer .backend .replace ("remote" , "ssh" ),
125- offer . region ,
123+ offer .backend .replace ("remote" , "ssh" ) + " (" + offer . region + ")" ,
124+ r . pretty_format ( include_spot = True ) ,
126125 instance ,
127- r .pretty_format (),
128- "yes" if r .spot else "no" ,
129- f"${ offer .price :g} " ,
126+ f"${ offer .price :.4f} " .rstrip ("0" ).rstrip ("." ),
130127 availability ,
131- style = None if i == 1 else "secondary" ,
128+ style = None if i == 1 or not include_run_properties else "secondary" ,
132129 )
133130 if job_plan .total_offers > len (job_plan .offers ):
134131 offers .add_row ("" , "..." , style = "secondary" )
@@ -140,7 +137,8 @@ def th(s: str) -> str:
140137 if job_plan .total_offers > len (job_plan .offers ):
141138 console .print (
142139 f"[secondary] Shown { len (job_plan .offers )} of { job_plan .total_offers } offers, "
143- f"${ job_plan .max_price :g} max[/]"
140+ f"${ job_plan .max_price :3f} " .rstrip ("0" ).rstrip ("." )
141+ + "max[/]"
144142 )
145143 console .print ()
146144 else :
@@ -150,19 +148,18 @@ def th(s: str) -> str:
150148def get_runs_table (
151149 runs : List [Run ], verbose : bool = False , format_date : DateFormatter = pretty_date
152150) -> Table :
153- table = Table (box = None )
154- table .add_column ("NAME" , style = "bold" , no_wrap = True )
155- table .add_column ("BACKEND" , style = "grey58" )
151+ table = Table (box = None , expand = os .get_terminal_size ()[0 ] <= 110 )
152+ table .add_column ("NAME" , style = "bold" , no_wrap = True , ratio = 2 )
153+ table .add_column ("BACKEND" , style = "grey58" , ratio = 2 )
154+ table .add_column ("RESOURCES" , ratio = 3 if not verbose else 2 )
156155 if verbose :
157- table .add_column ("INSTANCE" , no_wrap = True )
158- table .add_column ("RESOURCES" )
156+ table .add_column ("INSTANCE" , no_wrap = True , ratio = 1 )
157+ table .add_column ("RESERVATION" , no_wrap = True , ratio = 1 )
158+ table .add_column ("PRICE" , style = "grey58" , ratio = 1 )
159+ table .add_column ("STATUS" , no_wrap = True , ratio = 1 )
160+ table .add_column ("SUBMITTED" , style = "grey58" , no_wrap = True , ratio = 1 )
159161 if verbose :
160- table .add_column ("RESERVATION" , no_wrap = True )
161- table .add_column ("PRICE" , no_wrap = True )
162- table .add_column ("STATUS" , no_wrap = True )
163- table .add_column ("SUBMITTED" , style = "grey58" , no_wrap = True )
164- if verbose :
165- table .add_column ("ERROR" , no_wrap = True )
162+ table .add_column ("ERROR" , no_wrap = True , ratio = 2 )
166163
167164 for run in runs :
168165 run_error = _get_run_error (run )
@@ -201,10 +198,10 @@ def get_runs_table(
201198 job_row .update (
202199 {
203200 "BACKEND" : f"{ jpd .backend .value .replace ('remote' , 'ssh' )} ({ jpd .region } )" ,
204- "INSTANCE" : instance ,
205201 "RESOURCES" : resources .pretty_format (include_spot = True ),
202+ "INSTANCE" : instance ,
206203 "RESERVATION" : jpd .reservation ,
207- "PRICE" : f"${ jpd .price :.4 } " ,
204+ "PRICE" : f"${ jpd .price :.4f } " . rstrip ( "0" ). rstrip ( "." ) ,
208205 }
209206 )
210207 if len (run .jobs ) == 1 :
0 commit comments