Why streaming?
- Long-running operations - Molecular packing can take minutes
- User feedback - Agents can report “45% complete” instead of just spinning
- Timeout detection - Detect stuck processes via lack of events
- Resource monitoring - Track iteration counts, convergence rates
Enabling Streaming
Add the--stream flag to any warp-md CLI command:
Event Reference
warp-pack Events
| Event | Fields | Description |
|---|---|---|
pack_started | total_molecules, box_size, output_path | Initial configuration |
phase_started | phase, total_molecules, max_iterations | Phase begins |
molecule_placed | molecule_index, total_molecules, progress_pct | Core placement progress |
gencan_iteration | iteration, obj_value, pg_sup, progress_pct, eta_ms | Optimization iteration |
phase_complete | phase, elapsed_ms, final_obj_value | Phase finished |
pack_complete | total_atoms, elapsed_ms, profile_ms | Final result |
error | code, message | Error occurred |
Phases
template_load- Loading input structurescore_placement- Initial molecule placementmovebad- Stochastic refinement passesgencan- Gradient-based optimizationrelax- Final overlap relaxation
warp-pep Events
| Event | Fields | Description |
|---|---|---|
operation_started | operation, total_residues, total_mutations | Build/mutate starts |
mutation_complete | mutation_index, mutation_spec, progress_pct | Each mutation |
operation_complete | total_atoms, elapsed_ms | Final result |
error | code, message | Error occurred |
warp-md run Events
| Event | Fields | Description |
|---|---|---|
run_started | run_id, analysis_count, progress_pct, eta_ms | Config run begins |
analysis_started | index, analysis, out, progress_pct | Single analysis starts |
analysis_completed | index, analysis, status, timing_ms | Single analysis done |
analysis_failed | index, analysis, error | Single analysis failed |
run_completed | final_envelope | All analyses complete |
run_failed | final_envelope | Run failed |
Example Stream Output
warp-pack
warp-md run
Python Integration
Basic Event Parsing
Real-Time Progress Tracking
Agent Framework Integration
- LangChain
- CrewAI
Error Handling
All errors emit structured events:Error Codes
| Code | Meaning | Recovery |
|---|---|---|
E_CONFIG_VALIDATION | Invalid config file | Fix YAML/JSON syntax |
E_PLACEMENT_FAILED | Cannot place molecule | Increase box size or reduce molecule count |
E_FILE_NOT_FOUND | Missing input file | Check file paths |
E_INTERNAL | Unexpected error | Report bug |
Best Practices
Always Stream
Use
--stream in agent contexts to enable monitoring and timeout detection.Parse Line-by-Line
Don’t buffer entire output - process events as they arrive.
Monitor ETA
Use
eta_ms fields to estimate completion time for users.Check Final Event
Confirm success via
pack_complete/operation_complete events.Performance Considerations
- Streaming overhead: less than 1% CPU, minimal memory
- Event frequency: ~1-10 events/second during optimization
- No performance impact on core computation
See Also
- Molecule Packing - warp-pack usage and configs
- Peptide Builder - warp-pep workflows
- CLI Usage - Command-line patterns