Skip to content

feat(notebook-migration): add r folders to the import modal - #9427

Merged
mengw15 merged 5 commits into
apache:mainfrom
zyratlo:migration-tool-r-folder
Nov 19, 2026
Merged

mengw15 merged 5 commits into
apache:mainfrom
zyratlo:migration-tool-r-folder

Conversation

@zyratlo

@zyratlo zyratlo commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

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 (#8009). It reuses the Python folder pipeline from #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)

r.folder.pr.demo.mov

R Folder disabled on a deployment without R

image

Any related issues, documentation, discussions?

Closes #9386
Closes #8009
Parent-issue #4301

The plan is in #8866. With this PR, R supports the same three inputs as Python: notebooks (#8912), files (#8963) and folders. Language mismatches between the upload and the selected tab are tracked in #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)

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Nov 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Linked issue already claimed

This PR closes an issue that someone else has already claimed:

Issue Claimed by Their open PR
#8009 @mengw15 (assignee) —

Please check with them before this merges. Merging closes the issue, and any work they have in progress is left with nothing to fix.

  • If this PR takes over, say so here. Credit any of their work it includes, for example with a Co-authored-by: trailer.
  • If their claim is stale, they can release it with /untake, or a maintainer can unassign them.
  • Otherwise, remove that issue's closing keyword from this PR's description.

Refreshed whenever this PR is edited; deleted once nothing here applies.

@github-actions

github-actions Bot commented Nov 13, 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: @renovate-bot
    You can notify them by mentioning @renovate-bot in a comment.

@codecov-commenter

codecov-commenter commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.61%. Comparing base (a915d6b) to head (06451ac).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #9427   +/-   ##
=========================================
  Coverage     91.61%   91.61%           
+ Complexity     5048     5047    -1     
=========================================
  Files          1284     1284           
  Lines         57038    57078   +40     
  Branches       7421     7424    +3     
=========================================
+ Hits          52254    52293   +39     
- Misses         2909     2913    +4     
+ Partials       1875     1872    -3     
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø) Carriedforward from 7adc729
agent-service 99.56% <ø> (ø) Carriedforward from 7adc729
amber 85.34% <ø> (-0.02%) ⬇️ Carriedforward from 7adc729
computing-unit-managing-service 64.05% <ø> (ø) Carriedforward from 7adc729
config-service 87.73% <ø> (ø) Carriedforward from 7adc729
file-service 82.16% <ø> (ø) Carriedforward from 7adc729
frontend 96.42% <100.00%> (+0.01%) ⬆️
notebook-migration-service 83.77% <ø> (ø) Carriedforward from 7adc729
pyamber 98.50% <ø> (ø) Carriedforward from 7adc729
workflow-compiling-service 78.30% <ø> (ø) Carriedforward from 7adc729

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

@zyratlo

zyratlo commented Nov 16, 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 are reported for the R folder import changes.

No open issues 🎉

What changed in this PR

Extends Texera’s notebook-migration tool to import local R folders through the existing Python folder pipeline, completing R input support alongside notebooks and single files.

Changes:

  • Makes folder filtering, assembly, limits, and messages language-aware while preserving Python behavior.
  • Adds R folder prompts and examples for self-contained R UDFs, entry-point mapping, and valid slash escaping.
  • Adds a feature-gated R Folder tab, passes the selected language through conversion, and expands regression coverage.
File Description
frontend/​src/​app/​workspace/​service/​notebook-migration/​notebook-migration.service.ts Passes language through folder parsing and conversion.
frontend/​src/​app/​workspace/​service/​notebook-migration/​notebook-migration.service.spec.ts Covers R filtering, messages, dispatch, and feature gating.
frontend/​src/​app/​workspace/​service/​notebook-migration/​migration-prompts-r.ts Adds R folder prompts, a worked example, and slash-escaping guidance.
frontend/​src/​app/​workspace/​service/​notebook-migration/​migration-prompts-r.spec.ts Validates example definitions, entry-point mappings, and escaping.
frontend/​src/​app/​workspace/​service/​notebook-migration/​migration-llm.ts Selects folder prompts and operator settings by language.
frontend/​src/​app/​workspace/​service/​notebook-migration/​migration-llm.spec.ts Covers R folder prompts, operators, notebook metadata, and gating.
frontend/​src/​app/​workspace/​service/​notebook-migration/​folder-assembly.ts Adds language-specific extensions, exclusions, and messages.
frontend/​src/​app/​workspace/​service/​notebook-migration/​folder-assembly.spec.ts Tests R paths, exclusions, limits, and Python compatibility.
frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.ts Registers the R Folder tab.
frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.spec.ts Tests tab gating, directory selection, and submission.
frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.html Adds the R Folder description, diagram, and directory picker.
frontend/​src/​app/​dashboard/​component/​user/​user-workflow/​user-workflow.component.ts Forwards the selected language through folder import.
frontend/​src/​app/​dashboard/​component/​user/​user-workflow/​user-workflow.component.spec.ts Verifies Python and R folder language dispatch.
frontend/​LICENSE-binary Adds attribution for the R folder 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

@mengw15
mengw15 added this pull request to the merge queue Nov 19, 2026
Merged via the queue into apache:main with commit 1d7c006 Nov 19, 2026
24 checks passed
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)
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 24, 2026
…h the selected tab (apache#9578)

### What changes were proposed in this PR?

The import modal decides which prompts a conversion uses from where the
user uploads: the Python Notebook / R Notebook switch on the Jupyter
Notebook tab, or the Python File, Python Folder, R File and R Folder
tabs. Until now only one mismatch was checked, and its message could
point users to the wrong place. An R notebook uploaded as a Python
Notebook went through to the Python prompts and came back as a workflow
of broken Python UDFs.

**Mismatch checks.** The dashboard now checks every upload against the
selected language before any model call:

* Notebooks: the language comes from `metadata.kernelspec.language`,
falling back to `metadata.language_info.name`, ignoring case and
surrounding spaces. A notebook that declares neither is accepted as
before.
* Files: the extension decides. An extension no language claims keeps
today's upload hint.
* Folders: a folder with no files in the selected language but some in
another is pointed at the right tab. Any other folder, including a mixed
one, goes on to `parseFolder` and its existing checks.

| Upload | Message |
| --- | --- |
| R notebook as a Python Notebook | This notebook uses an R kernel, not
Python. Switch the notebook type to R Notebook. |
| Python notebook as an R Notebook | This notebook uses a Python kernel,
not R. Switch the notebook type to Python Notebook. |
| Any other kernel, either type | This notebook uses a julia kernel.
Only Python and R notebooks can be converted. |
| R file on a Python tab | This is an R file. Upload it under the R File
tab. |
| Python file on an R tab | This is a Python file. Upload it under the
Python File tab. |
| Python folder on R Folder | This folder holds Python files, not R.
Upload it under the Python Folder tab. |
| R folder on Python Folder | This folder holds R files, not Python.
Upload it under the R Folder tab. |

When the right place is an R option and R is not enabled on the
deployment, the message says so instead of pointing at a disabled
control, for example "This notebook uses an R kernel, and R is not
enabled on this deployment." The checks are driven by the per language
table the dispatch already used, now extended with each language's
kernel name, notebook type and tab names, so a later language gets them
without new branches.

**Script read errors.** `parseScriptFile` takes the language, so an
empty or unreadable R file is reported as "The R file is empty." or
"Failed to read the R file." rather than naming Python.

**Error duration.** Migration errors now stay on screen for 8 seconds
instead of ng-zorro's default 3, since most of them are two sentences of
instructions. Errors elsewhere in the app keep the default.

#### Demo video

https://drive.google.com/file/d/1BkMJHuZqcvIPArxia73Dtqp3th-_y2kn/view?usp=sharing

### Any related issues, documentation, discussions?

Closes apache#8929
Parent-issue apache#4301

### How was this PR tested?

* `user-workflow.component.spec.ts`, a new "language mismatches" block
of 14 tests covering every row above: R and Python notebooks on the
wrong type with R on and off, case and spacing in the declared language,
the `language_info` fallback, an unsupported kernel on both types with
the right article, R and Python files on the wrong tab with R on and
off, an unknown extension, folders in either direction with R on and
off, and a mixed folder and a folder with no source both reaching
`parseFolder`. Existing assertions were updated to the new wording and
to expect the 8 second duration, and the R folder test from apache#9427 now
sends R files.
* `notebook-migration.service.spec.ts`: the exact Python and R messages
from `parseScriptFile`.

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

Checked against a local stack by driving the modal's own upload and
submit with files carrying the mock inputs' kernels, extensions and
folder paths. With R off, the four R uploads on Python options each
showed the R is not enabled message. With R on, all seven mismatches
showed the messages above, and a matching R notebook passed the checks
and went on to the model call. No mismatch made a model request. An
error toast stayed visible for about 9 seconds, the 8 second duration
plus its fade out.

### 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]>
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 folders [Notebook Migration] Support migrating R code

4 participants