Flow Maker
This script orchestrates a sequence of Python programs to perform a comprehensive analysis related to automation processes. It takes an initial JSON input, runs various analysis and generation scripts, potentially generates alternative process trees, and outputs the results, including intermediate files, metadata, and a final assembled report (typically HTML), into a unique flow-specific directory.
This script orchestrates a sequence of Python programs to perform a comprehensive analysis related to automation processes. It takes an initial JSON input, runs various analysis and generation scripts, potentially generates alternative process trees, and outputs the results, including intermediate files, metadata, and a final assembled report (typically HTML), into a unique flow-specific directory.
Purpose¶
The flow-maker.py script serves as the main driver for a multi-step automation analysis workflow. It manages the execution order of several specialized Python scripts, handles input/output file paths between steps, creates a structured output directory for each run, and optionally generates alternative analysis variations based on input parameters.
Usage¶
To run the script, use the following command structure:
python flow-maker.py <input_json> [breadcrumbs]
<input_json>: (Required) Path to the primary JSON file containing the initial data and configuration for the flow.[breadcrumbs]: (Optional) A string providing context or tracking information, which will be saved in the output directory.
Input Files¶
<input_json>: A JSON file that provides the starting data for the analysis flow. It may contain parameters controlling the execution, such as the number ofalternativesto generate.[breadcrumbs]: An optional string passed as a command-line argument. If provided, it’s saved tobreadcrumbs.txtwithin the flow’s output directory for tracking or informational purposes.
Key Functions¶
run_program(program_name, input_path, output_path, extra_args=None):- Executes a specified Python script (
program_name) usingsubprocess.run. - Passes the
input_pathandoutput_pathas command-line arguments to the target script. - Includes any
extra_argsprovided. - Captures standard output and standard error.
- Prints status messages and returns
Trueon success orFalseon failure.
- Executes a specified Python script (
main():- Parses command-line arguments (
input_json,breadcrumbs). - Loads the initial
input_datafrom the specified JSON file usingutils.load_json. - Generates a unique UUID (
flow_uuid) for the run. - Creates the main output directory:
flow/<flow_uuid>/. - Copies the input JSON and saves breadcrumbs (if any) into the flow directory.
- Defines and executes the sequence of programs (see Program Execution Flow).
- Handles the generation of alternative trees if requested (see Alternative Tree Generation).
- Generates and saves
flow-metadata.jsonsummarizing the run.
- Parses command-line arguments (
utilsModule Functions:- Imports helper functions like
load_json(to read JSON files),save_output,create_output_metadata,get_output_filepath, andhandle_command_argsfrom a sharedutils.pymodule. These handle common tasks like file I/O and argument parsing across the different scripts in the workflow.
- Imports helper functions like
Program Execution Flow¶
The script executes a predefined sequence of Python programs. Each program typically takes the output of the previous step (or the initial input) as its input and generates an output file.
- Directory Setup: A unique directory
flow/<flow_uuid>is created. The initial<input_json>is copied toflow/<flow_uuid>/input.json. - Sequential Execution: The following scripts are run in order:
generate-metadata.py: Inputinput.json, Output1.jsonhallucinate-tree.py: Inputinput.json, Output2.json(with-saveInputs,-flow_uuid=<uuid>,-flatargs)generate-automation-timeline.py: Inputinput.json, Output3.jsongenerate-automation-challenges.py: Inputinput.json, Output4.jsonautomation-adoption.py: Inputinput.json, Output5.jsoncurrent-implementations.py: Inputinput.json, Output6.jsonreturn-analysis.py: Inputinput.json, Output7.jsonfuture-technology.py: Inputinput.json, Output8.jsonspecifications-industrial.py: Inputinput.json, Output9.jsonassemble.py: Input is the entireflow/<flow_uuid>directory. Output is typically an HTML report within the same directory (specific output filename determined byassemble.py).
- Input/Output Handling:
- For most steps, the input is the copied
input.json. - Intermediate outputs are saved as numbered JSON files (
1.jsonthrough9.json) within theflow/<flow_uuid>directory. assemble.pyis treated specially: it takes the entire flow directory path as input and is responsible for generating the final report(s).
- For most steps, the input is the copied
Alternative Tree Generation¶
If the initial <input_json> file contains a key "alternatives" with a value greater than 0, the script will generate that number of alternative process trees:
- Input Variation: For each alternative, a copy of the original
input_datais made. Parameters liketemperature,approach_name, andapproach_descriptionare modified to encourage diverse outputs. - Saving Inputs: Each modified input is saved to
flow/<flow_uuid>/inputs/alt_input_<N>.json. - Execution:
hallucinate-tree.pyis run for each alternative input using the-flatargument. - Output: The output for each alternative is saved to
flow/<flow_uuid>/alt<N>.json.
Output¶
The script generates a primary output directory named flow/<flow_uuid>/, where <flow_uuid> is a unique identifier for the run. This directory contains:
input.json: A copy of the original input JSON file provided to the script.breadcrumbs.txt: (Optional) Contains the breadcrumbs string if provided via the command line.1.json-9.json: Intermediate JSON output files generated by the corresponding scripts in the execution flow.inputs/: A subdirectory created if alternatives are generated.alt_input_1.json,alt_input_2.json, …: The modified input JSON files used for generating alternative trees.
alt1.json,alt2.json, …: (Optional) The JSON output files for each generated alternative tree.flow-metadata.json: A JSON file containing metadata about the flow run, including the UUID, timestamp, time taken, input file path, and list of programs executed.- Final Report(s): Files generated by the final
assemble.pyscript (e.g., an HTML report). The exact filenames depend on the implementation ofassemble.py.