# chueh-ermon/automate-arbin-schedule-file-creation architecture

> Architecture diagram of the GitHub repository chueh-ermon/automate-arbin-schedule-file-creation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chueh-ermon/automate-arbin-schedule-file-creation
- Repository: https://github.com/chueh-ermon/automate-arbin-schedule-file-creation

## Overview

##### Project type and purpose
- This is an open-source, command-line Python tool whose sole purpose is to automate generation of Arbin cycler schedule files (.sdu) and batch mapping files (.bth) from human-readable input (CSV policies and template files).
- Key use-cases:
- Generate standardized charging/discharge/rest sequences (“schedule files”) based on policy CSV.
- Generate batch files that assign schedules to instrument channels.

##### File structure
- Top-level scripts:
- automate_4step.py – reads `policies_all.csv` (or user CSV) + `template_4step.sdu` to emit multiple .sdu files.
- automate_batchfile.py / automate_batchfile_validation.py – read a set of .sdu files plus `batch_template.bth` to produce .bth files.
- Data directories:
- “OED schedule files/” – stores all generated .sdu files (both historical and validation sets).
- old/ – legacy scripts (3-step version and raw templates).
- Configuration and templates:
- `template_4step.sdu`, `batch_template.bth`
- `policies_all.csv` – primary input policy definitions.
- No external microservices or databases—everything is filesystem-based.

##### README for additional insights
- Clarifies that the scripts perform simple text substitution on templates.
- Mentions an external GitHub data source for batch assignments (battery-parameter-spaces), which could be drawn as an external dependency.

a. Main components
- Input Layer
– Policy CSV(s) (`policies_all.csv` or user-supplied)
– Template files (.sdu and .bth)
- Processing Layer
– Python generator modules:
· automate_4step.py
· automate_batchfile.py / validation version
- Output Layer
– Generated schedule files folder (`OED schedule files/…`)
– Generated batch files (.bth)
- External Data Source (optional)
– GitHub repo of battery-parameter-spaces for random policy assignment

b. Relationships / data flow
1. Policy CSV → automate_4step.py → text-substitution engine + `template_4step.sdu` → new .sdu files → write to “OED schedule files/”
2. Generated .sdu files + channel assignments → automate_batchfile.py → text-substitution on `batch_template.bth` → output .bth files
3. Optionally, automate_batchfile.py fetches or references external data source for random assignments.

c. Architectural patterns / design principles
- Modular scripts separated by function (schedule vs batch generation).
- Template-driven code generation (simple templating pattern).
- Filesystem-centric pipeline: no database or web layer.

d. Relevant technologies
- Python 3.x – core scripting language
- CSV I/O (standard library)
- Filesystem operations (read/write templates and outputs)

##### Detailed capture
- Legacy path (old/ folder) if it matters for versioning discussions.
- File names next to components to make it concrete.
- Both automate_4step and automate_batchfile flows side by side, then converge on the final outputs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Input Layer"
        PolicyCSV["Policy CSV\npolicies_all.csv"]:::input
        SDUTemplate["SDU Template\ntemplate_4step.sdu"]:::input
        BatchTemplate["Batch Template\nbatch_template.bth"]:::input
    end

    subgraph "Processing Layer"
        ScheduleGen["Schedule Generator\nautomate_4step.py"]:::process
        BatchGen["Batch File Generator\nautomate_batchfile.py"]:::process
        BatchVal["Batch File Validator\nautomate_batchfile_validation.py"]:::process
    end

    subgraph "Output Layer"
        ScheduleOut["Generated Schedules\nOED schedule files/"]:::output
        BatchOut["Generated Batch Files\n.bth files"]:::output
    end

    subgraph "External Data Source"
        GitHub["Battery Parameter Spaces\nGitHub Repo"]:::external
    end

    subgraph "Legacy (old/)"
        OldAuto["Legacy Automation\nold/automate.py"]:::legacy
        Old3Step["Legacy 3-Step Generator\nold/automate_3step.py"]:::legacy
        OldTemplate["Legacy SDU Template\nold/template.sdu"]:::legacy
    end

    PolicyCSV -->|"reads"| ScheduleGen
    SDUTemplate -->|"template"| ScheduleGen
    ScheduleGen -->|"writes"| ScheduleOut

    ScheduleOut -->|"reads"| BatchGen
    BatchTemplate -->|"template"| BatchGen
    GitHub -->|"optional reference"| BatchGen
    BatchGen -->|"writes"| BatchOut

    BatchOut -->|"validate"| BatchVal

    click PolicyCSV "https://github.com/chueh-ermon/automate-arbin-schedule-file-creation/blob/master/policies_all.csv"
    click SDUTemplate "https://github.com/chueh-ermon/automate-arbin-schedule-file-creation/blob/master/template_4step.sdu"
    click BatchTemplate "https://github.com/chueh-ermon/automate-arbin-schedule-file-creation/blob/master/batch_template.bth"
    click ScheduleGen "https://github.com/chueh-ermon/automate-arbin-schedule-file-creation/blob/master/automate_4step.py"
    click BatchGen "https://github.com/chueh-ermon/automate-arbin-schedule-file-creation/blob/master/automate_batchfile.py"
    click BatchVal "https://github.com/chueh-ermon/automate-arbin-schedule-file-creation/blob/master/automate_batchfile_validation.py"
    click ScheduleOut "https://github.com/chueh-ermon/automate-arbin-schedule-file-creation/tree/master/OED schedule files/"
    click OldAuto "https://github.com/chueh-ermon/automate-arbin-schedule-file-creation/blob/master/old/automate.py"
    click Old3Step "https://github.com/chueh-ermon/automate-arbin-schedule-file-creation/blob/master/old/automate_3step.py"
    click OldTemplate "https://github.com/chueh-ermon/automate-arbin-schedule-file-creation/blob/master/old/template.sdu"

    classDef input fill:#cce5ff,stroke:#4da3ff,color:#024;
    classDef process fill:#d4edda,stroke:#28a745,color:#155;
    classDef output fill:#fff3cd,stroke:#ffc107,color:#664;
    classDef external fill:none,stroke:#6c757d,stroke-dasharray:5 5,color:#6c757d;
    classDef legacy fill:#e2e3e5,stroke:#adb5bd,color:#6c757d,stroke-dasharray:5 5;
```
