Skip to content

Port the DB-journal path natively into cellpy.batch (E4 part 1, #716) - #748

Merged
jepegit merged 2 commits into
masterfrom
716-native-db-journal
Jul 27, 2026
Merged

Port the DB-journal path natively into cellpy.batch (E4 part 1, #716)#748
jepegit merged 2 commits into
masterfrom
716-native-db-journal

Conversation

@jepegit

@jepegit jepegit commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Part 1 of E4 (#716): the native DB-journal port. This is the substantive feature work the issue flagged as "a real feature port, comparable to C2, not a mechanical deletion."

Why

cellpy.batch.db.journal_from_db (which backs Batch.from_db) delegated the entire database parse to LabJournal.from_db() in utils/batch_tools/batch_journals.py (~1134 lines), driven by batch_tools/engines.py (~412 lines). That was the last live consumer of batch_tools/ from the new cellpy.batch stack — so batch_tools/ could not be deleted until the DB-journal path was reimplemented natively.

What

  • new cellpy/batch/_dbengine.py — native port of the pieces from_db actually needs:
    • simple_db_engine + _create_pages_dict + _query (from engines.py)
    • find_files / fix_groups / make_unique_groups / create_labels / create_factory (from batch_helpers.py)
    • make_db_reader — the reader construction that lived in LabJournal.__init__
    • The db readers themselves (cellpy.readers.dbreader, cellpy.readers.json_dbreader) are unchanged and still own db access.
  • cellpy/batch/db.py — orchestrates from_db natively (reader → select_batchsimple_db_engine → polars Journal); no more LabJournal import.

After this, batch_tools/ is unused by production code — only its own tests still reference it directly.

Verification

  • test_batch_v3_facade.py — the full Batch.from_db("simple_excel_reader") path and the deferred-_db create_journal() flow both pass (9 passed).
  • Whole batch suite green: test_batch.py + facade + helpers = 50 passed, 1 skipped, 5 xfailed.

Follow-up (part 2)

Delete cellpy/utils/batch_tools/ and migrate the 3 tests that still import it directly (test_batch.py, test_batch_helpers_nulldata.py, test_dbreader.py), keeping cellpy.utils.batch / cellpy.utils.collectors as re-export shims. That PR will close #716.

Part of #716.

🤖 Generated with Claude Code

`journal_from_db` (backing `Batch.from_db`) delegated the entire database
parse to `LabJournal.from_db()` in `utils/batch_tools/batch_journals.py`
(~1134 lines) via `batch_tools/engines.py` (~412 lines). That was the last
live consumer of `batch_tools/` from the new `cellpy.batch` stack.

This reimplements the DB-journal path natively:

- new `cellpy/batch/_dbengine.py`: `simple_db_engine` + `_create_pages_dict`
  + `_query` (from engines.py) and `find_files` / `fix_groups` /
  `make_unique_groups` / `create_labels` / `create_factory` (from
  batch_helpers.py), plus `make_db_reader` (the reader construction that was
  in `LabJournal.__init__`). The db readers themselves (`dbreader`,
  `json_dbreader`) are unchanged and still own db access.
- `cellpy/batch/db.py` orchestrates from_db natively (reader → select_batch →
  simple_db_engine → polars Journal); no more `LabJournal` import.

`batch_tools/` is now unused by production code (only its own tests still
reference it directly). Its deletion + test migration follows in part 2.

Verified: the full `Batch.from_db` path (simple Excel reader) plus the
create_journal/deferred-db flow pass (test_batch_v3_facade.py), and the whole
batch suite stays green (test_batch.py, 50 passed).

Part of #716.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 27, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@jepegit
jepegit enabled auto-merge (squash) July 27, 2026 20:13
@jepegit
jepegit merged commit 83b5351 into master Jul 27, 2026
5 checks passed
@jepegit
jepegit deleted the 716-native-db-journal branch July 27, 2026 20:49
jepegit added a commit that referenced this pull request Jul 27, 2026
With the DB-journal path ported natively (part 1, #748), nothing in production
imports `cellpy/utils/batch_tools/` any more. Remove it (~4300 lines: the
farm/barn Do-er machinery, LabJournal, engines, batch_helpers, exporters,
dumpers, analyzers, reporters, sqlite_from_excel_db) and migrate the tests that
still referenced it directly:

- test_batch.py: repoint `engines.simple_db_engine` / `engines._query` /
  `batch_helpers.find_files` to `cellpy.batch._dbengine`; import
  `get_headers_journal` from `cellpy.parameters.internal_settings`; delete the
  tests bound to the removed machinery (CyclingExperiment, CSVExporter/dumpers,
  LabJournal-direct construction, the `batch_plotters`-removed probe).
- test_batch_helpers_nulldata.py: deleted (tested the removed
  `batch_helpers.join_summaries` farm/barn path).
- test_dbreader.py: drop the skip-only excel->sqlite test (used the removed
  `sqlite_from_excel_db`).

`cellpy.utils.batch` / `cellpy.utils.collectors` stay as permanent re-export
shims (they never imported batch_tools). Stale docstring pointers updated.

Verified: test_batch.py + test_dbreader.py + test_batch_v3_facade.py = 57
passed, 1 skipped, 5 xfailed; full suite collects (1463 tests, no import
errors).

Closes #716.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E4: delete batch_tools/ + collectors elevated-kwarg shims

1 participant