From a452a954398ecf2879c11c3651ba608b3ec00d1c Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Fri, 1 Nov 2024 09:33:36 +0000 Subject: [PATCH] Formatting tweaks. --- src/somd2/io/_io.py | 12 +++++++----- src/somd2/runner/_repex.py | 4 +++- src/somd2/runner/_runner.py | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/somd2/io/_io.py b/src/somd2/io/_io.py index e0bcca6..4f51bcc 100644 --- a/src/somd2/io/_io.py +++ b/src/somd2/io/_io.py @@ -159,15 +159,17 @@ def parquet_append(filepath: _Path or str, df: _pd.DataFrame) -> None: Pandas dataframe to append. Must be same schema as original. """ try: + # Use memory map for speed. table_original_file = _pq.read_table( source=str(filepath), pre_buffer=False, use_threads=True, memory_map=True - ) # Use memory map for speed. + ) table_to_append = _pa.Table.from_pandas(df) - table_to_append = table_to_append.cast( - table_original_file.schema - ) # Attempt to cast new schema to existing, e.g. datetime64[ns] to datetime64[us] (may throw otherwise). + # Attempt to cast new schema to existing, e.g. datetime64[ns] to + # datetime64[us] (may throw otherwise). + table_to_append = table_to_append.cast(table_original_file.schema) - temp_file = str(filepath) + "_temp" # Temporary file to write to + # Temporary file to write to. + temp_file = str(filepath) + "_temp" # Writing to a temporary file with _pq.ParquetWriter(temp_file, table_original_file.schema) as temp_writer: diff --git a/src/somd2/runner/_repex.py b/src/somd2/runner/_repex.py index 7b1c20e..1986b19 100644 --- a/src/somd2/runner/_repex.py +++ b/src/somd2/runner/_repex.py @@ -415,7 +415,9 @@ def run(self): end = time() # Log the run time in minutes. - _logger.success(f"Simulation finished. Run time: {(end - start) / 60:.2f} minutes") + _logger.success( + f"Simulation finished. Run time: {(end - start) / 60:.2f} minutes" + ) def _run_block( self, index, lambdas, is_checkpoint, is_final_block, block, num_blocks diff --git a/src/somd2/runner/_runner.py b/src/somd2/runner/_runner.py index a42e9cf..b118cae 100644 --- a/src/somd2/runner/_runner.py +++ b/src/somd2/runner/_runner.py @@ -177,7 +177,6 @@ def run(self): result = job.result() except Exception as e: result = False - _logger.error( f"Exception raised for {_lam_sym} = {lambda_value}: {e}" ) @@ -192,7 +191,9 @@ def run(self): end = time() # Log the run time in minutes. - _logger.success(f"Simulation finished. Run time: {(end - start) / 60:.2f} minutes") + _logger.success( + f"Simulation finished. Run time: {(end - start) / 60:.2f} minutes" + ) def run_window(self, index): """