yangzhang75 opened a new issue, #9642:
URL: https://github.com/apache/texera/issues/9642

   ### Feature Summary
   
   A Python UDF declares its parameters in its code (`self.UiParameter(name, 
type)`), and whoever runs the workflow fills them in from the property panel, 
or on the Form View from the form. Today every parameter is a free-text box, 
whatever the value means, except one that names a dataset or a model, which 
opens a picker that stops at the version.
   
   Two problems follow:
   
   1. **A file has to be spelled out by hand.** A dataset is a versioned 
container holding a file tree. The picker stops at the version, so the person 
running the workflow types the rest of the path exactly right, although Texera 
lists every file a click away elsewhere. And what the UDF receives is a mounted 
folder path, which only exists on a Kubernetes computing unit: a workflow 
written this way fails on a local one.
   2. **Nothing says what a box accepts.** A parameter that takes one of three 
methods looks like a parameter that takes any text; a wrong value surfaces when 
the UDF runs, if at all. The author can only say what is expected in words (the 
input's help text, the form's instructions).
   
   The feature: a parameter says what it accepts in the same call that already 
gives it a name and a type. One that lists its values gets a dropdown; one that 
names a dataset gets the browser Texera already has, down to a file; one that 
says nothing is unchanged. Discussed in #9338 (general support from @mengw15; 
the three small main bugs found while building it are separate: #9501 / #9526, 
#9502 / #9527, #9500).
   
   ### Proposed Solution or Design
   
   ### 1. A parameter can list its values
   
   ```python
   # today
   self.method = self.UiParameter("method", AttributeType.STRING).value
   # proposed
   self.method = self.UiParameter("method", AttributeType.STRING, 
choices=["soupx", "decontx"]).value
   ```
   
   It renders as a dropdown of those values, on the panel and on the form. A 
value already filled in survives a change to the list, unless the new list no 
longer offers it. `choices` takes a literal list only.
   
   ### 2. A parameter that names a dataset can be picked down to a file
   
   ```python
   self.input_file = self.UiParameter("input_file", AttributeType.STRING, 
value=Resource.DATASET).value
   ```
   
   `value=Resource.DATASET` already exists on `main` (#6897); it keeps being 
the one way to point a parameter at a dataset (the `Resource.DATASET_FILE` 
spelling floated in the discussion is folded into it). What changes:
   
   - **The picker reaches a file.** The dataset browser opens in file mode with 
the version still selectable, so the person filling the form picks the version 
and then the file, or stops at the version for a UDF that reads several files 
out of it. The picked row is highlighted (#9526) and the browser is confirmed 
only once something is picked.
   - **What the UDF receives can be read on any deployment.** The parameter's 
value is the dataset's own path (`/<owner>/<dataset>/<version>/<file>`), not a 
mounted folder; pytexera reads it through the dataset API, which every 
deployment has, so the same workflow runs on a local computing unit and on 
Kubernetes. A dataset parameter no longer asks for a mount, so a UDF with only 
dataset parameters needs no execution binding at all. `value=Resource.MODEL` is 
unchanged (version only, mounted, as today).
   
   ### 3. The declaration comes from the code
   
   The frontend already reads each parameter's name and type out of the UDF 
source; what it accepts comes from the same place, re-read whenever the 
workflow is opened, so it stays in step with the code and a workflow built by a 
script or imported from a file shows its controls too. The copy stored with the 
workflow (`uiParameters`) is a cache.
   
   The declaration drives the UI only: the backend does not reject a value 
outside the declared set, since the stored set can be older than the code, and 
rejecting a value would tell an author their own code is wrong.
   
   ### Affected Area
   
   Workflow UI, 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]

Reply via email to