@@ -69,14 +69,14 @@ def add_deployment_parser(subparsers):
6969 deployment_delete_parser .set_defaults (func = delete_deployment )
7070 deployment_delete_parser .add_argument ("-a" , "--api_key" , help = "api key" )
7171 deployment_delete_parser .add_argument ("deployment_name" , help = "deployment name" )
72-
72+
7373 deployment_log_parser .set_defaults (func = get_deployment_log )
7474 deployment_log_parser .add_argument ("-a" , "--api_key" , help = "api key" )
7575 deployment_log_parser .add_argument ("deployment_name" , help = "deployment name" )
76- deployment_log_parser .add_argument ("-d" , "--duration" , help = "duration of log (from now) in seconds" , type = int , default = 3600 )
7776 deployment_log_parser .add_argument (
78- "-f " , "--follow " , help = "follow log output " , action = "store_true"
77+ "-d " , "--duration " , help = "duration of log (from now) in seconds " , type = int , default = 3600
7978 )
79+ deployment_log_parser .add_argument ("-f" , "--follow" , help = "follow log output" , action = "store_true" )
8080
8181
8282def list_machine_types (args ):
@@ -165,26 +165,25 @@ def get_deployment_log(args):
165165 if api_key is None :
166166 print ("Please provide an api key" )
167167 return
168-
168+
169169 to_timestamp = datetime .now ()
170- from_timestamp = ( to_timestamp - timedelta (seconds = args .duration ) )
171- log_ids = set () # to avoid duplicate logs
170+ from_timestamp = to_timestamp - timedelta (seconds = args .duration )
171+ log_ids = set () # to avoid duplicate logs
172172 while True :
173173 status_code , msg = deploymentapi .get_deployment_log (api_key , args .deployment_name , from_timestamp , to_timestamp )
174174 if status_code != 200 :
175175 print (f"{ status_code } : { msg } " )
176176 return
177177
178- for log in msg [::- 1 ]: # logs are sorted by reversed timestamp
179- if log [' insert_id' ] in log_ids :
178+ for log in msg [::- 1 ]: # logs are sorted by reversed timestamp
179+ if log [" insert_id" ] in log_ids :
180180 continue
181- log_ids .add (log [' insert_id' ])
181+ log_ids .add (log [" insert_id" ])
182182 print (f'[{ datetime .fromisoformat (log ["timestamp" ]).strftime ("%Y-%m-%d %H:%M:%S.%f" )} ] { log ["payload" ]} ' )
183183
184184 if not args .follow :
185185 break
186-
186+
187187 time .sleep (10 )
188188 from_timestamp = to_timestamp
189189 to_timestamp = datetime .now ()
190-
0 commit comments