py2dag 0.3.8__tar.gz → 0.3.10__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: py2dag
3
- Version: 0.3.8
3
+ Version: 0.3.10
4
4
  Summary: Convert Python function plans to DAG (JSON, pseudo, optional SVG).
5
5
  License: MIT
6
6
  Author: rvergis
@@ -18,7 +18,16 @@ Requires-Dist: graphviz (>=0.20.3,<0.21.0) ; extra == "svg"
18
18
  Description-Content-Type: text/markdown
19
19
 
20
20
  # py2dag
21
- Convert Python function plans to a DAG (JSON, pseudo, optional SVG).
21
+ Convert Python function plans to a DAG (JSON, pseudo, optional HTML/SVG).
22
+
23
+ ## Features
24
+
25
+ - Writes `plan.json` with explicit `nodes` and `edges` for downstream tools.
26
+ - Generates human-readable pseudo code at `plan.pseudo`.
27
+ - Optional exports:
28
+ - `--html` for an interactive Dagre graph with color-coded nodes.
29
+ - `--svg` for a Graphviz-rendered SVG.
30
+ - Node colors are chosen deterministically so the same op type is colored consistently across runs.
22
31
 
23
32
  ## Install
24
33
 
@@ -64,17 +73,17 @@ make run FILE=path/to/your_file.py ARGS=--html
64
73
  - Run the installed CLI (after `pip install py2dag`):
65
74
 
66
75
  ```
67
- py2dag path/to/your_file.py --html
76
+ py2dag path/to/your_file.py --html # interactive HTML
77
+ py2dag path/to/your_file.py --svg # Graphviz SVG
68
78
  ```
69
79
 
70
-
71
80
  - Or directly with Python (inside venv):
72
81
 
73
82
  ```
74
83
  poetry run python cli.py path/to/your_file.py --html
75
84
  ```
76
85
 
77
- This generates `plan.json`, `plan.pseudo`, and if `--html` is used, `plan.html`.
86
+ This generates `plan.json`, `plan.pseudo`, and if `--html`/`--svg` is used, `plan.html` or `plan.svg`.
78
87
 
79
88
  - Function name: By default the tool auto-detects a suitable function in the file. To target a specific function, pass `--func NAME`.
80
89
 
@@ -1,5 +1,14 @@
1
1
  # py2dag
2
- Convert Python function plans to a DAG (JSON, pseudo, optional SVG).
2
+ Convert Python function plans to a DAG (JSON, pseudo, optional HTML/SVG).
3
+
4
+ ## Features
5
+
6
+ - Writes `plan.json` with explicit `nodes` and `edges` for downstream tools.
7
+ - Generates human-readable pseudo code at `plan.pseudo`.
8
+ - Optional exports:
9
+ - `--html` for an interactive Dagre graph with color-coded nodes.
10
+ - `--svg` for a Graphviz-rendered SVG.
11
+ - Node colors are chosen deterministically so the same op type is colored consistently across runs.
3
12
 
4
13
  ## Install
5
14
 
@@ -45,17 +54,17 @@ make run FILE=path/to/your_file.py ARGS=--html
45
54
  - Run the installed CLI (after `pip install py2dag`):
46
55
 
47
56
  ```
48
- py2dag path/to/your_file.py --html
57
+ py2dag path/to/your_file.py --html # interactive HTML
58
+ py2dag path/to/your_file.py --svg # Graphviz SVG
49
59
  ```
50
60
 
51
-
52
61
  - Or directly with Python (inside venv):
53
62
 
54
63
  ```
55
64
  poetry run python cli.py path/to/your_file.py --html
56
65
  ```
57
66
 
58
- This generates `plan.json`, `plan.pseudo`, and if `--html` is used, `plan.html`.
67
+ This generates `plan.json`, `plan.pseudo`, and if `--html`/`--svg` is used, `plan.html` or `plan.svg`.
59
68
 
60
69
  - Function name: By default the tool auto-detects a suitable function in the file. To target a specific function, pass `--func NAME`.
61
70
 
@@ -509,15 +509,19 @@ def parse(source: str, function_name: Optional[str] = None) -> Dict[str, Any]:
509
509
  })
510
510
  returned_var = const_id
511
511
  elif isinstance(stmt.value, (ast.Constant, ast.List, ast.Tuple, ast.Dict)):
512
- lit = _literal(stmt.value)
513
- const_id = _ssa_new("return_value")
514
- ops.append({
515
- "id": const_id,
516
- "op": "CONST.value",
517
- "deps": [],
518
- "args": {"value": lit},
519
- })
520
- returned_var = const_id
512
+ try:
513
+ lit = _literal(stmt.value)
514
+ except DSLParseError:
515
+ returned_var = _emit_assign_from_literal_or_pack("return_value", stmt.value)
516
+ else:
517
+ const_id = _ssa_new("return_value")
518
+ ops.append({
519
+ "id": const_id,
520
+ "op": "CONST.value",
521
+ "deps": [],
522
+ "args": {"value": lit},
523
+ })
524
+ returned_var = const_id
521
525
  else:
522
526
  raise DSLParseError("return must return a variable name or literal")
523
527
  return None
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "py2dag"
7
- version = "0.3.8"
7
+ version = "0.3.10"
8
8
  description = "Convert Python function plans to DAG (JSON, pseudo, optional SVG)."
9
9
  authors = ["rvergis"]
10
10
  license = "MIT"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes