Skip to content

feat(notebook-migration): add r prompts and build rudf operators for r sources - #8911

Merged
mengw15 merged 7 commits into
apache:mainfrom
zyratlo:migration-tool-r-prompts
Nov 9, 2026
Merged

mengw15 merged 7 commits into
apache:mainfrom
zyratlo:migration-tool-r-prompts

Conversation

@zyratlo

@zyratlo zyratlo commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

This is the second of the PRs adding R support to the migration tool (#8009), building on the prompt sets from #8910. It adds the R side of the conversion. Nothing is user visible yet: the import modal options arrive in #8912 and #8963, and the new flag defaults to off.

Flag. gui.workflow-workspace.r-notebook-migration-enabled, default false, overridable with GUI_WORKFLOW_WORKSPACE_R_NOTEBOOK_MIGRATION_ENABLED and exposed to the frontend as rNotebookMigrationEnabled. R UDFs only run where the computing unit has the texera-rudf plugin installed (#4155), and no Texera image ships it, so R stays off unless a deployment opts in. It sits under the existing migration flag rather than replacing it.

R prompts. A new migration-prompts-r.ts holds an R version of each prompt, notebook and script, with the same JSON reply contract so parsing does not change. The design follows a spike against texera-rudf that ran chained R UDFs in a real workflow:

  • Every UDF uses the Table API: one function(table, port) that takes and returns a data.frame. RUDF needs useTupleAPI set explicitly, and teaching one API keeps generated code and the flag consistent.
  • Python passes objects between UDFs pickled in binary columns. R has no pickle, so a UDF whose output another UDF reads returns one row of I(list(serialize(x, NULL))) columns, and the reader calls unserialize(table$x[[1]]). The spike passed data.frames and fitted lm models this way between real workers.
  • A UDF no other UDF reads returns character columns. Texera's schema check rejects a number in a column buildWorkflow declares as string, and does not cast it.
  • Plots are converted with ggplotly() into a page that loads Plotly from a CDN, returned as html-content. htmlwidgets::saveWidget is ruled out because it needs pandoc.
  • Each UDF reads from at most one other UDF. Results a later step needs are carried along one chain instead of merged from branches, which avoids R UDFs having to union tables.

The worked examples are the diabetes pipeline in R. Their line numbers, mapping ranges and JSON escaping were generated rather than typed, and all six example UDFs were run through texera-rudf on diabetes.csv, chained the way buildWorkflow wires them. Unlike the Python examples, they are valid JSON.

Wiring. MigrationLanguage widens to "python" | "r". The R prompt set builds RUDF operators with useTupleAPI: false through a new properties overlay (empty for Python, so Python operators are unchanged) and derives notebooks with the ir kernelspec. A promptsFor guard refuses an R conversion while the R flag is off, before any model call. NotebookMigrationService passes the language through.

Any related issues, documentation, discussions?

Part of #8009
Parent-issue #4301

The plan is in #8866. The import modal options follow in #8912 (R notebooks) and #8963 (R files), which are stacked on this PR.

How was this PR tested?

  • migration-llm.spec.ts, six new tests: the exact R prelude and prompts for notebooks and scripts, the full RUDF property set with binary and string outputs, the ir kernelspec on a derived notebook, the R flag blocking R without a model call, and Python still converting with the R flag off. The Python prompt tests from refactor(notebook-migration): select prompts and operator type by source language #8910 pass unchanged.
  • migration-prompts-r.spec.ts, new, ten tests guarding the worked examples: both example blocks parse as JSON, edges only reference defined UDFs, every UDF is a numbered Table API function, only UDFs another UDF reads call serialize, no UDF has two inputs, and the mapping cells and line ranges point at real, non blank lines.
  • notebook-migration.service.spec.ts, two new tests that the language reaches both conversions.
  • GuiConfigSpec checks the flag defaults to false.

Coverage of migration-llm.ts and notebook-migration.service.ts stays at 100% of lines. The full frontend suite passes.

End to end with a live model, through the modal from #8912 and #8963: an R script and an R notebook each converted to a workflow of Table API RUDF operators. Run on the source dataset, the script's workflow reported the same model accuracies as running the original script in Rscript, and its plot rendered through an HTML Visualizer.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)

@zyratlo
zyratlo marked this pull request as draft October 7, 2026 18:51
@github-actions github-actions Bot added frontend Changes related to the frontend GUI common platform Non-amber Scala service paths labels Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @pedroreyesalvarado, @yangzhang75
    You can notify them by mentioning @pedroreyesalvarado, @yangzhang75 in a comment.

@codecov-commenter

codecov-commenter commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.80%. Comparing base (7b1033b) to head (178f671).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8911   +/-   ##
=========================================
  Coverage     91.79%   91.80%           
  Complexity     5020     5020           
=========================================
  Files          1274     1275    +1     
  Lines         56298    56324   +26     
  Branches       7352     7357    +5     
=========================================
+ Hits          51677    51706   +29     
+ Misses         2766     2764    -2     
+ Partials       1855     1854    -1     
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø)
agent-service 99.53% <ø> (ø) Carriedforward from 03290bc
amber 85.76% <100.00%> (+<0.01%) ⬆️
computing-unit-managing-service 64.05% <ø> (ø)
config-service 87.73% <100.00%> (+0.11%) ⬆️
file-service 82.29% <ø> (ø)
frontend 96.54% <100.00%> (+<0.01%) ⬆️
notebook-migration-service 83.77% <ø> (ø)
pyamber 98.46% <ø> (+0.06%) ⬆️ Carriedforward from 03290bc
workflow-compiling-service 77.95% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 0 better · 🔴 10 worse · ⚪ 5 noise (<±5%) · 0 without baseline

Compared against main 7b1033b benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 461 0.282 21,296/33,895/33,895 us 🔴 +12.6% / 🔴 +145.4%
🔴 bs=100 sw=10 sl=64 953 0.582 101,248/144,998/144,998 us 🔴 +16.1% / 🔴 +52.1%
⚪ bs=1000 sw=10 sl=64 1,147 0.7 852,888/994,711/994,711 us ⚪ within ±5% / 🔴 +7.6%
Baseline details

Latest main 7b1033b from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 461 tuples/sec 491 tuples/sec 886.32 tuples/sec -6.1% -48.0%
bs=10 sw=10 sl=64 MB/s 0.282 MB/s 0.3 MB/s 0.541 MB/s -6.0% -47.9%
bs=10 sw=10 sl=64 p50 21,296 us 19,898 us 11,452 us +7.0% +86.0%
bs=10 sw=10 sl=64 p95 33,895 us 30,092 us 13,814 us +12.6% +145.4%
bs=10 sw=10 sl=64 p99 33,895 us 30,092 us 16,981 us +12.6% +99.6%
bs=100 sw=10 sl=64 throughput 953 tuples/sec 1,006 tuples/sec 1,152 tuples/sec -5.3% -17.2%
bs=100 sw=10 sl=64 MB/s 0.582 MB/s 0.614 MB/s 0.703 MB/s -5.2% -17.2%
bs=100 sw=10 sl=64 p50 101,248 us 95,588 us 89,907 us +5.9% +12.6%
bs=100 sw=10 sl=64 p95 144,998 us 124,905 us 95,307 us +16.1% +52.1%
bs=100 sw=10 sl=64 p99 144,998 us 124,905 us 108,041 us +16.1% +34.2%
bs=1000 sw=10 sl=64 throughput 1,147 tuples/sec 1,146 tuples/sec 1,186 tuples/sec +0.1% -3.3%
bs=1000 sw=10 sl=64 MB/s 0.7 MB/s 0.699 MB/s 0.724 MB/s +0.1% -3.3%
bs=1000 sw=10 sl=64 p50 852,888 us 872,798 us 877,148 us -2.3% -2.8%
bs=1000 sw=10 sl=64 p95 994,711 us 970,350 us 924,448 us +2.5% +7.6%
bs=1000 sw=10 sl=64 p99 994,711 us 970,350 us 956,928 us +2.5% +3.9%
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,433.61,200,128000,461,0.282,21296.03,33895.14,33895.14
1,100,10,64,20,2097.73,2000,1280000,953,0.582,101248.32,144997.55,144997.55
2,1000,10,64,20,17438.34,20000,12800000,1147,0.700,852888.38,994711.25,994711.25

@zyratlo
zyratlo force-pushed the migration-tool-r-prompts branch from 960adc5 to 9e21203 Compare October 30, 2026 20:25
@zyratlo
zyratlo marked this pull request as ready for review October 30, 2026 20:27
@zyratlo

zyratlo commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

/request-review @mengw15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The disabled-R guard runs after model connection verification, and both R migration examples fail to expose printed statistics as readable outputs.

2 open issues
What changed in this PR

Adds the conversion layer for migrating R notebooks and scripts into Texera workflows, behind a disabled-by-default flag. Import-modal support remains in follow-up PRs.

Changes:

  • Adds R prompts and worked examples for data passing, visualization, and source mappings.
  • Passes source language through conversion, selecting Table API RUDF operators and R notebook metadata.
  • Exposes the opt-in configuration flag and adds conversion, prompt, and configuration tests.
File Description
frontend/​src/​app/​workspace/​service/​notebook-migration/​notebook-migration.service.ts Passes source language to notebook and script conversions.
frontend/​src/​app/​workspace/​service/​notebook-migration/​notebook-migration.service.spec.ts Tests language forwarding and Python defaults.
frontend/​src/​app/​workspace/​service/​notebook-migration/​migration-prompts-r.ts Adds R instructions, examples, and mapping prompts.
frontend/​src/​app/​workspace/​service/​notebook-migration/​migration-prompts-r.spec.ts Validates example structure, connections, and mappings.
frontend/​src/​app/​workspace/​service/​notebook-migration/​migration-llm.ts Selects R prompts, operator properties, and notebook metadata.
frontend/​src/​app/​workspace/​service/​notebook-migration/​migration-llm.spec.ts Tests R conversion wiring, flag checks, and Python compatibility.
frontend/​src/​app/​common/​type/​gui-config.ts Adds the frontend R migration flag type.
frontend/​src/​app/​common/​service/​gui-config.service.mock.ts Defaults the mocked R migration flag to false.
config-service/​src/​main/​scala/​org/​apache/​texera/​service/​resource/​ConfigResource.scala Exposes the R migration flag to the frontend.
common/​config/​src/​test/​scala/​org/​apache/​texera/​common/​config/​GuiConfigSpec.scala Checks that R migration defaults to disabled.
common/​config/​src/​main/​scala/​org/​apache/​texera/​common/​config/​GuiConfig.scala Reads the R migration configuration setting.
common/​config/​src/​main/​resources/​gui.conf Defines the default and environment override.

Review effort: Max

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The R migration prompt recommends unsupported NULL returns that cause generated Table API UDFs to fail; it should require a zero-row data frame with the declared output columns instead.

1 open issue
2 resolved since last review

Review effort: Max

@mengw15 mengw15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mengw15
mengw15 enabled auto-merge November 9, 2026 19:59
@mengw15
mengw15 added this pull request to the merge queue Nov 9, 2026
Merged via the queue into apache:main with commit 94aceba Nov 9, 2026
34 checks passed
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 10, 2026
…#8912)

### What changes were proposed in this PR?

This PR lets users convert R Jupyter notebooks, using the R conversion
from apache#8911. It is the first of the UI PRs for R support (apache#8009). R files
follow in apache#8963 and R folders in a later PR, each as a new tab beside
the Python ones.

**Import modal.** The Jupyter Notebook tab gets a "Python Notebook | R
Notebook" switch, centered above the diagram. It defaults to Python. The
diagram, the description and the upload label follow it, and changing it
clears the staged file. The switch is a `FormControl`, so it keeps its
value when the tab re-renders. `requestImport` now receives a
`language`.

**Disabled, not hidden.** When `rNotebookMigrationEnabled` is off, the R
Notebook option stays visible but disabled, with the tooltip "R is not
enabled on this deployment." Users can see that R exists without being
able to pick it on a deployment that cannot run it. The guard from apache#8911
still refuses R in that case, before any model call.

**Tab descriptors.** A small `IMPORT_TABS` list replaces the index
checks that decided the folder tab and the language. The R file and
folder tabs each add one entry.

**Dispatch.** The dashboard passes the language to the notebook
conversion. For R, only `.ipynb` is accepted in this PR. A notebook
uploaded as R whose `kernelspec.language` is set and is not R is
rejected before any model call: "This notebook uses a python kernel, not
R. Switch the notebook type to Python Notebook." A notebook without a
kernelspec is accepted. Other language mismatches are tracked in apache#8929.

**Assets.** A new R notebook diagram, at the same size and border as the
others. `frontend/LICENSE-binary` adds it to the Project Jupyter logo
and Material Symbols entries.

#### Demo video (wait time cut out)


https://github.com/user-attachments/assets/9769bdd8-5e2d-4994-8a5a-be216908b09f

#### R disabled on a deployment without R

<img width="420" height="159" alt="Screenshot 2026-10-12 at 1 51 42 PM"
src="https://github.com/user-attachments/assets/2c45ea97-9fe2-4b3c-a8ec-4fc2a8875d22"
/>

### Any related issues, documentation, discussions?

Closes apache#9384
Part of apache#8009
Parent-issue apache#4301

The plan is in apache#8866. R
notebooks open in the Jupyter panel without a kernel, since the Jupyter
image has no R kernel. apache#8909 removed the "Kernel not found" dialog that
otherwise appears and keeps the cells read only.

### How was this PR tested?

* `notebook-import-modal.component.spec.ts`, seven new tests: Python is
the default; the R option is disabled with its tooltip while the R flag
is off and enabled without one while it is on; switching to R changes
the diagram and label and drops the staged notebook; R stays selected
across a re-render; the file and folder tabs keep their own language;
and submit passes `"r"`. Existing assertions now expect `"python"`.
* `user-workflow.component.spec.ts`, five new tests: a Python notebook
converts as Python by default, an R notebook converts as R with or
without a kernelspec, a Python kernel notebook is rejected as R, and a
non notebook file is rejected as R.

The full frontend suite passes.

Checked by hand against a local stack. With the R flag on, the switch
changes the diagram, description and label, clears a staged file, and
survives leaving and returning to the tab. With it off, the R option is
disabled and shows its tooltip. The tab fits the modal without scrolling
in every state. An R notebook converted end to end with a live model.

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 13, 2026
### What changes were proposed in this PR?
This PR lets users convert R files, using the R script conversion from
apache#8911. It is the second UI PR for R support (apache#8009), after R notebooks
in apache#8912. R folders follow in apache#9386.

**Import modal.** An "R File" tab after Python Folder, laid out like the
Python File tab: its own diagram, a description, and an upload row that
accepts `.R` and `.r`. It is one more entry in the `IMPORT_TABS` list
from apache#8912, which is all the language and tab logic it needs.

**Disabled, not hidden.** As with the R Notebook option in apache#8912, the
tab is always shown. When `rNotebookMigrationEnabled` is off it is
greyed out, cannot be selected, and its title shows the tooltip "R is
not enabled on this deployment."

**Dispatch.** A small per language table now holds each language's
script extension and messages. For R, the dashboard accepts `.ipynb` or
`.R` / `.r`, and anything else gets "Please upload an R Jupyter Notebook
(.ipynb) or an R (.R) file." R files go through the R script conversion,
and a file that cannot be read gets R wording. Python's messages are
unchanged.

**Assets.** A new R file diagram, at the same size and border as the
others. `frontend/LICENSE-binary` adds it to the Material Symbols entry.

#### Demo video (waiting time cut out)


https://github.com/user-attachments/assets/fc1dc88a-452b-41ca-a972-22e4e9617e53

#### R File disabled on a deployment without R

<img width="308" height="88" alt="image"
src="https://github.com/user-attachments/assets/261f86ac-77a0-4a7f-99ff-6a15da1310f5"
/>

### Any related issues, documentation, discussions?

Closes apache#9385
Part of apache#8009
Parent-issue apache#4301

The plan is in apache#8866.
Language mismatches between the upload and the selected tab are tracked
in apache#8929.

### How was this PR tested?

* `notebook-import-modal.component.spec.ts`, four new tests: the tab is
disabled with its tooltip while the R flag is off and a click does not
select it; while the flag is on it shows its diagram, accepts `.R,.r`
and reports the R language; and submit passes `"r"`. The tab count
assertion now expects four tabs, and the tooltip lookup finds each
tooltip by the element it is attached to, since the modal now has two.
* `user-workflow.component.spec.ts`, three new tests: `.R` and `.r`
convert as R scripts, and an unreadable R file gets R wording. The R
test from apache#8912 now rejects a `.py`, since `.R` is accepted here, and
the Python script assertion now expects `"python"`.

The full frontend suite passes.

Checked by hand against a local stack. With the R flag off, the R File
tab is disabled, ignores clicks and shows its tooltip. With it on, the
tab shows its diagram, description and `.R,.r` upload row, a staged file
clears on changing tabs, and no tab scrolls. An R file converted end to
end with a live model.

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common frontend Changes related to the frontend GUI platform Non-amber Scala service paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants