py2dag 0.1.5__tar.gz → 0.1.7__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.
- {py2dag-0.1.5 → py2dag-0.1.7}/PKG-INFO +1 -1
- {py2dag-0.1.5 → py2dag-0.1.7}/py2dag/parser.py +26 -7
- {py2dag-0.1.5 → py2dag-0.1.7}/pyproject.toml +1 -1
- {py2dag-0.1.5 → py2dag-0.1.7}/LICENSE +0 -0
- {py2dag-0.1.5 → py2dag-0.1.7}/README.md +0 -0
- {py2dag-0.1.5 → py2dag-0.1.7}/py2dag/__init__.py +0 -0
- {py2dag-0.1.5 → py2dag-0.1.7}/py2dag/cli.py +0 -0
- {py2dag-0.1.5 → py2dag-0.1.7}/py2dag/export_dagre.py +0 -0
- {py2dag-0.1.5 → py2dag-0.1.7}/py2dag/export_svg.py +0 -0
- {py2dag-0.1.5 → py2dag-0.1.7}/py2dag/pseudo.py +0 -0
@@ -139,12 +139,29 @@ def parse(source: str, function_name: Optional[str] = None) -> Dict[str, Any]:
|
|
139
139
|
elif isinstance(stmt, ast.Return):
|
140
140
|
if i != len(fn.body) - 1: # type: ignore[index]
|
141
141
|
raise DSLParseError("return must be the last statement")
|
142
|
-
if
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
142
|
+
if isinstance(stmt.value, ast.Name):
|
143
|
+
var = stmt.value.id
|
144
|
+
if var not in defined:
|
145
|
+
raise DSLParseError(f"Undefined return variable: {var}")
|
146
|
+
returned_var = var
|
147
|
+
elif isinstance(stmt.value, ast.Constant):
|
148
|
+
# Support returning a literal (e.g., "DONE"): synthesize a const op
|
149
|
+
lit = stmt.value.value
|
150
|
+
const_id_base = "return_value"
|
151
|
+
const_id = const_id_base
|
152
|
+
n = 1
|
153
|
+
while const_id in defined:
|
154
|
+
const_id = f"{const_id_base}_{n}"
|
155
|
+
n += 1
|
156
|
+
ops.append({
|
157
|
+
"id": const_id,
|
158
|
+
"op": "CONST.value",
|
159
|
+
"deps": [],
|
160
|
+
"args": {"value": lit},
|
161
|
+
})
|
162
|
+
returned_var = const_id
|
163
|
+
else:
|
164
|
+
raise DSLParseError("return must return a variable name or literal")
|
148
165
|
else:
|
149
166
|
raise DSLParseError("Only assignments, expression calls, and a final return are allowed in function body")
|
150
167
|
|
@@ -156,7 +173,9 @@ def parse(source: str, function_name: Optional[str] = None) -> Dict[str, Any]:
|
|
156
173
|
if len(ops) > 200:
|
157
174
|
raise DSLParseError("Too many operations")
|
158
175
|
|
159
|
-
|
176
|
+
# Include the parsed function name for visibility/debugging
|
177
|
+
fn_name = getattr(fn, "name", None) # type: ignore[attr-defined]
|
178
|
+
plan: Dict[str, Any] = {"version": 1, "function": fn_name, "ops": ops, "outputs": outputs}
|
160
179
|
if settings:
|
161
180
|
plan["settings"] = settings
|
162
181
|
return plan
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|