Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/developer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,11 @@ def transmission_runs(files: Sequence[FileInfo]) -> pd.DataFrame:
for f in files if f.metadata.get('role') == 'transmission']
return pd.DataFrame.from_records(rows, columns=['key', 'run']).set_index('key')

manager = BatchManager(client, definitions=FolderDefinitions(folder),
sources={'transmission-runs': Source(transmission_runs, fills=('run',))})
manager.create('transmission', title='Transmissions', source='transmission-runs',
follow=True)
manager.step() # called by a timer of the application
manager = BatchManager(client, definitions=FolderDefinitions(folder))
intake = Intake(manager, sources={'transmission-runs': RowSource(transmission_runs, fills=('run',))})
intake.create('transmission', title='Transmissions', source='transmission-runs',
follow=True)
intake.step() # called by a timer of the application
```

A step never changes a row that the table has. The results are read from the records under the label, so a restarted application reduces no row that has a result. A record under the label with a row's key as member, from any batch, is that row's result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ Problem 3 is not decided (see "Not decided").
### The manager

```python
manager = BatchManager(client, sources={'sample-runs': SAMPLE_RUNS},
definitions=FolderDefinitions(folder))
label = manager.create('loki-iofq', title='Afternoon', source='sample-runs')
manager = BatchManager(client, definitions=FolderDefinitions(folder))
intake = Intake(manager, sources={'sample-runs': SAMPLE_RUNS})
label = intake.create('loki-iofq', title='Afternoon', source='sample-runs').label
manager.headers() # {label: Header(title, description)}, sorted by label
manager.batch(label) # the Batch: frame(), put(), state(), reduce(), cancel(), settings
manager.change(label, title='Afternoon, 2 mm cells')
Expand All @@ -58,7 +58,7 @@ What the application gives once, and what a person chooses for each batch:
| Part | Given by |
|---|---|
| spec | a person, from the specs that the workspace binds (`client.specs()`); the name is kept, the version is the one bound, the highest if several are ([ADR 0009](0009-a-record-of-another-spec-stays-readable.md)) |
| source | a person, from the sources that the application registers by name (`BatchManager(sources=...)`), or none |
| source | a person, from the sources that the application registers by name (`Intake(sources=...)`), or none |
| title, description | a person |
| label | the manager |
| first settings, `staged` | the application, for each spec (`BatchManager(settings=..., staged=...)`) |
Expand All @@ -78,8 +78,7 @@ So the records of a removed batch never show as results of another batch.

```
definitions/labels/20261118-130204/header.json {"title": "Afternoon, 2 mm cells", "description": "..."}
definitions/labels/20261118-130204/... the settings and the table (ADR 0012), the source (ADR 0013)
definitions/following.json {"label": "20261118-130204"}, or {"label": null}
definitions/labels/20261118-130204/... the settings and the table (ADR 0012), the source and whether the batch follows (ADR 0013)
definitions/corrections.json metadata of runs set by hand
```

Expand All @@ -92,18 +91,18 @@ Nothing checks that the batches cover every row or that they do not overlap.

### One batch follows

The manager keeps the label of the batch that follows, or none:
`Intake` keeps which batch follows, if any:

```python
manager.create(..., source='sample-runs', follow=True) # this batch follows, and no other
manager.following # its label, or None
manager.stop() # none follows
manager.step() # one step of Follow on it (ADR 0013)
intake.create(..., source='sample-runs', follow=True) # this batch follows, and no other
intake.following # its label, or None
intake.stop() # none follows
intake.step() # one step of Follow on it (ADR 0013)
```

- One value means that at most one batch follows, with no rule to enforce. Making a batch that follows stops the batch that followed before.
- The manager keeps the value in the definitions, apart from any batch, so a restart resumes. Removing the batch that follows ends Follow.
- Whoever serves the pages owns the timer that calls `step`. The manager has no thread, no timer and no lock.
- Making a batch that follows stops the batch that followed before, first, so at most one batch follows.
- `Intake` keeps it in the definitions of the batch (`"follows"` in its `source.json`), so a restart resumes, and removing the batch that follows ends Follow, also for a batch made again with the label.
- Whoever serves the pages owns the timer that calls `step`. `Intake` has no thread, no timer and no lock.
- The workspace has one lock: every request of every page and each step take it, so the batches, the manager and the corrections change in one request at a time.

### A page shows one batch, named in its URL
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/adr/0012-a-batch-is-a-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ The code of this ADR and of ADR 0013 is written together, since Follow is in use
- An empty cell depends on the settings, outside the table. The page shows it in grey as the value that the row takes.
- A table file shows an empty cell where a row takes the setting, so it needs the settings file to say what a row was reduced with.
- A cell emptied after its row was reduced counts its value as a setting: the row reads `earlier`, not `outdated`.
- A batch made from a source keeps the names that its source fills with it, in `source.json`, as they were when it was made; the batch, the command without the sources, and Follow read them there. A step asks the batch which names a row waits for.
- A batch made from a source keeps the names that its source fills with it, as the blanks of `settings.json`, as they were when it was made; the batch, the command without the sources, and Follow read them there. A step asks the batch which names a row waits for.
- The table of a batch made from a source keeps a column for each name that its source fills: `put`, a table file loaded, and "Make this a setting" refuse to drop one.
- `settings.json` holds every setting, those at the columns too, as a template without blanks. A file whose template has blanks, as one written before, reads the same: its blanks are not read, and it has no settings at the columns.
- A row that only wrong metadata made stays until a person removes it, and a correction of a run changes no batch (the example above).
Expand Down
37 changes: 18 additions & 19 deletions docs/developer/adr/0013-follow-adds-the-rows-not-considered.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def step(batch, source, considered):
### What is kept

```
definitions/labels/20261118-130204/source.json {"source": "sample-runs", "considered": ["60337", "60338", "60339"]}
definitions/following.json the label of the batch that follows, or none (ADR 0011)
definitions/labels/20261118-130204/source.json {"source": "sample-runs", "considered": ["60337", "60338", "60339"], "follows": true}
```

- A key is *considered* by a batch once a row of that key was put into the batch from the source, or was filled and left out when the batch was made.
Expand Down Expand Up @@ -72,7 +71,7 @@ What removes a bad run from the later rows is a correction of the run, which the

### A row waits until the source has filled it

A source says which columns it fills (`Source.fills`, such as `sample` and `sample_transmission`). A row is added once it has a value in each of these that is a column of the batch. Until then it is *waiting*: the source gives it again at every step, and the page says how many rows wait.
A source says which columns it fills (`RowSource.fills`, such as `sample` and `sample_transmission`). A row is added once it has a value in each of these that is a column of the batch. Until then it is *waiting*: the source gives it again at every step, and the page says how many rows wait.

- A sample run measured before its transmission run is added when the transmission run is listed.
- A row is added whatever its other columns hold. A column that the source does not fill is empty in a new row, and the row is incomplete if the template needs it.
Expand All @@ -84,8 +83,8 @@ A source says which columns it fills (`Source.fills`, such as `sample` and `samp
`create` lists the source once, and a person chooses the table of the batch from the rows that are filled:

```python
manager.create('loki-iofq', title='Afternoon', source='sample-runs',
choose=Range(first='60339'), columns=['thickness'], follow=True)
intake.create('loki-iofq', title='Afternoon', source='sample-runs',
choose=Range(first='60339'), columns=['thickness'], follow=True)

# in create:
given = rows_of(client, source) # one listing
Expand Down Expand Up @@ -116,35 +115,35 @@ The rule is on the state of the rows, as in ADR 0011. So in a batch that follows
No row moves from one batch to another. A person who wants the runs from 60400 on in a batch of their own makes it with Follow:

```python
label = manager.create('loki-iofq', title='Evening', source='sample-runs',
choose=Range(first='60400'),
settings=manager.batch('afternoon').settings,
follow=True) # the batch 'afternoon' stops following
intake.create('loki-iofq', title='Evening', source='sample-runs',
choose=Range(first='60400'),
settings=manager.batch('afternoon').settings,
follow=True) # the batch 'afternoon' stops following
```

The earlier batch keeps its rows, also those from 60400 on, until a person removes them. It has considered the keys it has seen, and takes no row that arrives later, since it cannot follow again.

A batch of only the rows that arrive later takes no row at making. Every row filled then is considered, so no row is reduced again:

```python
manager.create('loki-iofq', title='Night', source='sample-runs',
choose=Range(later=True), follow=True)
intake.create('loki-iofq', title='Night', source='sample-runs',
choose=Range(later=True), follow=True)
```

### A batch follows from the time it is made, until it is stopped

Follow is chosen when a batch is made. A batch that follows can be stopped. A batch that does not follow cannot be made to follow.

```python
manager.create(..., source='sample-runs', follow=True) # follows; the batch that followed before stops
manager.following # its label
manager.stop() # none follows; that batch cannot follow again
intake.create(..., source='sample-runs', follow=True) # follows; the batch that followed before stops
intake.following # its label
intake.stop() # none follows; that batch cannot follow again
```

- At most one batch follows, as in ADR 0011: the manager keeps its label in `following.json`, a restart resumes, and removing that batch ends Follow. Since `considered` is kept, the first step after a restart adds the rows that arrived in between.
- A batch made without a source cannot follow; `create` refuses `follow=True` without a source.
- A batch that follows has no last row. With one, the rows filled between the last row chosen and the making would be considered and never added, and the rows that arrive later would be. The range that a person picks is a value, `Range(first, last, later)`, which the manager reads: `create(follow=True)` with a `Range` that has a `last` is refused there. The page leaves the end of the range open while Follow is ticked, to say so before a person sends the form; the command does not follow. A `choose` that is a function may pick any rows, also with Follow: the rows were chosen in code, and the filled rows that it leaves out are considered, so Follow adds only the rows that arrive later.
- Nothing is kept that says a batch has followed. A batch is stopped when another label, or none, is in `following.json`, and no call writes its label there again.
- At most one batch follows, as in ADR 0011: `Intake` keeps whether a batch follows in its `source.json`, a restart resumes, and removing that batch ends Follow. Since `considered` is kept, the first step after a restart adds the rows that arrived in between.
- A batch made without a source cannot follow: only `intake.create`, which takes a source, takes `follow=True`.
- A batch that follows has no last row. With one, the rows filled between the last row chosen and the making would be considered and never added, and the rows that arrive later would be. The range that a person picks is a value, `Range(first, last, later)`, which `Intake` reads: `create(follow=True)` with a `Range` that has a `last` is refused there. The page leaves the end of the range open while Follow is ticked, to say so before a person sends the form; the command does not follow. A `choose` that is a function may pick any rows, also with Follow: the rows were chosen in code, and the filled rows that it leaves out are considered, so Follow adds only the rows that arrive later.
- Nothing is kept that says a batch has followed. A batch is stopped when its `source.json` says that it does not follow, and no call writes that it follows again.
- So the next batch is one form, "New batch" with Follow, and a step never takes a row that another batch took since.
- On the page, Follow is a state with one action, "Stop following", not a switch.

Expand Down Expand Up @@ -175,7 +174,7 @@ A batch made from `sample-runs` with the rows from run 60339 on, with Follow.

## Consequences

- `Scope`, `Row.index`, `Source.index_type`, `Source.index_title`, `Header.scope`, `Header.source` and `manager.change(scope=...)` go. `Source.fills` stays, with a second use: it says when a row is filled.
- `Scope`, `Row.index`, `Source.index_type`, `Source.index_title`, `Header.scope`, `Header.source` and `manager.change(scope=...)` go. `RowSource.fills` stays, with a second use: it says when a row is filled.
- The rule of a step is "ready and without a record". `RowState.changed_by_hand`, the columns `at` of `Automatic`, and the exception for cells set by hand go.
- A row that only waits is not in the table. The page says how many rows wait, and a person can add them.
- A transmission run measured again reaches no earlier row, and a correction of a run changes no row that the table has.
Expand Down
18 changes: 9 additions & 9 deletions docs/developer/tours/layers.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ <h1>essapps, layer by layer</h1>
runs.setdefault(f.metadata['sample'], []).append(str(f.ref))
return pd.DataFrame({'runs': runs.values()}, index=list(runs))

source = Source(angles, fills=('runs',), selector=Selector(role='sample'))
manager = BatchManager(client, sources={'angles': source},
definitions=FolderDefinitions(folder))
manager.create('stitch', title='reflectivity', source='angles', follow=True,
settings={'reference': file(run=500)})
manager.step() # called every few seconds` },
source = RowSource(angles, fills=('runs',), selector=Selector(role='sample'))
intake = Intake(BatchManager(client, definitions=FolderDefinitions(folder)),
sources={'angles': source})
intake.create('stitch', title='reflectivity', source='angles', follow=True,
settings={'reference': file(run=500)})
intake.step() # called every few seconds` },
{ level: 11, caller: 'all', placement: 'service', planned: SERVICE, title: 'Many controllers, one history',
body: `<p>All clients of a proposal share its history. A notebook can reference a transmission that the automatic reduction computed, and the app lists that record in its pickers.</p>
<p>Every client of a workspace reads the same values. The automatic reduction persists its outputs, so they outlive the workspace. A proposal has one workspace. Whether its users share the values in memory, or the service separates or bounds them per user, is open. Provenance follows each reference back to the files.</p>`,
Expand Down Expand Up @@ -290,7 +290,7 @@ <h1>essapps, layer by layer</h1>
const CALLER_SMALL = [
h('Jupyter notebook', '', '<pre class="mini">client.submit(IOFQ, ...)</pre>'),
h('Panel app', '', '<pre class="mini">App(client)</pre>'),
h('Automatic reduction', '', '<pre class="mini">manager.step()</pre>'),
h('Automatic reduction', '', '<pre class="mini">intake.step()</pre>'),
];

function layout(cfg, { box, arrow }) {
Expand Down Expand Up @@ -405,8 +405,8 @@ <h1>essapps, layer by layer</h1>
caller: {
notebook: `record = client.submit(SPEC, params={...})\nclient.output(record, ...)`,
app: 'app = App(client)',
trigger: 'manager.step() # every few seconds',
all: '# each in its own process, with its own client\nclient.submit(SPEC, params={...})\nApp(client)\nmanager.step() # every few seconds',
trigger: 'intake.step() # every few seconds',
all: '# each in its own process, with its own client\nclient.submit(SPEC, params={...})\nApp(client)\nintake.step() # every few seconds',
},
};

Expand Down
6 changes: 3 additions & 3 deletions docs/developer/user-stories.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Automatic reduction belongs to its sub-design ([automatic-reduction.md](automati
The stories use these calls:

```python
source = Source(rows_of_files, fills=(...)) # rows_of_files: the files -> a DataFrame of rows
source = RowSource(rows_of_files, fills=(...)) # rows_of_files: the files -> a DataFrame of rows
batch = Batch(client, SPEC, label=..., rows=rows_of(client, source), persist=True)
done = step(batch, source, considered) # reads batch.settings at each step
done.records # the step added the new rows of the source, and reduced the ready rows without a result; their records by key
Expand Down Expand Up @@ -648,7 +648,7 @@ def per_run(files): # every raw file
return pd.DataFrame({'sample': [f.ref.file for f in files]},
index=[str(f.metadata['run']) for f in files])

PER_RUN = Source(per_run, fills=('sample',))
PER_RUN = RowSource(per_run, fills=('sample',))

def iofq_batch(client):
return Batch(client, IOFQ, label='iofq', rows=rows_of(client, PER_RUN),
Expand All @@ -674,7 +674,7 @@ def angles(files): # a row per sampl
return pd.DataFrame({'sample': list(runs),
'runs': [[f.ref.file for f in found] for found in runs.values()]}, index=keys)

source = Source(angles, fills=('runs',))
source = RowSource(angles, fills=('runs',))
batch = Batch(client, STITCH, label='reflectivity', rows=rows_of(client, source),
persist=True, settings={'reference': reference})
counts = {2: [1.0, 2.0], 3: [1.0, 1.0], 4: [4.0, 8.0]}
Expand Down
Loading
Loading