Skip to content

feat(notebook-migration): add r files to the import modal - #8963

Merged
mengw15 merged 3 commits into
apache:mainfrom
zyratlo:migration-tool-r-file
Nov 13, 2026
Merged

mengw15 merged 3 commits into
apache:mainfrom
zyratlo:migration-tool-r-file

Conversation

@zyratlo

@zyratlo zyratlo commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

This PR lets users convert R files, using the R script conversion from #8911. It is the second UI PR for R support (#8009), after R notebooks in #8912. R folders follow in #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 #8912, which is all the language and tab logic it needs.

Disabled, not hidden. As with the R Notebook option in #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)

r-file-pr-demo.mov

R File disabled on a deployment without R

image

Any related issues, documentation, discussions?

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

The plan is in #8866. Language mismatches between the upload and the selected tab are tracked in #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 feat(notebook-migration): add r notebooks to the import modal #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)

@github-actions github-actions Bot added frontend Changes related to the frontend GUI common platform Non-amber Scala service paths labels Oct 12, 2026
@github-actions

github-actions Bot commented Oct 12, 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: @carloea2
    You can notify them by mentioning @carloea2 in a comment.

@codecov-commenter

codecov-commenter commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.75%. Comparing base (ada1cfe) to head (1435281).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8963   +/-   ##
=========================================
  Coverage     91.75%   91.75%           
  Complexity     5024     5024           
=========================================
  Files          1281     1281           
  Lines         56747    56770   +23     
  Branches       7452     7452           
=========================================
+ Hits          52067    52089   +22     
  Misses         2802     2802           
- Partials       1878     1879    +1     
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø) Carriedforward from ada1cfe
agent-service 99.53% <ø> (ø) Carriedforward from ada1cfe
amber 85.78% <ø> (ø) Carriedforward from ada1cfe
computing-unit-managing-service 64.05% <ø> (ø) Carriedforward from ada1cfe
config-service 87.73% <ø> (ø) Carriedforward from ada1cfe
file-service 82.31% <ø> (ø) Carriedforward from ada1cfe
frontend 96.37% <100.00%> (-0.01%) ⬇️
notebook-migration-service 83.77% <ø> (ø) Carriedforward from ada1cfe
pyamber 98.44% <ø> (ø) Carriedforward from ada1cfe
workflow-compiling-service 78.30% <ø> (ø) Carriedforward from ada1cfe

*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

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 516 0.315 18,755/27,541/27,541 us 🔴 +13.6% / 🔴 +75.2%
🔴 bs=100 sw=10 sl=64 1,182 0.721 84,433/104,740/104,740 us 🔴 +19.3% / 🟢 +15.3%
⚪ bs=1000 sw=10 sl=64 1,408 0.859 707,854/757,899/757,899 us ⚪ within ±5% / 🟢 +32.9%
Baseline details

Latest main 9cf43f2 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 516 tuples/sec 575 tuples/sec 790.31 tuples/sec -10.3% -34.7%
bs=10 sw=10 sl=64 MB/s 0.315 MB/s 0.351 MB/s 0.482 MB/s -10.3% -34.7%
bs=10 sw=10 sl=64 p50 18,755 us 16,503 us 12,375 us +13.6% +51.6%
bs=10 sw=10 sl=64 p95 27,541 us 27,722 us 15,719 us -0.7% +75.2%
bs=10 sw=10 sl=64 p99 27,541 us 27,722 us 19,058 us -0.7% +44.5%
bs=100 sw=10 sl=64 throughput 1,182 tuples/sec 1,267 tuples/sec 1,025 tuples/sec -6.7% +15.3%
bs=100 sw=10 sl=64 MB/s 0.721 MB/s 0.773 MB/s 0.626 MB/s -6.7% +15.3%
bs=100 sw=10 sl=64 p50 84,433 us 78,796 us 98,759 us +7.2% -14.5%
bs=100 sw=10 sl=64 p95 104,740 us 87,813 us 105,327 us +19.3% -0.6%
bs=100 sw=10 sl=64 p99 104,740 us 87,813 us 120,491 us +19.3% -13.1%
bs=1000 sw=10 sl=64 throughput 1,408 tuples/sec 1,432 tuples/sec 1,059 tuples/sec -1.7% +32.9%
bs=1000 sw=10 sl=64 MB/s 0.859 MB/s 0.874 MB/s 0.646 MB/s -1.7% +32.9%
bs=1000 sw=10 sl=64 p50 707,854 us 702,831 us 965,886 us +0.7% -26.7%
bs=1000 sw=10 sl=64 p95 757,899 us 737,836 us 1,007,533 us +2.7% -24.8%
bs=1000 sw=10 sl=64 p99 757,899 us 737,836 us 1,031,622 us +2.7% -26.5%
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,387.76,200,128000,516,0.315,18754.56,27540.92,27540.92
1,100,10,64,20,1692.50,2000,1280000,1182,0.721,84433.03,104740.39,104740.39
2,1000,10,64,20,14204.80,20000,12800000,1408,0.859,707854.38,757898.50,757898.50

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]>
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)
@zyratlo
zyratlo force-pushed the migration-tool-r-file branch from bd150fc to 1435281 Compare November 12, 2026 21:34
@zyratlo
zyratlo marked this pull request as ready for review November 12, 2026 21:37
@zyratlo

zyratlo commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

/request-review @mengw15

@github-actions github-actions Bot removed common platform Non-amber Scala service paths labels Nov 12, 2026
@github-actions
github-actions Bot requested a review from mengw15 November 12, 2026 21:43
@mengw15
mengw15 requested a balanced review from Copilot November 12, 2026 22:10

@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

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
What changed in this PR

Adds first-class UI support for importing R script files via the notebook migration import modal, wiring the dashboard import flow to accept .R/.r alongside R notebooks and route scripts through the R conversion path.

Changes:

  • Add an “R File” tab to the import modal (visible but disabled behind the R migration flag) with diagram, copy, and .R/.r accept filter.
  • Update dashboard import validation + dispatch to support per-language script extensions and route R scripts through script conversion with R-specific messages.
  • Extend frontend unit tests to cover the new tab behavior and R script import paths.
File Description
frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.ts Adds the R File import tab to the shared tab list and updates modal docstring.
frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.html Implements the R File tab UI, diagram asset, copy, and upload accept list.
frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.spec.ts Adds coverage for disabled/enabled R File tab behavior and submit language.
frontend/​src/​app/​dashboard/​component/​user/​user-workflow/​user-workflow.component.ts Introduces per-language script metadata + validation and routes scripts with language.
frontend/​src/​app/​dashboard/​component/​user/​user-workflow/​user-workflow.component.spec.ts Adds tests for .R/.r conversion and R-specific unreadable-file messaging.
frontend/​LICENSE-binary Registers the new R file diagram asset in third-party licensing list.

Review effort: Lite

@mengw15
mengw15 enabled auto-merge November 12, 2026 22:45
@mengw15
mengw15 added this pull request to the merge queue Nov 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 12, 2026
@mengw15
mengw15 added this pull request to the merge queue Nov 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 12, 2026
@mengw15
mengw15 added this pull request to the merge queue Nov 13, 2026
Merged via the queue into apache:main with commit 22cc29d Nov 13, 2026
23 checks passed
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 files/scripts

4 participants