Skip to content

feat(notebook-migration): add r notebooks to the import modal - #8912

Merged
mengw15 merged 2 commits into
apache:mainfrom
zyratlo:migration-tool-r-support
Nov 10, 2026
Merged

mengw15 merged 2 commits into
apache:mainfrom
zyratlo:migration-tool-r-support

Conversation

@zyratlo

@zyratlo zyratlo commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

This PR lets users convert R Jupyter notebooks, using the R conversion from #8911. It is the first of the UI PRs for R support (#8009). R files follow in #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 #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 #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)

r-notebook-pr-demo.mp4

R disabled on a deployment without R

Screenshot 2026-10-12 at 1 51 42 PM

Any related issues, documentation, discussions?

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

The plan is in #8866. R notebooks open in the Jupyter panel without a kernel, since the Jupyter image has no R kernel. #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)

@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: @mengw15
    You can notify them by mentioning @mengw15 in a comment.

@github-actions github-actions Bot added frontend Changes related to the frontend GUI common platform Non-amber Scala service paths labels Oct 7, 2026
@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 (94aceba) to head (bfffa10).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8912   +/-   ##
=========================================
  Coverage     91.80%   91.80%           
  Complexity     5022     5022           
=========================================
  Files          1275     1275           
  Lines         56324    56359   +35     
  Branches       7357     7362    +5     
=========================================
+ Hits          51708    51743   +35     
  Misses         2764     2764           
  Partials       1852     1852           
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø) Carriedforward from 94aceba
agent-service 99.53% <ø> (ø) Carriedforward from 94aceba
amber 85.77% <ø> (ø) Carriedforward from 94aceba
computing-unit-managing-service 64.05% <ø> (ø) Carriedforward from 94aceba
config-service 87.73% <ø> (ø) Carriedforward from 94aceba
file-service 82.29% <ø> (ø) Carriedforward from 94aceba
frontend 96.54% <100.00%> (+<0.01%) ⬆️
notebook-migration-service 83.77% <ø> (ø) Carriedforward from 94aceba
pyamber 98.46% <ø> (ø) Carriedforward from 94aceba
workflow-compiling-service 77.95% <ø> (ø) Carriedforward from 94aceba

*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 · 🔴 8 worse · ⚪ 7 noise (<±5%) · 0 without baseline

Compared against main 9cf43f2 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 344 0.21 28,268/38,082/38,082 us 🔴 +26.9% / 🔴 +142.3%
🔴 bs=100 sw=10 sl=64 762 0.465 129,778/152,330/152,330 us 🔴 -6.8% / 🔴 +44.6%
⚪ bs=1000 sw=10 sl=64 894 0.546 1,114,755/1,172,925/1,172,925 us ⚪ within ±5% / 🔴 +16.4%
Baseline details

Latest main 9cf43f2 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 344 tuples/sec 406 tuples/sec 790.31 tuples/sec -15.3% -56.5%
bs=10 sw=10 sl=64 MB/s 0.21 MB/s 0.248 MB/s 0.482 MB/s -15.3% -56.5%
bs=10 sw=10 sl=64 p50 28,268 us 25,095 us 12,375 us +12.6% +128.4%
bs=10 sw=10 sl=64 p95 38,082 us 30,001 us 15,719 us +26.9% +142.3%
bs=10 sw=10 sl=64 p99 38,082 us 30,001 us 19,058 us +26.9% +99.8%
bs=100 sw=10 sl=64 throughput 762 tuples/sec 817 tuples/sec 1,025 tuples/sec -6.7% -25.6%
bs=100 sw=10 sl=64 MB/s 0.465 MB/s 0.499 MB/s 0.626 MB/s -6.8% -25.7%
bs=100 sw=10 sl=64 p50 129,778 us 121,952 us 98,759 us +6.4% +31.4%
bs=100 sw=10 sl=64 p95 152,330 us 153,468 us 105,327 us -0.7% +44.6%
bs=100 sw=10 sl=64 p99 152,330 us 153,468 us 120,491 us -0.7% +26.4%
bs=1000 sw=10 sl=64 throughput 894 tuples/sec 901 tuples/sec 1,059 tuples/sec -0.8% -15.6%
bs=1000 sw=10 sl=64 MB/s 0.546 MB/s 0.55 MB/s 0.646 MB/s -0.7% -15.5%
bs=1000 sw=10 sl=64 p50 1,114,755 us 1,102,362 us 965,886 us +1.1% +15.4%
bs=1000 sw=10 sl=64 p95 1,172,925 us 1,234,010 us 1,007,533 us -5.0% +16.4%
bs=1000 sw=10 sl=64 p99 1,172,925 us 1,234,010 us 1,031,622 us -5.0% +13.7%
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,581.76,200,128000,344,0.210,28267.86,38082.20,38082.20
1,100,10,64,20,2624.93,2000,1280000,762,0.465,129777.52,152330.17,152330.17
2,1000,10,64,20,22371.59,20000,12800000,894,0.546,1114755.07,1172924.60,1172924.60

@zyratlo
zyratlo force-pushed the migration-tool-r-support branch from 613908a to 1122c60 Compare October 12, 2026 20:53
@zyratlo zyratlo changed the title feat(notebook-migration): add an r option to the import modal feat(notebook-migration): add r notebooks to the import modal Oct 12, 2026
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 9, 2026
…r sources (apache#8911)

### What changes were proposed in this PR?

This is the second of the PRs adding R support to the migration tool
(apache#8009), building on the prompt sets from apache#8910. It adds the R side of
the conversion. Nothing is user visible yet: the import modal options
arrive in apache#8912 and apache#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
(apache#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 apache#8009
Parent-issue apache#4301

The plan is in apache#8866. The
import modal options follow in apache#8912 (R notebooks) and apache#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 apache#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 apache#8912 and apache#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)

---------

Co-authored-by: Meng Wang <[email protected]>
@zyratlo
zyratlo force-pushed the migration-tool-r-support branch from 1122c60 to bfffa10 Compare November 9, 2026 21:55
@github-actions github-actions Bot removed common platform Non-amber Scala service paths labels Nov 9, 2026
@zyratlo
zyratlo marked this pull request as ready for review November 9, 2026 22:35
@zyratlo

zyratlo commented Nov 9, 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.

🟢 Approval recommended

No active review issues block approval of the R notebook import changes.

No open issues 🎉

What changed in this PR

Adds R Jupyter notebook imports to the frontend, connecting the import modal to the existing R conversion support while preserving Python notebook, file, and folder imports.

Changes:

  • Adds a persistent Python/R notebook switch, with R disabled and explained by a tooltip when deployment support is off.
  • Passes the selected language to conversion and rejects non-notebook R uploads and notebooks with an explicitly non-R kernel.
  • Adds modal and dispatch tests, language-specific presentation, and diagram license attribution.
File Description
frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.ts Manages notebook language, tab descriptors, and language-aware submission.
frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.spec.ts Tests language selection, feature gating, persistence, and submission.
frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.scss Centers and spaces the language switch.
frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.html Adds the switch, disabled-state tooltip, and R-specific diagram and text.
frontend/​src/​app/​dashboard/​component/​user/​user-workflow/​user-workflow.component.ts Routes notebook conversion by language and validates R uploads.
frontend/​src/​app/​dashboard/​component/​user/​user-workflow/​user-workflow.component.spec.ts Tests language forwarding and R upload validation.
frontend/​LICENSE-binary Attributes third-party assets used in the R notebook diagram.

Review effort: Balanced

@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. Eight mutations, each turning exactly the matching test red: the Python default, the disabled R option and its tooltip, clearing the staged file on switch, the language getter, the IMPORT_TABS order, the kernelspec guard and the .ipynb-only check. The two rejection tests assert the right negatives — sendToAIGenerateWorkflow not called, and for a non-notebook neither parseAndTagNotebook nor the script path.

Also checked: the new diagram is 1350x344 like the other three and matches its declared size, and LICENSE-binary adds it to both the Material Symbols and the Project Jupyter entries, which is right since it carries both.

@mengw15
mengw15 enabled auto-merge November 10, 2026 07:27
@mengw15
mengw15 added this pull request to the merge queue Nov 10, 2026
Merged via the queue into apache:main with commit 8420565 Nov 10, 2026
39 checks passed
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)
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 19, 2026
)

### What changes were proposed in this PR?

This PR lets users convert a local folder of R files, the last input
type for R support (apache#8009). It reuses the Python folder pipeline from
apache#8767: the folder is assembled into one banner separated document, the
model names an entry point, and the notebook shows that file with each
operator mapped to its call site.

**Folder assembly.** `folder-assembly.ts` now takes the language. A
small per language table gives the file extension, the directories to
skip and the name used in messages. R reads `.R` and `.r` and skips
`renv` and `packrat`, which hold installed packages full of `.R` files.
Python's extension, exclusions and messages are unchanged. Files in
other languages are named in the folder layout and never read, as for
Python, so a folder of `.py` files on the R tab gets "No R files were
found in the selected folder."

**R folder prompts.** `MigrationPromptSet` gains folder fields, so
`convertFolderToWorkflow` takes the language like the notebook and
script conversions and goes through the same R flag guard.
`migration-prompts-r.ts` adds R versions of the three folder prompts,
which differ from the Python ones where R differs:

* `source()` is how R files load each other, and it reads a file, which
a UDF cannot do. The prompt asks the model to copy every definition a
UDF uses into that UDF and to never call `source()`.
* R has no `if __name__ == "__main__"`, so the entry point is described
as the file whose top level code sources the others and calls their
functions.

The worked example is a three file project: `data_prep.R` and `models.R`
define functions, and `main.R` sources them and calls them in order.
Unlike the Python folder example, each example UDF carries the
definition of the function it calls, which is what the prompt asks for.
The example was generated from a real project that runs under `Rscript`,
and all six example UDFs were run through texera-rudf on `diabetes.csv`,
chained the way `buildWorkflow` wires them.

**Escaped slashes.** In one live run the model wrote `<\/script>` inside
an R string. R rejects `\/` as an unrecognized escape, so the plot UDF
failed to parse. The R visualization rules now say to write closing tags
as shown, and a guard test keeps every R worked example free of `\/`.
The rule is part of the shared R documentation, so it covers R notebooks
and files too.

**Import modal.** An "R Folder" tab after R File, laid out like the
Python Folder tab with its own diagram and a directory picker. It is one
more `IMPORT_TABS` entry, so the existing folder handling (directory
picker, drop rejection, whole list selection) applies to it unchanged.
As with the other R options, it is shown but disabled with the tooltip
"R is not enabled on this deployment." when `rNotebookMigrationEnabled`
is off. Its description is shorter than the Python Folder one so the tab
fits the modal without scrolling. The dashboard passes the language to
`parseFolder` and the folder conversion.

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

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


https://github.com/user-attachments/assets/f7be5cfb-fb49-46eb-a440-b4711ddad40f

**R Folder disabled on a deployment without R**

<img width="727" height="156" alt="image"
src="https://github.com/user-attachments/assets/383e127e-9a4b-40b4-9992-1b8f2a4995ad"
/>

### Any related issues, documentation, discussions?

Closes apache#9386
Closes apache#8009
Parent-issue apache#4301

The plan is in apache#8866. With
this PR, R supports the same three inputs as Python: notebooks (apache#8912),
files (apache#8963) and folders. Language mismatches between the upload and
the selected tab are tracked in apache#8929.

### How was this PR tested?

* `folder-assembly.spec.ts`: R paths (`.R` and `.r` accepted; `.py`,
`.Rmd` and `.Rproj` rejected; `renv`, `packrat` and `.Rproj.user`
skipped), each language's exclusions applying only to that language, the
exact Python messages and the R messages, and the layout's overflow line
naming R.
* `notebook-migration.service.spec.ts`: `parseFolder` for R keeps the R
files, names a `.py` in the layout and drops `renv`, with the R messages
for no files and all blank files. The language reaches the folder
conversion, and an R folder is refused before any client is created
while the R flag is off.
* `migration-llm.spec.ts`: the exact R folder prelude, layout and
prompts, RUDF operators and the `ir` kernel from a folder, and the R
flag blocking a folder without a model call.
* `migration-prompts-r.spec.ts`: the folder example passes the same
guards as the notebook and script examples, plus four of its own: its
entry point is a file in the folder, no UDF calls `source()` and each
copies the definitions it calls, the layout names a file the document
leaves out, and every mapping range falls on non blank lines of the
entry point.
* `notebook-import-modal.component.spec.ts`: four new tests for the R
Folder tab: disabled with its tooltip while the flag is off, not
selectable by a click, a directory picker with the R language while the
flag is on, and submit passing the whole folder with `"r"`. The tab
counts now expect five.
* `user-workflow.component.spec.ts`: an R folder is read and converted
as R, and the Python folder test now checks `"python"`.

The full frontend suite passes, and every new line and branch is
covered.

Checked by hand against a local stack. With the R flag on, all five tabs
fit on one line, every tab fits the modal without scrolling, and the R
Folder tab stages a picked folder as one R selection. Two live
conversions of the example project each produced a six operator RUDF
workflow with the expected edges and output types, and a notebook of
only `main.R` with each operator mapped to its call site. After the
slash fix, the generated UDFs ran through texera-rudf with the same
accuracies as `Rscript`. These runs used the worked example's own
project, so they check the pipeline more than how well the model
generalizes. With the flag off, the R Folder tab is disabled, ignores
clicks and shows its tooltip on one line.

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

Generated-by: Claude Code (Claude Opus 5.5)
Ma77Ball pushed a commit to Ma77Ball/texera that referenced this pull request Nov 21, 2026
)

### What changes were proposed in this PR?

This PR lets users convert a local folder of R files, the last input
type for R support (apache#8009). It reuses the Python folder pipeline from
apache#8767: the folder is assembled into one banner separated document, the
model names an entry point, and the notebook shows that file with each
operator mapped to its call site.

**Folder assembly.** `folder-assembly.ts` now takes the language. A
small per language table gives the file extension, the directories to
skip and the name used in messages. R reads `.R` and `.r` and skips
`renv` and `packrat`, which hold installed packages full of `.R` files.
Python's extension, exclusions and messages are unchanged. Files in
other languages are named in the folder layout and never read, as for
Python, so a folder of `.py` files on the R tab gets "No R files were
found in the selected folder."

**R folder prompts.** `MigrationPromptSet` gains folder fields, so
`convertFolderToWorkflow` takes the language like the notebook and
script conversions and goes through the same R flag guard.
`migration-prompts-r.ts` adds R versions of the three folder prompts,
which differ from the Python ones where R differs:

* `source()` is how R files load each other, and it reads a file, which
a UDF cannot do. The prompt asks the model to copy every definition a
UDF uses into that UDF and to never call `source()`.
* R has no `if __name__ == "__main__"`, so the entry point is described
as the file whose top level code sources the others and calls their
functions.

The worked example is a three file project: `data_prep.R` and `models.R`
define functions, and `main.R` sources them and calls them in order.
Unlike the Python folder example, each example UDF carries the
definition of the function it calls, which is what the prompt asks for.
The example was generated from a real project that runs under `Rscript`,
and all six example UDFs were run through texera-rudf on `diabetes.csv`,
chained the way `buildWorkflow` wires them.

**Escaped slashes.** In one live run the model wrote `<\/script>` inside
an R string. R rejects `\/` as an unrecognized escape, so the plot UDF
failed to parse. The R visualization rules now say to write closing tags
as shown, and a guard test keeps every R worked example free of `\/`.
The rule is part of the shared R documentation, so it covers R notebooks
and files too.

**Import modal.** An "R Folder" tab after R File, laid out like the
Python Folder tab with its own diagram and a directory picker. It is one
more `IMPORT_TABS` entry, so the existing folder handling (directory
picker, drop rejection, whole list selection) applies to it unchanged.
As with the other R options, it is shown but disabled with the tooltip
"R is not enabled on this deployment." when `rNotebookMigrationEnabled`
is off. Its description is shorter than the Python Folder one so the tab
fits the modal without scrolling. The dashboard passes the language to
`parseFolder` and the folder conversion.

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

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


https://github.com/user-attachments/assets/f7be5cfb-fb49-46eb-a440-b4711ddad40f

**R Folder disabled on a deployment without R**

<img width="727" height="156" alt="image"
src="https://github.com/user-attachments/assets/383e127e-9a4b-40b4-9992-1b8f2a4995ad"
/>

### Any related issues, documentation, discussions?

Closes apache#9386
Closes apache#8009
Parent-issue apache#4301

The plan is in apache#8866. With
this PR, R supports the same three inputs as Python: notebooks (apache#8912),
files (apache#8963) and folders. Language mismatches between the upload and
the selected tab are tracked in apache#8929.

### How was this PR tested?

* `folder-assembly.spec.ts`: R paths (`.R` and `.r` accepted; `.py`,
`.Rmd` and `.Rproj` rejected; `renv`, `packrat` and `.Rproj.user`
skipped), each language's exclusions applying only to that language, the
exact Python messages and the R messages, and the layout's overflow line
naming R.
* `notebook-migration.service.spec.ts`: `parseFolder` for R keeps the R
files, names a `.py` in the layout and drops `renv`, with the R messages
for no files and all blank files. The language reaches the folder
conversion, and an R folder is refused before any client is created
while the R flag is off.
* `migration-llm.spec.ts`: the exact R folder prelude, layout and
prompts, RUDF operators and the `ir` kernel from a folder, and the R
flag blocking a folder without a model call.
* `migration-prompts-r.spec.ts`: the folder example passes the same
guards as the notebook and script examples, plus four of its own: its
entry point is a file in the folder, no UDF calls `source()` and each
copies the definitions it calls, the layout names a file the document
leaves out, and every mapping range falls on non blank lines of the
entry point.
* `notebook-import-modal.component.spec.ts`: four new tests for the R
Folder tab: disabled with its tooltip while the flag is off, not
selectable by a click, a directory picker with the R language while the
flag is on, and submit passing the whole folder with `"r"`. The tab
counts now expect five.
* `user-workflow.component.spec.ts`: an R folder is read and converted
as R, and the Python folder test now checks `"python"`.

The full frontend suite passes, and every new line and branch is
covered.

Checked by hand against a local stack. With the R flag on, all five tabs
fit on one line, every tab fits the modal without scrolling, and the R
Folder tab stages a picked folder as one R selection. Two live
conversions of the example project each produced a six operator RUDF
workflow with the expected edges and output types, and a notebook of
only `main.R` with each operator mapped to its call site. After the
slash fix, the generated UDFs ran through texera-rudf with the same
accuracies as `Rscript`. These runs used the worked example's own
project, so they check the pipeline more than how well the model
generalizes. With the flag off, the R Folder tab is disabled, ignores
clicks and shows its tooltip on one line.

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

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Notebook Migration] Support migrating R Jupyter notebooks

4 participants