srim.notebook¶
Run folders for notebooks: read a run or scan folder back, finished or not (Qt-free).
A notebook opens a folder with load_run(). A finished folder (result/scan.csv is there)
is read as it was written. An unfinished one (a run that stopped or crashed) gives the points
whose folders have outputs. LoadedRun.point() reads a point’s results, a plain
Results or the merged results of a batched point.
LoadedRun.mark_loaded() records in the folder (.pysrim2-notebook/loaded.json) how many
points the notebook read, so a later reader can tell whether the folder has changed since.
- srim.notebook.LOADED_FILE = 'loaded.json'¶
the file in
NOTEBOOK_DIRthatLoadedRun.mark_loaded()writes
- class srim.notebook.LoadedRun(folder: Path, result: ScanResult, finished: bool, count: int, outputs: dict[int, str]=<factory>)¶
A run or scan folder read for a notebook.
folderis the folder,resultitsScanResult,finishedwhether the run finished, andcountthe number of the scan’s points with outputs.outputsmaps the index of each of those points to its path relative tofolder.- mark_loaded() None¶
Write
.pysrim2-notebook/loaded.json(the count and whether the run finished).The file is written to a temporary file in the same folder and then moved into place, so a reader never sees a part-written file. It is readable by others (mode 0644).
- points() list[int]¶
The indexes of the points that have outputs, in order.
- srim.notebook.NOTEBOOK_DIR = '.pysrim2-notebook'¶
the folder inside a run folder where notebooks keep their own files
- srim.notebook.RELOAD_FILE = 'reload'¶
the name of the file that asks for a reload (only the name is defined here)
- srim.notebook.has_outputs(point_dir: Path) bool¶
A point’s folder holds its run.yaml (or units.csv, when it was batched).
- srim.notebook.load_run(folder) LoadedRun¶
Read a run or scan folder for a notebook, finished or not.
countis the number of the scan’s own points (fromscan.yaml) whose folderpoints/<id[:16]>has outputs;results_count()gives the same number for an unchanged folder. RaisesFileNotFoundErrornaming the folder when it has noscan.yaml.
- srim.notebook.loaded_count(folder) int | None¶
The
pointsof.pysrim2-notebook/loaded.json, or None when the file is absent or cannot be read as a count.
- srim.notebook.open_point(folder: Path, rel_path: str)¶
The results of a point of a scan folder: merged when the point was batched (it has a
units.csv), else the plainResultsof its folder.
- srim.notebook.read_run_folder(folder) tuple[ScanResult, bool]¶
The scan result of a run folder, and whether the run finished.
A finished run (
result/scan.csvis there) is read as it was written. Otherwise the table is built from the scan’s points:donefor a point whose folder has outputs, elsemissing. RaisesFileNotFoundErrorfor a folder withoutscan.yaml.
- srim.notebook.results_count(folder) int¶
The number of the scan’s points whose folder has outputs (see
load_run()).Reads
scan.yaml. 0 for a folder that is missing, or whosescan.yamlcannot be read; never raisesOSError.