carloea2 commented on PR #4268:
URL: https://github.com/apache/texera/pull/4268#issuecomment-4272882772

   @kunwp1 are these diagrams ok?:
   
   Overall:
   ```mermaid
   sequenceDiagram
       autonumber
   
       participant FE as Frontend UI
       participant Parser as Parser Service
       participant Store as Operator Properties
       participant BE as Scala Backend
       participant Inj as Python Code Injector
       participant Py as Python Runtime
       participant UDF as User UDF
   
       FE->>Parser: Send Python code
       Parser->>Parser: Extract self.UiParameter declarations
       Parser-->>FE: Return parameter schema
   
       FE->>Store: Save uiParameters<br/>name, type, value
       Store->>BE: Submit operator descriptor
   
       BE->>Inj: Pass original code + uiParameters
       Inj->>Inj: Validate names and types
       Inj->>Inj: Generate injected hook
       Inj-->>BE: Return modified Python code
   
       BE->>Py: Execute injected code
       Py->>UDF: Load UDF class
       UDF->>Py: open() is wrapped
   
       Py->>UDF: Call injected hook
       UDF-->>Py: Return parameter values
   
       Py->>UDF: Provide typed UiParameter values
       UDF->>Py: Execute workflow logic
   ```
   Detailed:
   ```mermaid
   sequenceDiagram
       autonumber
   
       actor User
   
       participant CodeEditor as CodeEditorComponent<br/>Monaco editor
       participant YCode as Yjs shared code
       participant Sync as UiUdfParametersSyncService
       participant Parser as UiUdfParametersParserService
       participant ParamUI as UiUdfParametersComponent
       participant Formly as Formly / Operator Properties
       participant OpDesc as Python UDF Operator Descriptor<br/>Scala backend
       participant Injector as PythonUdfUiParameterInjector
       participant Runtime as Python Runtime
       participant Support as _UiParameterSupport
       participant UDF as User UDF Class
   
       User->>CodeEditor: Writes Python UDF code
       CodeEditor->>YCode: Updates shared code text
       YCode->>Sync: Emits code-change event
   
       Sync->>Parser: Parse latest Python code
       Parser->>Parser: Find supported UDF class
       Parser->>Parser: Scan self.UiParameter(...)
       Parser-->>Sync: Return inferred parameters<br/>name + AttributeType
   
       Sync->>Formly: Update operator uiParameters structure
       Formly->>ParamUI: Render parameter rows
       ParamUI-->>User: Shows inferred params<br/>name/type locked, value 
editable
   
       User->>ParamUI: Enters parameter values
       ParamUI->>Formly: Store edited values
       Formly->>OpDesc: Persist uiParameters in operator properties
   
       User->>OpDesc: Runs workflow
   
       OpDesc->>Injector: inject(code, uiParameters)
       Injector->>Injector: Validate uiParameters
       Injector->>Injector: Build parameter map
       Injector->>Injector: Generate reserved hook method
       Injector->>Injector: Insert hook into user UDF class
       Injector-->>OpDesc: Return injected Python code
   
       OpDesc->>Runtime: Execute OpExecWithCode(injectedCode, "python")
       Runtime->>UDF: Load user UDF class
       UDF->>Support: __init_subclass__ wraps open()
   
       Runtime->>UDF: Start operator execution
       UDF->>Support: wrapped open() runs first
       Support->>UDF: Call _texera_injected_ui_parameters()
       UDF-->>Support: Return UI parameter values
       Support->>Support: Store injected values
   
       Support->>UDF: Continue original user open()
       UDF->>Support: Create/read self.UiParameter(...)
       Support->>Support: Look up injected value by name
       Support->>Support: Convert value using AttributeType
       Support-->>UDF: Return typed Python value
   
       UDF->>Runtime: Process tuples / batches / source output
   ```


-- 
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