Repository navigation
Batch command: take rows, follow, stop and remove - #265
Merged
Merged
Conversation
The command could discover, look and reduce, but not do what the page does
besides: take rows of the row source into a batch, follow the files, stop
following, remove a batch. Each new command is one call of Intake or
BatchManager:
reduce --source NAME --first KEY / --last KEY / --later Range as choose
offered -l LABEL intake.offered
take -l LABEL KEY... intake.take; writes the rows as show does
remove -l LABEL manager.remove; says how many records stay
stop intake.stop; says which batch stopped
follow -l LABEL intake.follow, then a step every --interval s
follow is the second way to run Follow, after the page: whoever runs the
loop owns the timer. The loop, cli.follow, takes its pause and its "stop
asked" check as arguments, so tests run it without waiting or signals.
After a step that did something it writes one line (with --json, one JSON
object): rows added, rows submitted, the status of each row whose reduction
ended, why rows were refused, the rows that wait. A step that raises
ValueError is said on stderr once and the next step runs, as on the page.
The first SIGINT or SIGTERM ends the steps and waits for the reductions
that run; the batch still follows on disk, so the next follow or a page
goes on. A second signal ends the process with os._exit, since the worker
threads otherwise run their reductions to the end; the help says what such
a reduction reads after the next start. --steps N is for scripts and agents
that cannot hold a process open. Exit status 0 if every row is done, else 3.
The command opens the folder with ArrivingFiles, so follow finds the files
that arrive. To keep the help within about 120 lines, the one-line summary
per command is gone: the session in the help lists every command, and each
command's --help keeps its description.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A review ran real follow processes with signals, and an agent used the commands on LoKI data. What it found: - files -o wrote files.csv in place, so a follow that read it meanwhile saw half a table and ended with a KeyError. A table file is now written next to its name and renamed (files.replace_at_once), for write_table and write_files_table alike. files does not open the folder, so it runs while follow holds it, and the help says to run it again for new runs. - Only a ValueError of a step was caught: a source that raised anything else ended follow with a traceback. A step that raises anything is said as the page says it; said() moves from the web layer to ess.apps.errors for both. A workspace that stopped raises Stopped (a RuntimeError), which ends the loop with exit status 1. With --json, a line carries "error". - The signal handler wrote to stderr, which raises a reentrant call if the main thread writes at that moment. It only sets the flag; the loop says that it stops. SIGHUP is taken as SIGTERM. - --steps must be 1 or more and --interval finite and 0 or more. - A command that opens the folder reads files.csv once first, so a table of files in error (a file listed twice, a file that does not exist) is refused with a message, as before ArrivingFiles. - The help says what the agent had to find out: reduce --source does not follow; KEY is the first column of rows; a row keeps the cells it was added with; --later; the exit statuses after one and after two signals; that the next command runs the reductions that a second signal cut off before they started. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 23, 2026
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.
Second part of #262, and Follow without a page (#151):
essapps-batchcan do what the batch page does besides reducing.Each command is one call of
IntakeorBatchManager. Onlyfollowhas code of its own: the loop, and what it prints.followmakes the batch follow and then does a step every--intervalseconds. A step that did something writes one line (one JSON object with--json):follow, or a page, goes on.failed, "the workspace ended while it ran";followleaves it to a person, andreduce --remainingreduces it.ess.apps.errors.said) moved out ofweb/so that the page and the command share it. It says a refusal as its text; the page formatted a pydanticValidationErrorraised by application code more briefly before.ess.apps.errors.Stopped, aRuntimeError, where it raised a plainRuntimeError.--steps Ndoes N steps, waits for the reductions it submitted and exits, for a script or an agent that cannot hold a process open.Every table file is replaced in one step (
files.replace_at_once).followsees a run oncefiles.csvlists it, sofiles -o files.csvis run again whilefollowruns. It wrote the file in place, and afollowthat read the half-written table ended with an error.Every command now opens the folder with
ArrivingFiles, so that a long-running command sees a changedfiles.csv, and readsfiles.csvonce at the start: a file listed twice, or a listed file that does not exist, is a message with exit status 2. A review ran the commands that existed before onmainand on this branch side by side: the output, the exit status and the folder are the same for a validfiles.csv.Measured. A fresh agent (Claude Sonnet) got the command, the names of the bindings and row sources, and a LoKI folder into which a run arrived every 75 seconds. It was to reduce I(Q) from run 70007 on, keep up with the arrivals, and go on after its program was stopped. It was not allowed to read source or documentation. It ran about 15 commands, 4 of them to learn the command; its
followwas ended twice by SIGTERM; each of the four sample runs was reduced once.The same run showed a wrong pair made by LoKI's row source, not by the command: a sample run measured a second time under one name was reduced with the transmission run of the first measurement, because its own arrived 75 seconds later. The case is recorded in #221. The help now says that a row keeps the cells it was added with.
Not done here:
files.csvagain whenever it changed. A table that changes faster than a step reads it stalls the steps (seen with an arrival every 0.25 s on 3,000 rows). One snapshot of the files per step would cure it.To check by hand:
essapps-batch --helpandessapps-batch follow --helpread as a page one could work from.followon a folder into which a run arrives; Ctrl-C;followagain.🤖 Generated with Claude Code