Skip to content

Commit 6d306be

Browse files
authored
Merge pull request #21 from gperdrizet/dev
General clean up
2 parents 44c8c70 + cb962b9 commit 6d306be

File tree

12 files changed

+909
-1691
lines changed

12 files changed

+909
-1691
lines changed

docs/source/api.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,3 @@ Core functions
6868
.. automodule:: hill_climber.climber_functions
6969
:members:
7070
:undoc-members:
71-
72-
Plotting functions
73-
------------------
74-
75-
.. automodule:: hill_climber.plotting_functions
76-
:members:
77-
:undoc-members:

docs/source/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ Features
4848
- **Multi-column data**: Optimize datasets with any number of features
4949
- **Structured state management**: ReplicaState dataclass with type hints for clarity and IDE support
5050
- **Checkpointing**: Save and resume long-running optimizations with configurable checkpoint intervals
51-
- **Rich visualization**: Built-in plotting functions for results analysis
5251
- **JIT compilation**: Numba-optimized core functions for performance
5352

5453
Data format

hill_climber/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
ReplicaState: State container for individual replicas
1111
OptimizerConfig: Type-safe configuration dataclass
1212
Helper functions: Data manipulation and objective calculation utilities
13-
Plotting functions: Visualization tools for input data and results
1413
1514
Example:
1615
>>> from hill_climber import HillClimber
@@ -54,9 +53,6 @@
5453
extract_columns,
5554
calculate_objective
5655
)
57-
from .plotting_functions import (
58-
plot_input_data
59-
)
6056

6157
__all__ = [
6258
'HillClimber',
@@ -68,5 +64,4 @@
6864
'perturb_vectors',
6965
'extract_columns',
7066
'calculate_objective',
71-
'plot_input_data',
7267
]

hill_climber/database.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,17 @@ def set_run_end_time(self):
337337
""", (time.time(),))
338338

339339

340+
def checkpoint_database(self):
341+
"""Checkpoint the database to consolidate WAL files.
342+
343+
Merges all Write-Ahead Log (WAL) changes back into the main database
344+
file and removes the auxiliary .db-shm and .db-wal files. This should
345+
be called when the optimization is complete to clean up temporary files.
346+
"""
347+
with self.get_connection() as conn:
348+
conn.execute("PRAGMA wal_checkpoint(TRUNCATE)")
349+
350+
340351
def update_replica_status(self, replica_id: int, current_perturbation_num: int,
341352
num_accepted: int, num_improvements: int,
342353
temperature: float, best_objective: float,

hill_climber/optimizer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,9 @@ def _finalize_results(self) -> np.ndarray:
565565

566566
# Mark run as complete
567567
self.db_writer.set_run_end_time()
568+
569+
# Checkpoint database to consolidate WAL files and remove auxiliary files
570+
self.db_writer.checkpoint_database()
568571

569572
# Final checkpoint
570573
if self.checkpoint_file:

0 commit comments

Comments
 (0)