Repository navigation
fix(assistant): ensure checkpoints parent directory exists before sqlite3 connection - #41
Open
shrinivas-sn wants to merge 1 commit into
Open
shrinivas-sn wants to merge 1 commit into
shrinivas-sn wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On a clean clone of the repository, the
checkpoints/directory does not exist on disk and is explicitly ignored by.gitignore. Whensrc/core/assistant.pyis imported (e.g. during application startup inmain.py), SQLite attempts to openconfig.CHECKPOINTS_DB. Because SQLite cannot create files in non-existent parent directories, this causes an immediatesqlite3.OperationalError: unable to open database file.This PR adds a directory creation guard (
os.makedirs(checkpoint_dir, exist_ok=True)) before callingsqlite3.connect(), matching the pattern used for logs insrc/utils/logger.py. It also introduces a dedicated unit test suite intests/test_assistant_initialization.pyto prevent regressions.Fixes #40
Type of Change
Changes Made
src/core/assistant.py: importedosand added directory existence guardos.makedirs(checkpoint_dir, exist_ok=True)beforesqlite3.connect(config.CHECKPOINTS_DB, check_same_thread=False).tests/test_assistant_initialization.py: added unit tests validating that missing directories raise SQLite errors without the guard, that the directory guard resolves the issue idempotently, and thatconfig.CHECKPOINTS_DBparent directory can be safely initialized.tests/__init__.py: initialized tests package.How Has This Been Tested?
python -m unittest discover tests(2 tests, 100% passing).ruff check .(all checks passed) andruff format --check .(27 files formatted).git diff --checkhas zero whitespace errors.checkpoints/directory.Checklist
src/config.py(if applicable)@tooldecorator fromsrc/core/tools.py