aglinxinyuan opened a new issue, #8669:
URL: https://github.com/apache/texera/issues/8669
### Feature Summary
Inside a control block (`Loop Start ... Loop End`), any operator property
can hold a loop-variable reference such as `$i` (#8635, #8636). Operators whose
Scala descriptor generates Python code from their properties, such as the
sklearn trainers, cannot use it yet. Their code is generated when the workflow
is compiled, before the loop runs, so the compiler rejects a reference on them.
The trainers' hyperparameter values are the common case: the property panel
offers `$i` there, but the run fails at compile time.
```
Loop Start (i = 1) -> SVC trainer (C = "$i") -> Loop End
today: compile error, "its code is generated before the loop runs"
after: iteration i trains with C = i
```
### Proposed Solution or Design
A text property that the generated code decodes at run time is already read
inside the operator, after the iteration's state has arrived. Bind the
reference there, using the state that each Python operator registers before
`process_state` (`loop_state`, #8641):
| Step | Where | What |
|---|---|---|
| 1 | Code generation (Scala) | Inside a block, the decode expression of a
text reference, `self.decode_python_template('<"$i" encoded>')`, becomes a
lookup, `self.loop_variable_text('i')`. |
| 2 | Compiler | A generated operator is accepted when every reference it
holds was rewritten. A numeric or boolean reference, or a text reference that
the code embeds as plain text, is still a compile error that names the
property. |
| 3 | Python operator | `loop_variable_text(name)` returns the current value
of `name` in `loop_state` as text, and fails with a clear message when no state
message carried it. |
Outside every block nothing changes: a text such as `$AAPL` stays text.
Numeric and boolean properties of generated operators stay unsupported for now,
because their values are written into the code as literals.
Depends on #8639 and #8642.
### Affected Area
Workflow Engine (Amber)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]