Skip to content

Batch: documents and code agree, in the guide's terms - #267

Merged
SimonHeybrock merged 18 commits into
mainfrom
259-clean-code
Nov 23, 2026
Merged

SimonHeybrock merged 18 commits into
mainfrom
259-clean-code

Conversation

@SimonHeybrock

Copy link
Copy Markdown
Member

Brings the batch system to a point where it can be reviewed in depth (#259): every sentence of the documents and docstrings checked against the code, in the terms of the guide, and the places fixed where the code broke a rule that the guide states. No feature is added.

1. The sweep (first commit, text only). Three readers went through the guide from "One example followed through" on, the other documents (automatic-reduction.md, the page's README, ADRs 0011 to 0013, the stories, the LoKI batch notebook), and every docstring and comment of the batch layer. A fourth checked the result against the code and compared the syntax trees of the changed Python files: no code changed.

  • About 30 sentences were false. Examples: "the command does no step"; "the manager writes considered" (Intake does); "stops the batch that follows, for good" (it can follow again since A batch that stopped following can follow again #263); BatchManager.version moves when another batch follows (Intake.version does).
  • About 190 places said "table", "column" or "source" where the guide's terms distinguish: batch table, files table, the rows of a row source, table file; parameter column, note column; row source, file source.
  • ADRs 0011 to 0013 are corrected in place, as the index of the ADRs says a changed decision is.
  • The guide's definition of a batch says how "a spec, settings and a batch table" relates to "a template and a table" of ADR 0012 and the command's help. Which wording to keep is open.

2. Code that broke a stated rule.

Rule or term Was Is
Rule 1: only put changes a batch table Batch.make_setting wrote rows.json itself it calls put; no observable change
Rule 6: the rules are in the batch layer only the page's offer checked that a spec fits a row source; the command made a batch whose fills named something that is no parameter Intake.create refuses: the spec find has no parameter transmission, which the source pairs fills
Rule 6: the page and the command copy no rule the command called the row source itself for rows, and worded an unknown --source its own way it asks Intake.rows_of; one function words an unknown row source, for the intake and for the command's check before it opens the folder
A refusal is said as a person reads it a ValidationError that a row function raised showed as pydantic's raw text: on the page since #265, in Follow and the command before that too ess.apps.errors.said words it per field, on every path of the page and the command
parameter column create(columns=...), NewBatch.columns, state.problems(..., columns) beside Batch.parameter_columns parameter_columns everywhere, also in the JSON body of POST /api/batches
Each kind of table has a name the definitions kept "tables", a fourth kind they keep entries, by key (docstrings and the guide)

Smaller: described (joins a run table to the files table, knows no batch) moved from batch.frames to ess.apps.folder; "Follow could not step:" is worded once (intake.step_failure); Batch.make_setting(name, key) refuses a name that is no parameter column (before, a note column was accepted: it wrote a setting that is no parameter, and reading the state of the batch raised from then on; any other name raised pandas' KeyError, a 500 on the page); the command's help strings use the guide's terms.

3. Tests. The marker real_data (#266) is registered in the conftest.py that uses it. Registered in one package's pyproject.toml, it made a pytest run over both packages from the repository root fail at collection.

Checked by a review that ran every command and the page's API on the code before and after, side by side: the differences are the ones above, and make_setting through put matches in 12 cases (order of the writes, version, a refused write).

Not changed, listed in #259 for the review: names in code where one word holds two things (source as a name and as a RowSource; table; following/follows), the structure of cli.py, and intake.follow(label) on a batch made with a last row.

🤖 Generated with Claude Code

SimonHeybrock and others added 18 commits November 23, 2026 10:50
…ide's terms

Five changes of 2026-11-23 (#260, #261, #263, #264, #265) changed names,
classes and files of the batch system. A sweep read the guide, the other
documents, and every docstring and comment of the batch layer against the
code.

False sentences, about 30. Among them: the command does no step; the
manager writes `considered`; a stopped batch stops for good; `Batch.put`
is the only writer of `rows.json`; `BatchManager.version` moves when
another batch follows; a `KeyError` of application code is a refusal; no
process handles SIGTERM but `essapps-batch follow` (true, and the batch
page is now said not to: checked on the demo).

Terms, about 190 places: batch table, files table, the rows of a row
source and table file where "table" stood alone; parameter column and
note column; row source where "source" could be the file source.

ADRs 0011 to 0013 are corrected in place, as the index of the ADRs says a
changed decision is: `fills` as the blanks of `settings.json`, the row
source with `Intake`, a batch that follows again, the command that
follows, and "only `put` changes a batch table" where they said "only a
person".

The guide's definition of a batch says how "a spec, settings and a batch
table" relates to "a template and a table" of ADR 0012 and the command's
help. Its command list has `files`, and rule 6 names the three refusals.

The LoKI batch notebook: a file of the command line is written
`path:files/...`, and its template has no `blanks`, which nothing reads.

No code changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Since said() moved to ess.apps.errors, a pydantic ValidationError that code
of the application raises, such as a row source that validates its
metadata, reached the page and the command as pydantic's raw text, with
its input value and a URL. Before, the web layer's why() worded it per
field ("run must be a valid integer"). The wording is a property of the
exception, so said() gives it, and said_at() holds the rule for one reason
at a field; the page's say() is said_at() with its own field messages, and
why() keeps only the KeyError, which said() names with its type.

The table of refusals.py listed a ValidationError raised by the batch
layer; none is raised there (definition.py turns it into a ValueError).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fits() was asked only where the page offers choices, so the command and
code could make a batch of a spec that lacks a parameter that its source
fills: its fills then named a parameter that is no parameter of the spec.
Intake.create refuses it with a ValueError that names the spec, the source
and the parameters the spec lacks, after the source is looked up and
before it is listed, so the order of the other refusals stays. The page's
check is an offer of choices, not a rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
make_setting dropped the column, wrote rows.json and held the frame
itself, beside put: two writers of rows.json, against "only put changes a
batch table". It is one put of the frame without the column, after the
settings are written, so the order settings.json then rows.json stays.

Nothing observable changes: the frame without the column always differs
from the one held, so put's check for an equal frame never skips the
write; put types and checks the fills as the lines did, forgets the
resolved cells, writes before it holds the frame, and moves the version
once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BatchManager.create, Intake.create, NewBatch (and what the page sends),
state.problems, state.row_states, forms.held and forms.tree took
columns=, beside Batch.parameter_columns for the same thing. The argument
gets the name of the attribute; a columns that means the columns of a
frame stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
described joins a person's run table to the files table of a folder and
knows no batch, so it sits beside scan_folder, whose rows it describes.
ess.apps.folder needs the extra files already (scipp, h5py), which holds
pandas too; it imports nothing of ess.apps.batch, and import ess.apps
still loads neither it nor pandas. Its tests move to the tests of folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main refused a --source, or the NAME of rows, that is not in --sources
with its own message, beside Intake's refusal of the same; and rows called
rows_of itself beside Intake.rows_of. rows opens the folder with the
bindings, so it asks the intake, and reduce --source reaches
Intake.create: both say "the source p is not registered" with exit
status 2. What stays of the command's own check is what no intake can
say: rows and reduce --source without -s/--sources are a wrong command
line, as for offered, take and follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The command's follow and the page's tick each wrote "Follow could not
step: " before said(error). intake.step_failure holds the wording, beside
Intake.step, whose exception it says; ess.apps.errors knows no Follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What the definitions keep under a key was called a table, a fourth kind
beside the batch table, the files table and a table file. The docstrings
of definition, manager and intake and the guide say "entry". The word
"entry" those docstrings used for a field of the data of an entry, such
as "considered" of source.json, is "field".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The descriptions of show, reduce, offered, take, remove, rows, files and
export, the help of --with, TABLE of reduce and export, and the template's
how-to said bare "table". Each says batch table, table file, files table,
run table, or the rows that the row source makes, as the guide's terms
do. So does the refusal of a table file with --source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A review checked the sweep of documents and docstrings against the code:

- Rule 1 of the guide names make_column and make_setting among the
  callers of put, which they are.
- The command's help says "a batch is a template and a batch table" and
  what a parameter column is in one phrase; two lines over 80 characters
  are wrapped.
- The hint of Remove says what goes: the title, description, settings and
  batch table, and whether the batch follows; the row source is code of
  the application and stays.
- RowSource.fills names columns, which a batch keeps as parameter
  columns: the rows of a source know no spec.
- Step 3 of the guide's example says that row 60340 reads outdated at the
  put, and 60339 stays earlier.
- ADR 0011: intake.follow also lets a batch follow that never followed.
- Bare "table" in the guide, the page's README and the LoKI notebook names
  what it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The marker was registered in the pytest options of essinstruments only,
so a run of the tests of both packages from the root of the repository,
which reads no pyproject.toml, refused it under --strict-markers at
collection. The LoKI conftest registers it in pytest_configure, which
pytest calls when it loads that conftest, before the test modules that
carry the mark are imported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since the command asks the intake, its message said only "the source p
is not registered"; the command's own check listed the names, which a
person needs to correct the command line. Intake._source names them, or
"none", for the command, the page and code alike.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With a key, make_setting read the cell of the column before it checked
that the column is one, so a parameter without a column, or a note,
raised pandas' KeyError, though the docstring promises a ValueError.
The check that values() makes is one method that both call first; the
batch is left as it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
said() words a pydantic ValidationError per field, but three places
flattened the error to its text before said() saw it: the SourceError of
a step (auto.step), the refusal of offered (Intake.offered), and the
message of the command for a ValueError (cli.main). So Follow on the page
and in the command, offered on the page, and rows, reduce --source, take
and offered of the command still showed pydantic's raw text. Each says
said(error); a plain ValueError reads as before.

Also noted: on the base, make_setting('name', '1') on a note column
succeeded: it wrote the setting name, which is no parameter, dropped the
note, and from then on state() raised SubmitError, also after the batch
was read again. Commit "Batch.make_setting refuses a name that is no
parameter column" refuses it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Asking the intake moved the refusal of a misspelt --source or rows NAME
after the opening of the folder: a fresh folder got a log.jsonl, and
while follow held the folder the person read that the folder is held,
with exit status 1, where the name was wrong. That a name is in
--sources is a fact of the command line, so main refuses it again before
the folder is opened, with exit status 2. intake.not_registered holds the
wording, which the command and Intake._source share. rows still calls
Intake.rows_of.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
files --with calls folder.described, and rows calls intake.rows_of. The
other rows of the table were checked against cli.py and hold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The refusal of a spec that does not fit said "has no parameter a, b"
when several are missing; it says "parameters" then. The guide called a
setting and a command "an entry" of a dict, beside the entries of the
definitions; it says "item" there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SimonHeybrock SimonHeybrock self-assigned this Nov 23, 2026
@SimonHeybrock
SimonHeybrock merged commit 3530740 into main Nov 23, 2026
2 checks passed
@SimonHeybrock
SimonHeybrock deleted the 259-clean-code branch November 23, 2026 11:45
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.

1 participant