carloea2 opened a new pull request, #4268:
URL: https://github.com/apache/texera/pull/4268
<!--
Thanks for sending a pull request (PR)! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
[Contributing to
Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md)
2. Ensure you have added or run the appropriate tests for your PR
3. If the PR is work in progress, mark it a draft on GitHub.
4. Please write your PR title to summarize what this PR proposes, we
are following Conventional Commits style for PR titles as well.
5. Be sure to keep the PR description updated to reflect all changes.
-->
### What changes were proposed in this PR?
Add Python UDF Parameter support:
<img width="1594" height="601" alt="image"
src="https://github.com/user-attachments/assets/771f2c85-1442-4c9a-98cf-f5c41e8d2707"
/>
### What the user writes (Python)
Users declare UI parameters once in `open()`, and then use the typed value
directly:
```python
from pytexera import *
from typing import Iterator, Optional
class ProcessTupleOperator(UDFOperatorV2):
@overrides
def open(self):
# declare UiParameters once, store the parsed runtime values
self.value1 = self.UiParameter(name="param1",
type=AttributeType.DOUBLE).value
self.value2 = self.UiParameter(name="param2",
type=AttributeType.INT).value
self.value3 = self.UiParameter(name="param3",
type=AttributeType.STRING).value
self.value4 = self.UiParameter(name="param4",
type=AttributeType.TIMESTAMP).value
@overrides
def process_tuple(self, tuple_: Tuple, port: int) ->
Iterator[Optional[TupleLike]]:
print(self.value1)
print(self.value2)
print(self.value3)
print(self.value4)
yield tuple_
```
### What shows up in the UI
From those `self.UiParameter(...)` lines, the property panel automatically
generates a **Parameters** section with one row per parameter:
* **Name** + **Type** are read-only (so they stay consistent with the code)
* **Value** is editable (so users can change runtime values without touching
the script)
### 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
calls `UiParameter(...).value`, they get the current value from the UI.
### Any related issues, documentation, discussions?
Closes [#4154
](https://github.com/apache/texera/discussions/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
--
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]