Skip to content

Collect Datasets

Stacks the per-dataset files one script wrote into a single file. A sweep runs a script once for each dataset, and each run writes <Script_Name>_<dataset>.csv into the folder of that dataset. This script reads all of them and writes <Script_Name>_All.csv. It does one task. It computes nothing and reads no Output.csv.

The app bundles this script as Collect_Datasets.R and Collect_Datasets.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.

Collect_Datasets.py needs python3 only. Collect_Datasets.R needs Rscript only. Both write the same bytes from the same input, which the test suite checks.

Requirements

LanguageNeeds
PythonPython 3.11 or later. No package.
RR 4.3 or later. No package.

The test suite runs on these versions in GitHub Actions. Older versions are not tested.

Inputs and Outputs

InputSourceRead as
The parent folderFirst command-line argument, then EXPERIMENTER_OUTPUT_DIRThe folder whose sub-folders each hold the files of one dataset
The script nameThe required option --stemThe file-name stem, for example Calibration_Fit. --stem=Calibration_Fit also works
The dataset filesEach folder directly under the parentEvery file named <Script_Name>_<name>.csv, except <Script_Name>_All.csv
OutputWritten toHolds
<Script_Name>_All.csvThe parent folderThe header once, then every row of every dataset file, in folder-name order
python3 Collect_Datasets.py /path/to/sweep-outputs --stem Calibration_Fit

Core Mechanics

The script copies lines and does not parse them, so every cell reaches the roll-up exactly as the first script wrote it. It rebuilds the file on every run from the files that exist at that time. A dataset with no file leaves the roll-up. A row from an earlier sweep never stays.

Where It Runs

Put it in the run order below the Script items that write the dataset files:

model: Model.stmx
runs:
  fit: {}
  to-long:
    script: "python3 Wide_To_Long.py"
  score:
    script: "python3 Calibration_Fit.py"
  roll-up:
    script: "python3 Collect_Datasets.py --stem Calibration_Fit"

Pass the parent folder as the first argument if the Outputs folder of the Script item is not that parent. The chaining rules name the file-name convention that lets this script collect the files of any other script.

Likely Issues and Error Types

Every failure below stops the script with a non-zero exit and a message on standard error. No roll-up is written.

  • --stem is missing, or it has no value. Pass the script name as --stem <Script_Name>.
  • The command line has another option, or a second folder. The old form, with the script name as a positional argument, stops here.
  • No folder is given, or the folder does not exist.
  • No <Script_Name>_<dataset>.csv file is in any folder under the parent. Run the script that writes them first.
  • Two files have different header rows. The message names both files. They come from different scripts or from different versions of one script.
  • A dataset file is empty.

Version Policy

The script reads no Output.csv, so a new column in Output.csv does not affect it. It was written for Experimenter 0.3.0.