99from humanloop import Humanloop
1010from humanloop .sync .sync_client import SyncClient
1111from datetime import datetime
12- from humanloop .cli .progress import progress_context
1312
1413# Set up logging
1514logger = logging .getLogger (__name__ )
@@ -166,12 +165,7 @@ def pull(
166165 click .echo (click .style (f"Path: { path or '(root)' } " , fg = INFO_COLOR ))
167166 click .echo (click .style (f"Environment: { environment or '(default)' } " , fg = INFO_COLOR ))
168167
169- if verbose :
170- # Don't use the spinner in verbose mode as the spinner and sync client logging compete
171- successful_files = sync_client .pull (path , environment )
172- else :
173- with progress_context ("Pulling files..." ):
174- successful_files = sync_client .pull (path , environment )
168+ successful_files = sync_client .pull (path , environment )
175169
176170 # Get metadata about the operation
177171 metadata = sync_client .metadata .get_last_operation ()
@@ -201,56 +195,7 @@ def pull(
201195 click .echo (click .style (f" ✗ { file } " , fg = ERROR_COLOR ))
202196 if metadata .get ('error' ):
203197 click .echo (click .style (f"\n Error: { metadata ['error' ]} " , fg = ERROR_COLOR ))
204-
205- def format_timestamp (timestamp : str ) -> str :
206- """Format timestamp to a more readable format."""
207- try :
208- dt = datetime .fromisoformat (timestamp .replace ('Z' , '+00:00' ))
209- return dt .strftime ('%Y-%m-%d %H:%M:%S' )
210- except (ValueError , AttributeError ):
211- return timestamp
212-
213- @cli .command ()
214- @click .option (
215- "--oneline" ,
216- is_flag = True ,
217- help = "Display history in a single line per operation" ,
218- )
219- @handle_sync_errors
220- @common_options
221- def history (api_key : Optional [str ], env_file : Optional [str ], base_dir : str , base_url : Optional [str ], oneline : bool ):
222- """Show sync operation history."""
223- client = get_client (api_key , env_file , base_url )
224- sync_client = SyncClient (client , base_dir = base_dir )
225-
226- history = sync_client .metadata .get_history ()
227- if not history :
228- click .echo (click .style ("No sync operations found in history." , fg = WARNING_COLOR ))
229- return
230-
231- if not oneline :
232- click .echo (click .style ("Sync Operation History:" , fg = INFO_COLOR ))
233- click .echo (click .style ("======================" , fg = INFO_COLOR ))
234-
235- for op in history :
236- if oneline :
237- # Format: timestamp | operation_type | path | environment | duration_ms | status
238- status = click .style ("✓" , fg = SUCCESS_COLOR ) if not op ['failed_files' ] else click .style ("✗" , fg = ERROR_COLOR )
239- click .echo (f"{ format_timestamp (op ['timestamp' ])} | { op ['operation_type' ]} | { op ['path' ] or '(root)' } | { op ['environment' ] or '-' } | { op ['duration_ms' ]} ms | { status } " )
240- else :
241- click .echo (click .style (f"\n Operation: { op ['operation_type' ]} " , fg = INFO_COLOR ))
242- click .echo (f"Timestamp: { format_timestamp (op ['timestamp' ])} " )
243- click .echo (f"Path: { op ['path' ] or '(root)' } " )
244- if op ['environment' ]:
245- click .echo (f"Environment: { op ['environment' ]} " )
246- click .echo (f"Duration: { op ['duration_ms' ]} ms" )
247- if op ['successful_files' ]:
248- click .echo (click .style (f"Successfully { op ['operation_type' ]} ed { len (op ['successful_files' ])} file{ '' if len (op ['successful_files' ]) == 1 else 's' } " , fg = SUCCESS_COLOR ))
249- if op ['failed_files' ]:
250- click .echo (click .style (f"Failed to { op ['operation_type' ]} ed { len (op ['failed_files' ])} file{ '' if len (op ['failed_files' ]) == 1 else 's' } " , fg = ERROR_COLOR ))
251- if op ['error' ]:
252- click .echo (click .style (f"Error: { op ['error' ]} " , fg = ERROR_COLOR ))
253- click .echo (click .style ("----------------------" , fg = INFO_COLOR ))
198+
254199
255200if __name__ == "__main__" :
256201 cli ()
0 commit comments