vgraph 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vgraph/__init__.py +25 -0
- vgraph/api.py +45 -0
- vgraph/cli.py +41 -0
- vgraph/compile.py +247 -0
- vgraph/engine.py +314 -0
- vgraph/graph.schema.json +56 -0
- vgraph/inputs.py +82 -0
- vgraph/model.py +63 -0
- vgraph/py.typed +0 -0
- vgraph/registry.py +183 -0
- vgraph/server/__init__.py +1 -0
- vgraph/server/app.py +248 -0
- vgraph/server/state.py +96 -0
- vgraph/server/views.py +89 -0
- vgraph/server/watch.py +48 -0
- vgraph/static/assets/index-BAxILRja.js +64 -0
- vgraph/static/assets/index-CsCg66zj.css +1 -0
- vgraph/static/index.html +14 -0
- vgraph/topology.py +129 -0
- vgraph/typing_utils.py +88 -0
- vgraph-0.1.0.dist-info/METADATA +213 -0
- vgraph-0.1.0.dist-info/RECORD +25 -0
- vgraph-0.1.0.dist-info/WHEEL +4 -0
- vgraph-0.1.0.dist-info/entry_points.txt +3 -0
- vgraph-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgb(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgb(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #777;--xy-background-pattern-lines-color-default: #777;--xy-background-pattern-cross-color-default: #777;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color, var(--xy-background-color-props, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.center{left:50%;transform:translate(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:4px;height:4px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));transform:translate(-50%,-50%)}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root{--text: #16191f;--muted: #5f6b7a;--border: #d1d5db;--border-strong: #9ba7b6;--surface: #ffffff;--canvas: #f4f5f7;--panel: #fafafa;--accent: #0972d3;--accent-soft: #e8f2fc;--danger: #d13212;--danger-soft: #fdecea;--ok: #037f0c;--focus: 0 0 0 2px #fff, 0 0 0 4px var(--accent);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;color:var(--text)}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}body{background:var(--canvas)}h2,h3{margin:0}.muted{color:var(--muted)}button,select,input{font:inherit;color:inherit}button,select{height:30px;padding:0 12px;border:1px solid var(--border-strong);border-radius:6px;background:var(--surface);cursor:pointer}button:hover:not(:disabled){background:#f2f4f7}button:disabled{color:#9ba7b6;border-color:var(--border);cursor:default}:focus-visible{outline:none;box-shadow:var(--focus)}button.primary{background:var(--accent);border-color:var(--accent);color:#fff;font-weight:600}button.primary:hover:not(:disabled){background:#075fb0}button.primary:disabled{background:#e9ebed;border-color:#e9ebed;color:#8d99a8}button.danger:hover:not(:disabled){color:var(--danger);border-color:var(--danger);background:var(--danger-soft)}button.link{border:none;background:none;color:var(--accent);padding:0 4px;height:auto;text-decoration:underline}.app{display:flex;flex-direction:column;height:100%}.topbar{display:flex;align-items:center;gap:16px;height:52px;padding:0 16px;background:var(--surface);border-bottom:1px solid var(--border)}.brand{font-weight:700;font-size:16px;letter-spacing:-.01em}.brand:before{content:"";display:inline-block;width:10px;height:10px;margin-right:8px;border-radius:2px;background:var(--accent);transform:rotate(45deg)}.graph-list{display:flex;align-items:center;gap:8px}.graph-list select{min-width:160px}.unsaved{font-size:12px;color:var(--muted)}.unsaved:before{content:"● ";color:#c77700}.notice{font-size:13px;padding:4px 8px;border-radius:6px;background:#fff7e0;color:#7a4c00}.spacer{flex:1}.validity{font-size:13px;font-weight:600}.validity.ok{color:var(--ok)}.validity.ok:before{content:"✓ "}.validity.bad{color:var(--danger)}.body{flex:1;display:flex;min-height:0}.main{flex:1;display:flex;flex-direction:column;min-width:0}.palette{width:272px;display:flex;flex-direction:column;background:var(--surface);border-right:1px solid var(--border)}.palette-head{padding:14px 14px 10px;border-bottom:1px solid var(--border)}.palette-head h2{font-size:13px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);margin-bottom:10px}.palette-head input{width:100%;height:30px;padding:0 10px;border:1px solid var(--border-strong);border-radius:6px;background:var(--surface)}.palette-body{flex:1;overflow:auto;padding:8px 10px 16px}.palette-body section{margin-top:10px}.palette-body h3{font-size:12px;font-weight:600;color:var(--muted);padding:4px 4px 6px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.fn-item{display:flex;flex-direction:column;align-items:flex-start;gap:3px;width:100%;height:auto;padding:8px 10px;margin-bottom:6px;text-align:left;border:1px solid var(--border);border-radius:6px;background:var(--surface);cursor:grab}.fn-item:hover:not(:disabled){border-color:var(--accent);background:var(--accent-soft)}.fn-item:disabled{color:inherit;cursor:default;opacity:.6}.fn-name{display:flex;align-items:center;gap:6px;font-weight:600;font-size:13px}.fn-sig{font-size:12px;color:var(--muted);font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.registry-error{font-size:12px;padding:8px;margin-top:8px;border-radius:6px;background:var(--danger-soft);color:var(--danger)}.canvas{flex:1;position:relative;min-height:0;background:var(--canvas)}.canvas-empty{position:absolute;top:0;right:0;bottom:0;left:0;display:grid;place-items:center;pointer-events:none;color:var(--muted);font-size:14px}.react-flow__controls{box-shadow:none;border:1px solid var(--border);border-radius:6px;overflow:hidden}.react-flow__controls-button{border-bottom-color:var(--border);width:28px;height:28px;padding:0}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge:focus .react-flow__edge-path{stroke:var(--accent)!important}.node{position:relative;width:200px;padding:9px 12px;display:flex;flex-direction:column;align-items:flex-start;gap:5px;background:var(--surface);border:1px solid var(--border-strong);border-radius:8px;box-shadow:0 1px 2px #0007160f}.node.invalid{border-color:var(--danger)}.node.selected{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-soft),0 0 0 3px var(--accent)}.react-flow__node:focus-visible{box-shadow:none}.react-flow__node:focus-visible .node{box-shadow:var(--focus)}.node-main{align-self:stretch;display:flex;align-items:center;gap:10px;min-width:0}.node-icon{flex:none;display:grid;place-items:center;width:24px;height:24px;border-radius:6px;background:var(--accent-soft);color:var(--accent);font-weight:700;font-style:italic;font-size:14px}.node-icon.choice{width:15px;height:15px;margin:0 4.5px;border-radius:3px;transform:rotate(45deg);background:#fff4e5;border:1.5px solid #c77700}.node-icon.choice.small{width:9px;height:9px;margin:0 2px;border-width:1.2px}.node-text{min-width:0;flex:1}.node-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.node-sub{display:flex;align-items:center;gap:6px;font-size:11px;color:var(--muted);margin-top:1px}.node-sub>span:first-child{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.node-sub .badge{flex:none}.exit-label{position:absolute;bottom:7px;transform:translate(-50%);font-size:10px;font-weight:600;letter-spacing:.02em;color:#7a4c00;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.react-flow__handle{width:8px;height:8px;background:var(--surface);border:1.5px solid var(--border-strong)}.react-flow__handle-top,.react-flow__handle.back-in{opacity:0}.react-flow__handle-top.connectingto,.react-flow__handle-top.valid{opacity:1}.react-flow__handle:hover,.react-flow__handle.connectingto{border-color:var(--accent);background:var(--accent)}.node.branch .react-flow__handle-bottom{border-color:#c77700}.badge{font-size:10px;font-weight:600;line-height:16px;border-radius:8px;white-space:nowrap}.node .badge.issues{position:absolute;top:-9px}.node .badge.handles{margin-left:34px}.badge.handles{padding:0 6px;background:#f0f4ff;color:#1d4ed8;border:1px solid #c3d4fb}.badge.handles.inline{margin-top:2px}.badge.issues{right:-8px;min-width:18px;height:18px;padding:0 5px;text-align:center;line-height:18px;border-radius:9px;background:var(--danger);color:#fff}.issues{background:var(--surface);border-top:1px solid var(--border)}.issues-head{display:flex;align-items:center;gap:8px;width:100%;height:36px;padding:0 14px;border:none;border-radius:0;background:var(--panel);font-weight:600;font-size:13px}.issues .chevron{width:10px;color:var(--muted)}.count{font-size:11px;padding:0 7px;border-radius:9px;line-height:18px}.count.ok{background:#e7f5e9;color:var(--ok)}.count.bad{background:var(--danger);color:#fff}.issues ul{list-style:none;margin:0;padding:4px 0;max-height:180px;overflow:auto}.issues li.muted{padding:8px 14px;font-size:13px}.issues li button{display:grid;grid-template-columns:180px 1fr auto;gap:12px;align-items:baseline;width:100%;height:auto;padding:7px 14px;text-align:left;border:none;border-radius:0;background:none;font-size:13px}.issues li button:hover:not(:disabled){background:var(--danger-soft)}.issues li button:disabled{color:inherit}.issue-where{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.issue-where:before{content:"";display:inline-block;width:7px;height:7px;border-radius:50%;background:var(--danger);margin-right:8px;vertical-align:1px}.issues code{font-size:11px;color:var(--muted)}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}button.icon{width:28px;height:28px;padding:0;border-color:transparent;background:none;font-size:18px;line-height:1;color:var(--muted)}button.icon:hover:not(:disabled){background:#f2f4f7;color:var(--text)}.chip{display:inline-block;padding:0 8px;border-radius:10px;line-height:20px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:#fff}.chip.small{padding:0 6px;line-height:16px;font-size:10px}.chip.pending{background:var(--st-pending);color:var(--text)}.chip.running{background:var(--st-running)}.chip.ok{background:var(--st-ok)}.chip.failed{background:var(--st-failed)}.chip.skipped{background:var(--st-skipped)}.node.run{border-color:transparent;color:#fff}.node.run.pending{color:var(--text);border-color:#cfd4db}.node.run:not(.pending) .node-sub,.node.run:not(.pending) .exit-label{color:#ffffffd9}.node.run:not(.pending) .node-icon{background:#fff3;color:#fff}.node.run:not(.pending) .node-icon.choice{background:transparent;border-color:#fff}.node.run:not(.pending) .badge.handles{background:#ffffff29;border-color:#fff6;color:#fff}.node.run .react-flow__handle{opacity:0}.node.run.running{animation:run-pulse 1.4s ease-in-out infinite}.node.run.selected{box-shadow:0 0 0 2px #fff,0 0 0 4px var(--accent)}@keyframes run-pulse{0%,to{box-shadow:0 0 #2563eb73}50%{box-shadow:0 0 0 7px #2563eb00}}@media (prefers-reduced-motion: reduce){.node.run.running{animation:none;box-shadow:0 0 0 3px #2563eb4d}}.badge.runs{position:absolute;top:-9px;right:-8px;height:18px;padding:0 6px;line-height:18px;border-radius:9px;background:var(--text);color:#fff;box-shadow:0 0 0 2px var(--canvas)}.run-history{min-width:230px;font-variant-numeric:tabular-nums}.run-bar{display:flex;align-items:center;gap:10px;height:44px;padding:0 14px;background:var(--surface);border-bottom:1px solid var(--border);font-size:13px}.run-bar>*{flex:none;white-space:nowrap}.run-bar>.spacer{flex:1}.run-label{font-weight:700}.run-bar code{font-size:12px;color:var(--muted)}.main{position:relative}.legend{position:absolute;left:14px;bottom:14px;display:flex;gap:12px;padding:6px 10px;background:var(--surface);border:1px solid var(--border);border-radius:6px;color:var(--muted);font-size:12px}.legend span{display:inline-flex;align-items:center;gap:5px}.legend i{width:10px;height:10px;border-radius:3px}.node-panel{width:380px;display:flex;flex-direction:column;background:var(--surface);border-left:1px solid var(--border);min-height:0}.node-panel>header{display:flex;align-items:center;gap:8px;padding:12px 10px 12px 16px;border-bottom:1px solid var(--border)}.panel-title{flex:1;min-width:0;display:flex;align-items:center;gap:10px}.panel-title h2{font-size:15px;font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.exec-picker{display:flex;flex-wrap:wrap;gap:6px;padding:10px 16px;border-bottom:1px solid var(--border);background:var(--panel)}.exec-picker button{height:26px;padding:0 10px;font-size:12px;font-weight:600;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center;gap:6px}.exec-picker button:before{content:"";width:8px;height:8px;border-radius:50%;background:var(--st-pending)}.exec-picker button.ok:before{background:var(--st-ok)}.exec-picker button.failed:before{background:var(--st-failed)}.exec-picker button.running:before{background:var(--st-running)}.exec-picker button.skipped:before{background:var(--st-skipped)}.exec-picker button.on{border-color:var(--accent);background:var(--accent-soft);color:var(--accent)}.panel-body{flex:1;overflow:auto;padding:14px 16px 20px;display:flex;flex-direction:column;gap:16px;align-items:stretch}.panel-body>button{align-self:flex-start}.panel-body h3{font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);margin-bottom:8px}.panel-body p{margin:0;font-size:13px}.facts{display:grid;grid-template-columns:96px 1fr;gap:8px 12px;margin:0;font-size:13px}.facts dt{color:var(--muted)}.facts dd{margin:0;font-variant-numeric:tabular-nums}.value+.value{margin-top:10px}.value-name{font-size:12px;font-weight:600;margin-bottom:4px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}pre.code,textarea.code{margin:0;padding:8px 10px;border:1px solid var(--border);border-radius:6px;background:#f7f8fa;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--text)}pre.code{white-space:pre-wrap;word-break:break-word;max-height:260px;overflow:auto}.error-box pre.code{background:var(--danger-soft);border-color:#f5c2bb;color:#8a1c0b}.error-box h3{color:var(--danger)}.error-box details{margin-top:8px}.error-box summary{cursor:pointer;font-size:13px;font-weight:600;color:var(--muted);padding:2px 0}.error-box details pre.code{margin-top:6px;background:#f7f8fa;border-color:var(--border);color:var(--text);font-size:11px;max-height:340px;white-space:pre;overflow:auto}.run-dialog{width:min(560px,calc(100vw - 32px));padding:0;border:1px solid var(--border);border-radius:10px;box-shadow:0 12px 40px #00071640;color:var(--text)}.run-dialog::backdrop{background:#0f172a66}.run-dialog header{padding:18px 20px 10px}.run-dialog h2{font-size:17px}.run-dialog header p{margin:6px 0 0;font-size:13px}.run-dialog-body{padding:6px 20px 8px}.field-head{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:6px;font-size:13px;font-weight:600}.run-dialog textarea.code{display:block;width:100%;resize:vertical;background:#fbfbfc;border-color:var(--border-strong)}.run-dialog textarea.code[aria-invalid=true]{border-color:var(--danger)}.form-errors{margin:10px 0 0;padding:8px 12px 8px 28px;border-radius:6px;background:var(--danger-soft);color:#8a1c0b;font-size:13px}.form-errors li+li{margin-top:4px}.run-dialog footer{display:flex;justify-content:flex-end;align-items:center;gap:8px;padding:12px 20px 16px}.run-dialog .hint{margin-right:auto;font-size:12px}
|
vgraph/static/index.html
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>vgraph</title>
|
|
7
|
+
<link rel="icon" href="data:," />
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-BAxILRja.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CsCg66zj.css">
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="root"></div>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
vgraph/topology.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""Structural facts about a graph file: forward/back edges, entries, reachability, exclusivity."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
|
|
5
|
+
from vgraph.model import GraphFile
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True)
|
|
9
|
+
class Edge:
|
|
10
|
+
src: str
|
|
11
|
+
dst: str
|
|
12
|
+
exit: str | None = None
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class Topology:
|
|
17
|
+
nodes: list[str]
|
|
18
|
+
forward: list[Edge]
|
|
19
|
+
back: list[Edge]
|
|
20
|
+
entries: list[str]
|
|
21
|
+
_dom: dict[str, set[str]] = field(default_factory=dict, init=False, repr=False)
|
|
22
|
+
|
|
23
|
+
def __post_init__(self) -> None:
|
|
24
|
+
# Dominators on the forward DAG; entries hang off a virtual root.
|
|
25
|
+
# shortcut: iterative set algorithm, O(n^2) sets, fine for hand-written graphs.
|
|
26
|
+
everything = set(self.nodes)
|
|
27
|
+
dom = {n: {n} if n in self.entries else set(everything) for n in self.nodes}
|
|
28
|
+
changed = True
|
|
29
|
+
while changed:
|
|
30
|
+
changed = False
|
|
31
|
+
for n in self.nodes:
|
|
32
|
+
if n in self.entries:
|
|
33
|
+
continue
|
|
34
|
+
new = {n} | set.intersection(*(dom[e.src] for e in self.preds(n)))
|
|
35
|
+
if new != dom[n]:
|
|
36
|
+
dom[n], changed = new, True
|
|
37
|
+
self._dom = dom
|
|
38
|
+
|
|
39
|
+
def preds(self, n: str) -> list[Edge]:
|
|
40
|
+
return [e for e in self.forward if e.dst == n]
|
|
41
|
+
|
|
42
|
+
def succs(self, n: str) -> list[Edge]:
|
|
43
|
+
return [e for e in self.forward if e.src == n]
|
|
44
|
+
|
|
45
|
+
def _walk(
|
|
46
|
+
self, starts: list[str], blocked: frozenset[str] | set[str] = frozenset()
|
|
47
|
+
) -> set[str]:
|
|
48
|
+
seen: set[str] = set()
|
|
49
|
+
todo = [s for s in starts if s not in blocked]
|
|
50
|
+
while todo:
|
|
51
|
+
n = todo.pop()
|
|
52
|
+
if n in seen:
|
|
53
|
+
continue
|
|
54
|
+
seen.add(n)
|
|
55
|
+
todo.extend(e.dst for e in self.succs(n) if e.dst not in blocked)
|
|
56
|
+
return seen
|
|
57
|
+
|
|
58
|
+
def ancestors(self, n: str) -> set[str]:
|
|
59
|
+
seen: set[str] = set()
|
|
60
|
+
todo = [e.src for e in self.preds(n)]
|
|
61
|
+
while todo:
|
|
62
|
+
m = todo.pop()
|
|
63
|
+
if m not in seen:
|
|
64
|
+
seen.add(m)
|
|
65
|
+
todo.extend(e.src for e in self.preds(m))
|
|
66
|
+
return seen - {n}
|
|
67
|
+
|
|
68
|
+
def reachable(self, n: str) -> set[str]:
|
|
69
|
+
return self._walk([e.dst for e in self.succs(n)]) - {n}
|
|
70
|
+
|
|
71
|
+
def reachable_avoiding(self, n: str, blocked: set[str]) -> bool:
|
|
72
|
+
return n in self._walk(self.entries, blocked)
|
|
73
|
+
|
|
74
|
+
def exclusive(self, a: str, b: str) -> bool:
|
|
75
|
+
# A branch takes exactly one member per pass, hence disjoint exit sets mean exclusive.
|
|
76
|
+
for br in self._dom[a] & self._dom[b] - {a, b}:
|
|
77
|
+
edges = self.succs(br)
|
|
78
|
+
if all(e.exit is None for e in edges):
|
|
79
|
+
continue
|
|
80
|
+
exits = [
|
|
81
|
+
{e.exit for e in edges if x == e.dst or x in self.reachable(e.dst)} for x in (a, b)
|
|
82
|
+
]
|
|
83
|
+
if not exits[0] & exits[1]:
|
|
84
|
+
return True
|
|
85
|
+
return False
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def build_topology(graph: GraphFile) -> Topology:
|
|
89
|
+
nodes = list(graph.nodes)
|
|
90
|
+
out: dict[str, list[Edge]] = {}
|
|
91
|
+
for name, spec in graph.nodes.items():
|
|
92
|
+
pairs = (
|
|
93
|
+
[(None, t) for t in spec.next]
|
|
94
|
+
if isinstance(spec.next, list)
|
|
95
|
+
else list(spec.next.items())
|
|
96
|
+
)
|
|
97
|
+
edges = [Edge(name, t, m) for m, t in pairs if t in graph.nodes]
|
|
98
|
+
out[name] = list(dict.fromkeys(edges))
|
|
99
|
+
|
|
100
|
+
back: set[Edge] = set()
|
|
101
|
+
visited: set[str] = set()
|
|
102
|
+
has_any_in = {e.dst for n in nodes for e in out[n]}
|
|
103
|
+
# Roots: no-incoming nodes, then non-branches, so a pure cycle is closed by a branch exit.
|
|
104
|
+
roots = [n for n in nodes if n not in has_any_in]
|
|
105
|
+
roots += [n for n in nodes if not isinstance(graph.nodes[n].next, dict)]
|
|
106
|
+
for root in roots + nodes:
|
|
107
|
+
if root in visited:
|
|
108
|
+
continue
|
|
109
|
+
visited.add(root)
|
|
110
|
+
stack = [root]
|
|
111
|
+
iters = [iter(out[root])]
|
|
112
|
+
while stack:
|
|
113
|
+
for e in iters[-1]:
|
|
114
|
+
if e.dst in stack:
|
|
115
|
+
back.add(e)
|
|
116
|
+
elif e.dst not in visited:
|
|
117
|
+
visited.add(e.dst)
|
|
118
|
+
stack.append(e.dst)
|
|
119
|
+
iters.append(iter(out[e.dst]))
|
|
120
|
+
break
|
|
121
|
+
else:
|
|
122
|
+
stack.pop()
|
|
123
|
+
iters.pop()
|
|
124
|
+
|
|
125
|
+
all_edges = [e for n in nodes for e in out[n]]
|
|
126
|
+
forward = [e for e in all_edges if e not in back]
|
|
127
|
+
back_list = [e for e in all_edges if e in back]
|
|
128
|
+
has_in = {e.dst for e in forward}
|
|
129
|
+
return Topology(nodes, forward, back_list, [n for n in nodes if n not in has_in])
|
vgraph/typing_utils.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""Type-annotation helpers: output fields, exception unions, compatibility."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import dataclasses
|
|
6
|
+
import types
|
|
7
|
+
from functools import reduce
|
|
8
|
+
from operator import or_
|
|
9
|
+
from typing import Any, Union, get_origin, get_type_hints
|
|
10
|
+
|
|
11
|
+
from pydantic import BaseModel
|
|
12
|
+
|
|
13
|
+
_UNIONS = (Union, types.UnionType)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _members(hint: Any) -> tuple[Any, ...]:
|
|
17
|
+
from typing import get_args
|
|
18
|
+
|
|
19
|
+
return get_args(hint) if get_origin(hint) in _UNIONS else (hint,)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _is_exc(t: Any) -> bool:
|
|
23
|
+
return isinstance(t, type) and issubclass(t, Exception)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def exception_classes(hint: Any) -> tuple[type[Exception], ...]:
|
|
27
|
+
"""Exception subclasses appearing in a (union) hint."""
|
|
28
|
+
return tuple(t for t in _members(hint) if _is_exc(t))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def value_hint(hint: Any) -> Any:
|
|
32
|
+
"""The hint minus exception classes (``None`` if nothing is left)."""
|
|
33
|
+
rest = tuple(t for t in _members(hint) if not _is_exc(t))
|
|
34
|
+
if not rest:
|
|
35
|
+
return None
|
|
36
|
+
return reduce(or_, rest)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _struct_fields(t: Any) -> dict[str, Any] | None:
|
|
40
|
+
"""Field hints for a dataclass, NamedTuple or pydantic model, else None."""
|
|
41
|
+
if not isinstance(t, type):
|
|
42
|
+
return None
|
|
43
|
+
if issubclass(t, BaseModel):
|
|
44
|
+
return {k: f.annotation for k, f in t.model_fields.items()}
|
|
45
|
+
if dataclasses.is_dataclass(t) or (issubclass(t, tuple) and hasattr(t, "_fields")):
|
|
46
|
+
hints = get_type_hints(t)
|
|
47
|
+
names = (
|
|
48
|
+
[f.name for f in dataclasses.fields(t)]
|
|
49
|
+
if dataclasses.is_dataclass(t)
|
|
50
|
+
else list(t.__annotations__)
|
|
51
|
+
)
|
|
52
|
+
return {n: hints[n] for n in names}
|
|
53
|
+
return None
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def output_fields(return_hint: Any, fn_name: str, out: str | None) -> dict[str, Any]:
|
|
57
|
+
"""Named outputs produced by a function with this return hint."""
|
|
58
|
+
v = value_hint(return_hint)
|
|
59
|
+
if v is None or v is type(None):
|
|
60
|
+
return {}
|
|
61
|
+
return _struct_fields(v) or {out or fn_name: v}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def extract_outputs(return_hint: Any, fields: dict[str, Any], value: Any) -> dict[str, Any]:
|
|
65
|
+
"""Map a returned value onto the named outputs in ``fields``."""
|
|
66
|
+
if not fields:
|
|
67
|
+
return {}
|
|
68
|
+
if _struct_fields(value_hint(return_hint)) is not None:
|
|
69
|
+
return {k: getattr(value, k) for k in fields}
|
|
70
|
+
return {next(iter(fields)): value}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def is_compatible(produced: Any, consumed: Any) -> bool:
|
|
74
|
+
"""Best effort: generic arguments are not compared, only their origins."""
|
|
75
|
+
if produced is Any or consumed is Any:
|
|
76
|
+
return True
|
|
77
|
+
cons = _members(consumed)
|
|
78
|
+
return all(any(_one(p, c) for c in cons) for p in _members(produced))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _one(p: Any, c: Any) -> bool:
|
|
82
|
+
if p is Any or c is Any:
|
|
83
|
+
return True
|
|
84
|
+
p, c = get_origin(p) or p, get_origin(c) or c
|
|
85
|
+
try:
|
|
86
|
+
return issubclass(p, c)
|
|
87
|
+
except TypeError:
|
|
88
|
+
return p == c
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vgraph
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Typed function graphs with a local web UI
|
|
5
|
+
Author: Lorenzo Gardini
|
|
6
|
+
Author-email: Lorenzo Gardini <l.gardo98@gmail.com>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: pydantic>=2.9
|
|
10
|
+
Requires-Dist: pyyaml>=6
|
|
11
|
+
Requires-Dist: fastapi>=0.115
|
|
12
|
+
Requires-Dist: uvicorn>=0.32
|
|
13
|
+
Requires-Dist: watchfiles>=0.24
|
|
14
|
+
Requires-Dist: websockets>=13
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
<div align="center">
|
|
19
|
+
|
|
20
|
+
<h1>vgraph</h1>
|
|
21
|
+
|
|
22
|
+
<p><strong>Typed Python functions in, a live graph out.</strong></p>
|
|
23
|
+
|
|
24
|
+
<p>
|
|
25
|
+
<a href="https://pypi.org/project/vgraph/"><img alt="PyPI" src="https://img.shields.io/pypi/v/vgraph?logo=pypi&logoColor=white"></a>
|
|
26
|
+
<img alt="Python 3.12+" src="https://img.shields.io/badge/Python-3.12%2B-3776AB?logo=python&logoColor=white">
|
|
27
|
+
<a href="https://github.com/Lorenzo-Gardini/vgraph/blob/main/LICENSE"><img alt="License Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-blue"></a>
|
|
28
|
+
<a href="https://github.com/Lorenzo-Gardini/vgraph/actions/workflows/ci.yml?query=branch%3Amain"><img alt="CI" src="https://github.com/Lorenzo-Gardini/vgraph/actions/workflows/ci.yml/badge.svg?branch=main"></a>
|
|
29
|
+
<a href="https://lorenzo-gardini.github.io/vgraph/"><img alt="Docs" src="https://img.shields.io/badge/docs-mkdocs-526CFE?logo=materialformkdocs&logoColor=white"></a>
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
<p>Compose small, typed functions into a graph, then run it and watch it execute in a
|
|
33
|
+
local editor with AWS Step Functions style colours.</p>
|
|
34
|
+
|
|
35
|
+
<img alt="vgraph running the ingest graph: nodes turn blue while running, then green, red or grey" src="https://raw.githubusercontent.com/Lorenzo-Gardini/vgraph/main/docs/assets/demo.gif" width="800">
|
|
36
|
+
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
## ✨ Why vgraph
|
|
40
|
+
|
|
41
|
+
- **Almost no glue code.** Functions are wired by parameter name and type. No state
|
|
42
|
+
dictionary, no condition strings.
|
|
43
|
+
- **Mistakes are caught early.** Typos, missing inputs, unhandled branch values and
|
|
44
|
+
ambiguous data fail when the graph is loaded, not halfway through a run.
|
|
45
|
+
- **Everything is inspectable.** Every execution of every node keeps its inputs,
|
|
46
|
+
outputs, error, traceback and skip reason.
|
|
47
|
+
- **Plain files.** Graphs are small, diff-friendly YAML files, runnable from Python
|
|
48
|
+
without the UI.
|
|
49
|
+
|
|
50
|
+
## 📦 Install
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uv add vgraph # or: pip install vgraph
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Requires Python 3.12 or newer.
|
|
57
|
+
|
|
58
|
+
## 🚀 Quick start
|
|
59
|
+
|
|
60
|
+
**1. Write functions.** Decorate typed functions with `@node` or `@branch`. From
|
|
61
|
+
[`examples/flows/ingest.py`](https://github.com/Lorenzo-Gardini/vgraph/blob/main/examples/flows/ingest.py) (abridged):
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from vgraph import branch, node
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@node
|
|
68
|
+
async def read_input(path: Path) -> Path:
|
|
69
|
+
if not path.exists():
|
|
70
|
+
raise FileNotFoundError(path)
|
|
71
|
+
return path
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@branch
|
|
75
|
+
async def by_format(path: Path) -> Fmt: # Fmt.CSV or Fmt.JSON picks the next node
|
|
76
|
+
return Fmt(path.suffix[1:])
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@node(out="table")
|
|
80
|
+
async def parse_json(path: Path) -> Table:
|
|
81
|
+
return json.loads(path.read_text())
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**2. Draw the graph** in the editor, or write the YAML by hand:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
vgraph serve examples/flows --graphs examples/graphs
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```yaml
|
|
91
|
+
# examples/graphs/ingest.yaml
|
|
92
|
+
vgraph: 1
|
|
93
|
+
nodes:
|
|
94
|
+
read_input:
|
|
95
|
+
fn: flows.ingest:read_input
|
|
96
|
+
next: [by_format]
|
|
97
|
+
by_format:
|
|
98
|
+
fn: flows.ingest:by_format
|
|
99
|
+
next: {CSV: parse_csv, JSON: parse_json}
|
|
100
|
+
parse_csv: {fn: "flows.ingest:parse_csv", next: [merge]}
|
|
101
|
+
parse_json: {fn: "flows.ingest:parse_json", next: [merge]}
|
|
102
|
+
merge: {fn: "flows.ingest:merge"}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**3. Run it** with ▶ Run in the editor, or from Python:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from vgraph import load
|
|
109
|
+
|
|
110
|
+
graph = load("examples/graphs/ingest.yaml", functions="examples/flows")
|
|
111
|
+
result = graph.run(path="examples/data/sales.csv")
|
|
112
|
+
|
|
113
|
+
result.status # RunStatus.OK
|
|
114
|
+
result.outputs["merge"]["merge"] # outputs[node][name] of terminal nodes
|
|
115
|
+
result.executions["parse_csv"] # every execution of a node, in order
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Run the commands from the root of a checkout: the examples use relative paths.
|
|
119
|
+
|
|
120
|
+
## 🧩 Concepts at a glance
|
|
121
|
+
|
|
122
|
+
**Branch.** A `@branch` returns an `Enum` member; each member is an exit. Exits not
|
|
123
|
+
taken are skipped (dark grey).
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
class Fmt(Enum):
|
|
127
|
+
CSV = "csv"
|
|
128
|
+
JSON = "json"
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@branch
|
|
132
|
+
async def by_format(path: Path) -> Fmt:
|
|
133
|
+
return Fmt(path.suffix[1:])
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Join.** One rule for every node, no barrier node: a node waits until all its
|
|
137
|
+
predecessors have finished, and is skipped if all of them were skipped. `merge` waits
|
|
138
|
+
for both parsers; only one of them runs, so `merge` runs.
|
|
139
|
+
[Details](https://lorenzo-gardini.github.io/vgraph/concepts/joins/).
|
|
140
|
+
|
|
141
|
+
**Exceptions as values.** A node that raises turns red and its outputs become the
|
|
142
|
+
exception. A successor whose type accepts it handles it, and the run stays ok:
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
@node
|
|
146
|
+
async def merge(table: Table | CsvError) -> Report:
|
|
147
|
+
if isinstance(table, CsvError):
|
|
148
|
+
return Report(0, f"skipped: {table}")
|
|
149
|
+
return Report(len(table), f"{len(table)} rows")
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Loops.** Cycles are do-while shaped: the back edge leaves a branch exit. A value fed
|
|
153
|
+
back from later in the loop needs a default for the first pass:
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
@node
|
|
157
|
+
async def download(feedback: str = "") -> int: # "" on the first pass
|
|
158
|
+
return len(feedback) + 1
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
```yaml
|
|
162
|
+
check:
|
|
163
|
+
fn: flows.retry:check
|
|
164
|
+
next: {RETRY: download, DONE: publish}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## 🖼️ Screenshots
|
|
168
|
+
|
|
169
|
+
<table>
|
|
170
|
+
<tr>
|
|
171
|
+
<td width="50%"><img alt="The editor: function palette, graph canvas and live validation" src="https://raw.githubusercontent.com/Lorenzo-Gardini/vgraph/main/docs/assets/editor.png"></td>
|
|
172
|
+
<td width="50%"><img alt="The node panel of a failed node with its error, traceback, inputs and outputs" src="https://raw.githubusercontent.com/Lorenzo-Gardini/vgraph/main/docs/assets/node-panel.png"></td>
|
|
173
|
+
</tr>
|
|
174
|
+
<tr>
|
|
175
|
+
<td align="center">Editor: palette, canvas, live validation</td>
|
|
176
|
+
<td align="center">A failed node: error, traceback, inputs, outputs</td>
|
|
177
|
+
</tr>
|
|
178
|
+
<tr>
|
|
179
|
+
<td colspan="2"><img alt="A loop that ran three times: ×3 badges and the #1 to #3 execution picker" src="https://raw.githubusercontent.com/Lorenzo-Gardini/vgraph/main/docs/assets/loop.png"></td>
|
|
180
|
+
</tr>
|
|
181
|
+
<tr>
|
|
182
|
+
<td colspan="2" align="center">A loop: every pass is recorded, <code>#1…#3</code></td>
|
|
183
|
+
</tr>
|
|
184
|
+
</table>
|
|
185
|
+
|
|
186
|
+
## 📚 Documentation
|
|
187
|
+
|
|
188
|
+
The full documentation lives at
|
|
189
|
+
**[lorenzo-gardini.github.io/vgraph](https://lorenzo-gardini.github.io/vgraph/)**:
|
|
190
|
+
[getting started](https://lorenzo-gardini.github.io/vgraph/getting-started/),
|
|
191
|
+
[concepts](https://lorenzo-gardini.github.io/vgraph/concepts/nodes/),
|
|
192
|
+
[YAML format](https://lorenzo-gardini.github.io/vgraph/yaml-format/),
|
|
193
|
+
[UI](https://lorenzo-gardini.github.io/vgraph/ui/) and the
|
|
194
|
+
[API reference](https://lorenzo-gardini.github.io/vgraph/reference/).
|
|
195
|
+
|
|
196
|
+
## 🤝 Contributing
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
uv sync
|
|
200
|
+
uv run pytest
|
|
201
|
+
uv run ruff check && uv run ruff format --check
|
|
202
|
+
uv run pyright
|
|
203
|
+
cd ui && npm ci && npm test && npm run typecheck && npm run build
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Work on a branch, write tests first, open a PR, wait for green CI and rebase-merge.
|
|
207
|
+
Use conventional commits: release-please builds releases from them. See
|
|
208
|
+
[`AGENTS.md`](https://github.com/Lorenzo-Gardini/vgraph/blob/main/AGENTS.md) for the architecture and the invariants. To regenerate the
|
|
209
|
+
images above, run `uv run python scripts/record_demo.py`.
|
|
210
|
+
|
|
211
|
+
## 📄 License
|
|
212
|
+
|
|
213
|
+
[Apache-2.0](https://github.com/Lorenzo-Gardini/vgraph/blob/main/LICENSE)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
vgraph/__init__.py,sha256=J6ee8ndQndzpITZ7ZRBmxnL5xknEaFLKr9GUbqr98FQ,548
|
|
2
|
+
vgraph/api.py,sha256=Xv1YT_JB6r8WIqORAZRdcKVh1VgIYmShrzuBs_NSXAI,1650
|
|
3
|
+
vgraph/cli.py,sha256=NhoX2rRVl3Dlt1_UcE3xUeLmG7AAPZjRGfNvYBCOYbs,1277
|
|
4
|
+
vgraph/compile.py,sha256=UY6AKo_z4VP_27OQwAQ0sQTia0FKfwce8VNSI2GlCds,9811
|
|
5
|
+
vgraph/engine.py,sha256=XA3FY8OElju4_RFnsRd5p4tSCaxlNVbRVGXpvp67xNo,12440
|
|
6
|
+
vgraph/graph.schema.json,sha256=cPXKBB4vKf-g34Z6ZWr5iMIQWcbT12tyJ9GY3eTgq8s,1043
|
|
7
|
+
vgraph/inputs.py,sha256=ODXjO5kxcS6VqusRK4lkoAWMkppH1DnPYOT_8fFvSxU,2921
|
|
8
|
+
vgraph/model.py,sha256=SVTyEYzsW78o9qInLYEflMp8hLRroW3s540b-_qTN9c,1948
|
|
9
|
+
vgraph/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
vgraph/registry.py,sha256=-YBoCyVdRdOl2kzbysL9nO7qAQVayGyCPcMwxr8YmvA,5912
|
|
11
|
+
vgraph/server/__init__.py,sha256=vju0dMkNnCa6BI-ZNB8S2-JaWuUXTv9yKs1I646WM6Q,51
|
|
12
|
+
vgraph/server/app.py,sha256=y__bCDNrtv3-G5XM57xxkqcOKMRvjKvvW_GpPcRnnmk,9786
|
|
13
|
+
vgraph/server/state.py,sha256=hkn2uIXZC4TrLtS1oOCNTi-VK6GW5g8y8qgorTHGsGA,3426
|
|
14
|
+
vgraph/server/views.py,sha256=rCnstlM-5e0x9daZXpKltLJPzcSXG-zJNUYhuG7aV8s,2716
|
|
15
|
+
vgraph/server/watch.py,sha256=jbDmuO8jo9qCS2K8dA5lu8CzuAM-pGC4V0a9oQIjEbM,1588
|
|
16
|
+
vgraph/static/assets/index-BAxILRja.js,sha256=f5fnH5SgnGydpsJI_89pvKbCWgGBebc5f94cPQc4xKo,383455
|
|
17
|
+
vgraph/static/assets/index-CsCg66zj.css,sha256=hJQd5lNyu7QRfPOhppGbjBDNmnq9f5jF55C2oxVDVRs,28828
|
|
18
|
+
vgraph/static/index.html,sha256=2dFRofgAomKF_-6HN3Vx41odeDZHINHVHY_XHnhSYhA,429
|
|
19
|
+
vgraph/topology.py,sha256=h7nYWXK6MmT4dopwf_er4mKr0ufvKa2nZeO3vWEWplE,4475
|
|
20
|
+
vgraph/typing_utils.py,sha256=e-GOjdz3gAuE1EgAuNZ5QMDvXZwCcZilNB1z6Usj5mo,2801
|
|
21
|
+
vgraph-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
22
|
+
vgraph-0.1.0.dist-info/WHEEL,sha256=-gI5GRFdiNNn2CFz-ptlExISMINC-k8bFxeojAlHbrM,81
|
|
23
|
+
vgraph-0.1.0.dist-info/entry_points.txt,sha256=FtgbgmLlBfmaLquvDqkjneKgDqooGSgjQDDkzfRWN50,44
|
|
24
|
+
vgraph-0.1.0.dist-info/METADATA,sha256=Vlw5B1MuIwcLzRsh1BFdotU6nqJ81cV_NRpO5d2i6M8,7357
|
|
25
|
+
vgraph-0.1.0.dist-info/RECORD,,
|