A service that processes pending private patchflow runs from a PostgreSQL database and executes the patchflow command for each matching run.
- Python 3.12+ (as specified in pyproject.toml)
- PostgreSQL database access
- uv - Fast Python package installer and virtual environment manager
-
Clone this repository
-
Copy
.env.exampleto.env:cp .env.example .env
-
Edit
.envand add your database credentials and configuration:DB_HOST=your_database_host DB_NAME=your_database_name DB_USER=your_database_user DB_PASSWORD=your_database_password DB_PORT=your_database_port ORGANIZATION_ID=your_organization_id PATCHWORK_EXEC=path_to_patchwork_executable OUTPUT_DIR=path_to_output_directory READ_ONLY=false # Set to true for dry-run mode -
Install dependencies using uv:
uv sync
-
Make the script executable:
chmod +x main.py
Run the script manually:
./main.pyTo run the script every minute, add this line to your crontab:
* * * * * /path_to_directory/.venv/bin/python /path_to_directory/main.py >> /path_to_logfile/logfile.log 2>&1The script will:
- Connect to the PostgreSQL database
- Find pending private patchflow runs for your organization
- For each pending run:
- Execute the patchflow command with the run's inputs
- Log the command output
- Update the run's status and outputs in the database
- Handle any errors that occur during processing
pyproject.toml: Project configuration and dependenciesmain.py: Main script for processing patchflow runs.env.example: Example environment variables.gitignore: Git ignore rules
The project uses the following main dependencies (as specified in pyproject.toml):
- python-dotenv>=1.1.0
- psycopg2>=2.9.9
- strip-ansi>=0.1.1
The script logs:
- Database connection status
- When it starts processing a run
- Command execution details
- Success/failure status for each run
- Any errors that occur during processing
The script includes error handling for:
- Database connection issues
- Failed patchflow command execution
- File I/O operations
- General exceptions
DB_HOST: PostgreSQL database hostDB_NAME: PostgreSQL database nameDB_USER: PostgreSQL database userDB_PASSWORD: PostgreSQL database passwordDB_PORT: PostgreSQL database port (default: 5432)ORGANIZATION_ID: Your organization IDPATCHWORK_EXEC: Path to the patchwork executableOUTPUT_DIR: Directory to store output filesREAD_ONLY: Set to "true" for dry-run mode (default: "false")