Repository navigation
feat(frontend): add UDF parameters from the panel - #7551
Conversation
…anel Adding a parameter in the Python UDF properties panel now writes the self.UiParameter(...) declaration into the code, creating open() when the UDF class does not define one. The code stays the single source of truth: the add action only edits the shared Y.Text code buffer and the row appears through the existing parse/merge sync loop.
…r declarations A template whose statements are still commented out parses as a class body holding only comments and a lezer error node. The error node was treated as an anchor statement, so the synthesized open() landed at module level at the end of the file. Filter error nodes out and, when a class or open() body has no real statements yet, insert right after the header line with one extra indent level.
…t rule All placement cases (docstrings, decorators, pass-only, commented-out, and empty bodies) collapse into a single rule shared by class and open(): insert before the first real statement, or right after the header line when the body has none yet. parse() and the insertion share the class discovery and call traversal, and the add form becomes a single always-visible row with the name validation living only in the parser.
…d tables Each placement case is now a single annotated file where '>' marks the inserted lines, so input and expected output are derived from one copy; every case re-parses its result, absorbing the separate round-trip tests. The redundant undecorated-open case and duplicated fixtures are gone.
The standalone name/type/Add strip read as another parameter row. It is now a dashed 'Add parameter' button under the list that opens a draft row in the same three-column grid, confirmed with a check button or Enter and dismissed with close or Escape.
Automated Reviewer SuggestionsBased on the
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7551 +/- ##
============================================
- Coverage 88.63% 87.06% -1.58%
+ Complexity 4346 4226 -120
============================================
Files 1177 1173 -4
Lines 46896 46782 -114
Branches 5230 5235 +5
============================================
- Hits 41568 40731 -837
- Misses 3568 4332 +764
+ Partials 1760 1719 -41
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@aicam can you review it? |
|
/request-review @aicam |
aicam
left a comment
There was a problem hiding this comment.
Adding a parameter can emit Python that doesn't compile. If the UDF already
declares a UiParameter inside a compound statement's header — e.g.
if self.UiParameter(name="debug", type=AttributeType.BOOL).value: — and the
next statement is a for/while/if block, the new declaration is inserted
between that header and its body.
|
Thanks for catching this. I changed the insertion logic so new parameters are added at the top of I also added a regression test for the exact |
…9644) ### What changes were proposed in this PR? Remove unused and inert SCSS rules, an empty component stylesheet, unread callback and lifecycle parameters, and a duplicate module import across the Angular frontend (**+13/-134 lines**). There is no observable UI or runtime behavior change. - **Detail-page SCSS selectors:** Remove unmatched `.file-title`, `.file-size`, `.versions-tab-content`, `nz-layout`, `html, body`, `.grayed-out`, `.disabled-click`, and `.ant-collapse-content-box` rules from `DatasetDetailComponent` SCSS, and unmatched `.versions-tab-content` and `nz-layout` rules from `ModelDetailComponent` SCSS. Both components use Angular's default `ViewEncapsulation.Emulated`, `apache#8942` moved the version browser markup and styles to `VersionsFilesBrowserComponent`, and zero matching elements remain in either component template. - **Unused and inert cross-component SCSS rules:** Remove unmatched `#googleButton`, `.hidden` (dashboard and hub templates use HTML `hidden` / `[hidden]` / `aria-hidden` attributes rather than a CSS class), unused Sass variable `$dashboard-navigation-height`, `.uploaded-files-list`, empty `.file-uploader-banner {}`, `.dataset-menu-bar`, `.condition-input-popup.fade-out`, and `.ai-fix-field` (zero template or TypeScript references in `frontend/src`), along with the `opacity: 1` and `transition: opacity 1s ease-in-out` declarations on `.condition-input-popup` that only existed to animate `.fade-out`. Remove emulated `.ant-table-thead > tr > th` and `.ant-table` rules in `WorkflowExecutionHistoryComponent` SCSS (default `ViewEncapsulation.Emulated` scopes them to host attributes that cannot match `nz-table` internal DOM without `::ng-deep`), remove obsolete `.ant-collapse-content-box` overrides in global `styles.scss` (`ng-zorro-antd` 21 emits `.ant-collapse-body` with zero `.ant-collapse-content-box` occurrences), and delete the empty license-only `hub.component.scss` along with its `styleUrls` entry in `HubComponent`. - **Unread subscriber callback parameters:** Drop six unread `(res: Response)` and `(err: unknown)` parameters in `DatasetDetailComponent` (`onPublicStatusChange`, `onDownloadableStatusChange`, and `onPreviouslyUploadedFileDeleted`) that were never read in their callback bodies. - **Unread lifecycle parameter and import:** Drop the unread `changes: SimpleChanges` parameter and orphaned `SimpleChanges` import in `BrowseSectionComponent.ngOnChanges`, along with two placeholder `{} as any` arguments in `browse-section.component.spec.ts`. - **Duplicate module import:** Merge the duplicate `import` from `ui-udf-parameters-parser.service` in `UiUdfParametersComponent` into the existing import block from the same module. | Event | PR / Commit | | --- | --- | | Introduced by | Detail SCSS: apache#2413 (2024-02-26), apache#2927 (2024-10-14), apache#4928 (2026-05-04), apache#7043 (2026-07-30), apache#6953 (2026-08-03), apache#8072 (2026-08-28); other SCSS and empty `hub.component.scss`: apache#1634 (2022-10-04), apache#2413 (2024-02-26), apache#2435 (2024-03-17), apache#2502 (2024-03-27), apache#2571 (2024-04-05), apache#2737 (2024-07-15), apache#2776 (2024-08-19), apache#2878 (2024-09-27), apache#2953 (2024-10-25), apache#3415 (2025-05-03), apache#4484 (2026-05-01), apache#8637 (2026-10-28); unread parameters and duplicate import: apache#2515 (2024-03-27), apache#3296 (2025-03-10), apache#3363 (2025-04-10), apache#3663 (2025-08-16), apache#6897 (2026-09-21, duplicating apache#7551 from 2026-08-13) | | Usage removed by | Detail version styles: apache#8942 (2026-10-10, `refactor(frontend): extract shared VersionsFilesBrowser component`); `.ant-collapse-content-box`: apache#5895 (2026-06-22, `chore: upgrade ng-zorro-antd to 21.3.1`); remaining selectors, empty `hub.component.scss`, unread parameters, and duplicate import: unused or inert since introduction or prior UI refactors | As of 2026-11-23, the `.ai-fix-field` rule has been unused for about 4 weeks, the orphaned detail-page version styles for 6 weeks, the duplicate import for 2 months, the obsolete `.ant-collapse-content-box` rules for 5 months, and the remaining rules and unread parameters for 15 to 49 months. ### Any related issues, documentation, discussions? Closes apache#9643. ### How was this PR tested? Ran in `frontend/` on `ff6361f2ea` (Node 24, `node .yarn/releases/yarn-4.14.1.cjs install --immutable --inline-builds`): ```bash node .yarn/releases/yarn-4.14.1.cjs format:ci node .yarn/releases/yarn-4.14.1.cjs exec tsc -p src/tsconfig.app.json --noEmit node .yarn/releases/yarn-4.14.1.cjs exec tsc -p src/tsconfig.spec.json --noEmit node .yarn/releases/yarn-4.14.1.cjs build node .yarn/releases/yarn-4.14.1.cjs test ``` - `format:ci` (`prettier-eslint --list-different` and `eslint ./src`): passed. - `tsc --noEmit` (`src/tsconfig.app.json` and `src/tsconfig.spec.json`): passed. - `build` (production Angular AOT build): passed. - `test` (Vitest, JUnit XML): `255` suites passed (`7,385` passed, `0` failed, `0` errors, `1` pre-existing skipped in untouched `operator-property-edit-frame.component.spec.ts`). Review follow-up `aacada02e9` only removes the two inert declarations on `.condition-input-popup`; it was checked locally with `prettier --check` (3.2.5) and a `sass` (1.71.1) compile of the changed stylesheet, and CI runs the full build and tests on the new head. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Antigravity (Gemini 4 Neon) Generated-by: Claude Code (Opus 5.5), review follow-up `aacada02e9` --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
What changes were proposed in this PR?
This PR lets users add Python UDF parameters directly from the properties panel.
The parameter list now includes a dashed Add parameter button. Clicking it opens an inline draft row where the user can enter a name, select a supported type, and confirm with the check button or Enter, or cancel with the close button or Escape.
Confirming the draft inserts a
self.UiParameter(...)declaration into the operator's shared Python code. The code remains the single source of truth: the parameter row appears through the existing parse-and-sync flow instead of being written directly into the form model.The insertion logic:
UiParameterdeclarations;open()method when available;open()when it is absent;pass, comments, and empty class bodies;Any related issues, documentation, discussions?
Closes #7552
How was this PR tested?
Manual verification by the author covered the add, confirm/cancel, declaration insertion, and properties-panel synchronization flows.
Frontend CI formatting and lint:
cd frontend yarn format:ciThe command passes.
The updated specifications cover component actions and error states, shared-code insertion and synchronization, declaration placement, identifier sanitization, duplicate names, unsupported types, unsupported classes, and malformed class bodies.
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code Fable 5 Ultra, OpenAI Codex 5.6 Ultra, and Me