Script Template
A starting point for a new Experimenter Script, in R and in Python. It
resolves the Outputs folder. It reads the collated Output.csv and the Batch
record (batch.json). It lists the job folders. It locates the fit carrier
and log files of an Optimization and the comparative export of a
Sensitivity. It writes nothing and makes no claim about the model. Copy the
file, keep every section above Report, and add your own analysis after it.
The app bundles this script as Script_Template.R and Script_Template.py. Type the bare file name as a Script’s File, or pick it with Bundled scripts… on a Script row. A copy beside the Experiment file runs in place of the bundled one. See Run your own R or Python. Back to the Scripts.
| File | Needs |
|---|---|
Script_Template.R | Rscript and jsonlite. Install it with install.packages("jsonlite") |
Script_Template.py | python3 and pandas. Install it with pip install pandas |
Requirements
| Language | Needs |
|---|---|
| Python | Python 3.11 or later, with pandas. Install it with pip install pandas. |
| R | R 4.3 or later, with jsonlite. Install it with install.packages("jsonlite"). |
The test suite runs on these versions in GitHub Actions. Older versions are not tested.
Where it runs
With no argument, the Outputs folder comes from EXPERIMENTER_OUTPUT_DIR
and the time column from EXPERIMENTER_TIME_COLUMN. This is the shape that
an Experimenter Script step runs in. You can also give the folder of a
finished batch by hand as the first command-line argument. Then the script
finds the time column by elimination against the column set that
Experimenter publishes. The argument wins when you give both.
The script reads Output.csv in either layout. EXPERIMENTER_OUTPUT_LAYOUT
names it, and the header decides when the variable is unset. It prints one
line that names the layout it read. The loader melts a wide file to the long
shape, so the code after it is the same for both.
Rscript Script_Template.R /path/to/Outputs/MyBatchWhat it binds
Every value this file loads has one named variable and a comment that states what it holds:
- The row count and column set of
Output.csv, and the resolved time column. - The job names and the saved-run names, told apart by
source_kindand never by name. - The parsed Batch record, and the job entries under the output folder with their folder names.
- When present, the comparative export of a Sensitivity and the fit carrier
of an Optimization, with its optimizer log and report. The import/export role of each
data_filesrecord in a job entry finds the fit carrier. A fixed file name such asParameters.csvnever does.
One Batch writes one record, batch.json, at the Batch root. The script
looks for it in the output folder, then in up to four folders above. A
Script in a dataset lane or a Sequence group has a folder inside the Batch
root. The record therefore sits above it. The script keeps the entries of the
jobs list whose folder lies under its own output folder. The folder is
relative to the Batch root. The record also holds id, status,
environment, sequences, datasets and scopes. The script leaves
those for your own analysis. A copy of Output.csv has no record, and that
is not an error.
What it prints
One summary line. It gives the row and column count, the time column and the job names. It also gives the saved-run names and the job folder names. It gives the Batch record (status, and the job, sequence and dataset counts) and says whether it found a Sensitivity or an Optimization role. Each of these cases stops the script with a message that names the problem:
- A missing output folder, a folder that does not exist, or a missing
Output.csv. - A required column missing from
Output.csv. - A
source_kindother thanjoborsaved_run. - A
batch.jsonthat is not valid JSON. - More than one unrecognized column.
In a Chain
The template reads Output.csv and writes nothing. A new script made from it
writes <Script_Name>.csv, or <Script_Name>_<dataset>.csv when it runs once
for each dataset, into the folder it read. See the chaining
rules.
Version Policy
The library README sets the format policy. The header of this file names the Experimenter version that it targets. The script checks every column before it reads anything. An unknown column stops the script with a message that names it. A version difference prints one line and does not stop the run.