On this page
Data generation module that runs scripts in bubblewrap sandboxes with read-only mounts, validates JSON/CSV output, and writes results to .selfdoc/data/.
#selfdoc.gendata
#selfdoc.gendata
Generate data files by running sandboxed scripts via bubblewrap (bwrap).
#GenDataError
Raised when gen-data encounters an error.
#_validate_script
def _validate_script(script)Validate that a script declaration has all required fields.
Raises GenDataError if command, output, or mounts is missing or invalid.
#_check_bwrap
def _check_bwrap()Check that bwrap is available on the system.
Raises GenDataError with installation instructions if not found.
#_build_bwrap_command
def _build_bwrap_command(script, base_dir, output_dir)Build the bwrap command list for a script declaration.
Returns a list of strings suitable for subprocess.run.
#_validate_output
def _validate_output(filepath)Validate that an output file is valid JSON or CSV based on extension.
Raises GenDataError if the file cannot be parsed.
#generate_data
def generate_data(config, base_dir='.')Run sandboxed scripts to generate data files.
Reads gen_data.scripts from config, runs each script inside a bwrap sandbox, and validates the output. Returns a list of output file paths.
Raises GenDataError on validation failures, missing bwrap, or script errors.