feat(frontend): Support for UDF Ui Parameter#4268
feat(frontend): Support for UDF Ui Parameter#4268carloea2 wants to merge 23 commits intoapache:mainfrom
Conversation
…into feat/ui-parameter
…into feat/ui-parameter
|
@aglinxinyuan Please review it. |
There was a problem hiding this comment.
Pull request overview
This PR adds UDF UI Parameter support, allowing users to declare typed parameters in their Python UDF open() method via self.UiParameter(name=..., type=AttributeType....). The frontend parses these from the code, displays them as an editable properties panel, and the backend injects the UI-supplied values into the Python code before execution.
Changes:
- Frontend: New
UiUdfParametersParserServiceandUiUdfParametersSyncServicethat parseself.UiParameter(...)calls from Python code and sync parsed parameters to the operator property store; newUiUdfParametersComponentrenders the parameters table in the property panel. - Backend (Scala): New
UiUDFParametermodel andPythonUdfUiParameterInjectorthat injects a_texera_injected_ui_parametershook method into the UDF class with the UI-supplied values encoded via thepybuildermechanism; all three Python UDF operator descriptors updated to run the injector. - Backend (Python): New
_UiParameterSupportmixin class added to all UDF base classes; it wrapsopen()via__init_subclass__to apply injected values before user code runs.
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
workflow-compiling.interface.ts |
Adds large_binary to AttributeType, JAVA/Python attribute type name constants, and derived union types for cross-language type token handling |
ui-udf-parameters-parser.service.ts |
New service that parses self.UiParameter(...) calls from Python code and normalizes type tokens to canonical schema names |
ui-udf-parameters-parser.service.spec.ts |
Tests for the parser service; contains incorrect expected type values |
ui-udf-parameters-sync.service.ts |
New service that attaches to YText changes and syncs parsed parameter structure to operator properties |
ui-udf-parameters.component.* |
New Angular Formly custom type component rendering the parameters table with read-only name/type and editable value columns |
operator-property-edit-frame.component.ts/.scss |
Subscribes to param changes and maps the uiParameters field key to the custom Formly type; adds styling |
code-editor.component.ts |
Attaches/detaches the YText listener when the Monaco editor is initialized/destroyed |
formly-config.ts / app.module.ts |
Registers the new ui-udf-parameters Formly type and declares the component |
PythonUdfUiParameterInjector.scala |
New Scala object that injects the _texera_injected_ui_parameters hook method into UDF classes |
PythonUdfUiParameterInjectorSpec.scala |
Tests for the Scala injector; contains failing test assertions |
UiUDFParameter.scala |
New Scala model class for a UI parameter (attribute + string value) |
PythonUDFOpDescV2.scala / DualInputPortsPythonUDFOpDescV2.scala / PythonUDFSourceOpDescV2.scala |
Adds uiParameters field and wires the injector call |
Attribute.java |
Adds @EncodableStringAnnotation to getName() for safe encoding in pybuilder templates; introduces unused imports |
udf_operator.py |
Adds _UiParameterSupport mixin with UiParameter inner class and wrapping mechanism |
attribute_type.py |
Adds FROM_STRING_PARSER_MAPPING for string-to-type conversion |
pytexera/__init__.py / pyamber/__init__.py |
Exports AttributeType |
collab-wrapper.component.css |
Minor whitespace change to an already-invalid CSS property |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
frontend/src/app/workspace/service/code-editor/ui-udf-parameters-parser.service.spec.ts
Show resolved
Hide resolved
frontend/src/app/workspace/component/ui-udf-parameters/ui-udf-parameters.component.html
Show resolved
Hide resolved
frontend/src/app/workspace/service/code-editor/ui-udf-parameters-parser.service.spec.ts
Outdated
Show resolved
Hide resolved
frontend/src/app/workspace/component/code-editor-dialog/code-editor.component.ts
Outdated
Show resolved
Hide resolved
frontend/src/app/workspace/service/code-editor/ui-udf-parameters-sync.service.ts
Outdated
Show resolved
Hide resolved
...rc/main/scala/org/apache/texera/amber/operator/udf/python/PythonUdfUiParameterInjector.scala
Outdated
Show resolved
Hide resolved
common/workflow-core/src/main/scala/org/apache/texera/amber/core/tuple/Attribute.java
Show resolved
Hide resolved
aglinxinyuan
left a comment
There was a problem hiding this comment.
Please fix the test cases, as the frontend currently fails to compile. Also address the comments left by Copilot. The PR still feels quite draft-like, so please take some time to polish it before requesting for review.
What changes were proposed in this PR?
Add Python UDF Parameter support:

What the user writes (Python)
Users declare UI parameters once in
open(), and then use the typed value directly:What shows up in the UI
From those
self.UiParameter(...)lines, the property panel automatically generates a Parameters section with one row per parameter:How the values get into Python
When the workflow runs, we inject the UI values into the UDF and the base class applies them right before
open()executes. That way, when the user callsUiParameter(...).value, they get the current value from the UI.Any related issues, documentation, discussions?
Closes #4154
How was this PR tested?
Testing added to backend and frontend
Was this PR authored or co-authored using generative AI tooling?
Co-generated with GPT