Skip to content

feat(notebook-migration): support migrating local Python folders into workflows - #8767

Merged
mengw15 merged 24 commits into
apache:mainfrom
zyratlo:migration-tool-python-folder
Oct 5, 2026
Merged

mengw15 merged 24 commits into
apache:mainfrom
zyratlo:migration-tool-python-folder

Conversation

@zyratlo

@zyratlo zyratlo commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

The migration tool accepted a Jupyter notebook and a single Python file. It now accepts a folder of Python files selected from disk, and produces one workflow from all of them, with the same stored source and operator mapping that drive highlighting in the Jupyter panel.

A folder is harder than a script for the same reason a script was harder than a notebook: the mapping keys on cells, and there are none. This PR does not introduce a second mechanism for that. The folder's Python files are concatenated into one document, each behind a banner line naming the file it came from, with line numbers running continuously across the whole thing. The model then reports line ranges exactly as it does for a single script, and #8007's segmenter derives the cells. The mapping stays keyed on cell uuids, so storage, the Jupyter panel and the highlight index never learn that folders exist. No backend, database, Helm, or dependency changes.

The alternative was to number each file separately and key the mapping on file plus line range. That changes the stored mapping shape, which pulls in the backend, the database and the panel, to buy provenance the banner line already provides.

Main pieces:

  • folder-assembly.ts, a new pure module: which files are in scope, the order they are joined in, the assembled document, the layout, the caps, and entry point resolution. It reuses the segmenter's own line splitting, so assembling, numbering the prompt and slicing the cells all agree on what a line is.
  • segmentScript gains one optional argument, a list of caller-required cut points. Each file's banner joins the boundary set, so no cell holds lines from two files. Every invariant the module already documented holds unchanged.
  • An indented layout of the folder, sent as prompt text ahead of the numbered document. It is deliberately not part of that document: numbering it would shift every line the model reports, and the segmenter would emit it as a cell of directory listing. It also names the folder's non-Python files without reading them, so the model knows a dataset or a requirements list exists.
  • Folder variants of the conversion prompt, the mapping prompt, and the worked example. migration-prompts.ts is 232 insertions and 10 deletions. All 232 insertions are the new folder constants. The 10 deletions are apostrophe fixes raised in review (ID's to IDs, key's to keys, UDF's to UDFs where it is a plural), applied uniformly to the notebook, script and folder prompts so the three do not drift apart on wording. No other notebook or script prompt text changed.

The derived notebook holds the entry point alone, not every file. A folder's other files are function definitions, and a notebook of all of them reads as a wall of code rather than the story of what the project does. The model names the entry point in the conversion reply, so this costs no extra round trip, and the mapping it reports is expressed in that file's lines. Clicking an operator highlights the call that runs it. When the entry point cannot be resolved the notebook falls back to the whole folder, which is worse to read but never empty.

Two caps refuse an oversized folder before any request is sent: 100 files, and 60,000 characters of code. The binding constraint is the reply rather than the prompt, because the conversion asks the model to return every line of code as JSON-escaped strings and no output budget is set. A cap the model cannot meet would defeat the point of refusing up front, since the user would wait out a full conversion and get a JSON parse error from a truncated reply. A byte check runs before anything is read, so one enormous generated file cannot be loaded into memory first.

Dropping a folder onto the upload button is refused with a message. ng-zorro binds a drop handler on the button whatever its type, and in directory mode it hands over one file at a time with no path attached, so accepting a drop would stage a single arbitrary file and convert it as if it were the whole project.

Three things ride along:

  • The three import modal diagrams are normalized to one size. They were the same layout exported at three resolutions with uneven whitespace, so the tabs rendered at slightly different scales. Trimming each to its content and scaling to a common canvas touches two images from earlier PRs.
  • LICENSE-binary credits snippet_folder for the new diagram, and adds python_file_diagram.png to the Material Symbols paths. That second entry fills an attribution gap from [Notebook Migration] Support migrating Python files #8007, where the same icons were reused without extending the path list.
  • A final commit consolidates the folder caps and the webkitRelativePath parsing, which had spread across two files while the feature was built.

Demo video

https://drive.google.com/file/d/1KtI2FVWgOwoGCFZfnIWXLGurBcXQmmkz/view?usp=sharing

Any related issues, documentation, discussions?

Closes #8008
Parent-issue #4301

The reasoning for keeping the mapping and Jupyter panel on an input without cells was settled for scripts in #8489 and applies to folders unchanged.

The output budget argument behind the character cap applies just as much to a single .py and to a notebook, neither of which has a size cap today, and joining a project into one script is an easy way around the folder cap. That is worth its own issue rather than widening this one.

How was this PR tested?

Unit tests:

  • folder-assembly.spec.ts, new, 59 tests. File selection, ordering, assembly, the layout, the caps, entry point resolution and scoping. Two cases are worth naming. Directories sort by segment, so a sibling whose name sorts between a directory and its subdirectory (src, src-old, src/utils) cannot be rendered as the wrong parent. And an ambiguous entry point name resolves to null rather than to whichever file sorts first, because showing the wrong file is worse than falling back to the whole folder.
  • script-segmentation.spec.ts, 32 to 36. Forced cut points, including that out of range and non-integer boundaries are dropped rather than clamped.
  • migration-llm.spec.ts, 42 to 57. The layout is sent ahead of the code and never numbered, cuts land on every file banner, a range straddling a seam still maps to the cells on both sides, and the entry point scopes the notebook with a fallback when it cannot be resolved.
  • notebook-migration.service.spec.ts, 48 to 65. Reading a selection, the layout it produces, and each cap, including that the file count and byte checks run before any file is read.
  • notebook-import-modal.component.spec.ts, 27 to 39. The third tab, the directory picker, and the drop path modelled the way a real drop arrives: one file per call, each in its own one-element list, with no path.
  • user-workflow.component.spec.ts, 81 to 87. Dispatch on selection shape, and that a folder names its workflow after itself.

Manually tested end to end against a live model with a small multi-file project (a package with an entry point, two modules and a helpers-only module, plus non-Python files and a __pycache__).

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

Generated-by: Claude Code (Claude Opus 5)

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Sep 30, 2026
@github-actions

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.

@zyratlo

zyratlo commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

/request-review @mengw15

@github-actions
github-actions Bot requested a review from mengw15 September 30, 2026 04:08
@codecov-commenter

codecov-commenter commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.61%. Comparing base (e5c8511) to head (2baebb1).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8767      +/-   ##
============================================
+ Coverage     92.58%   92.61%   +0.02%     
  Complexity     4981     4981              
============================================
  Files          1244     1245       +1     
  Lines         52933    53154     +221     
  Branches       6550     6602      +52     
============================================
+ Hits          49006    49226     +220     
  Misses         2295     2295              
- Partials       1632     1633       +1     
Flag Coverage Δ *Carryforward flag
access-control-service 77.38% <ø> (ø) Carriedforward from e5c8511
agent-service 99.16% <ø> (ø) Carriedforward from e5c8511
amber 88.06% <ø> (ø) Carriedforward from e5c8511
computing-unit-managing-service 60.41% <ø> (ø) Carriedforward from e5c8511
config-service 87.37% <ø> (ø) Carriedforward from e5c8511
file-service 81.53% <ø> (ø) Carriedforward from e5c8511
frontend 96.58% <100.00%> (+0.02%) ⬆️
notebook-migration-service 83.73% <ø> (ø) Carriedforward from e5c8511
pyamber 98.50% <ø> (ø) Carriedforward from e5c8511
workflow-compiling-service 74.09% <ø> (ø) Carriedforward from e5c8511

*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 Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Line Changes Breakdown as of 2549826

Category Lines added Share code comment blank
Tests (*.spec.ts) 1,282 53.8% 945 92 245
Core logic (pure modules) 430 18.0% 206 180 44
Conversion + service 237 9.9% 142 78 17
Prompt text 232 9.7% 210 2 20
UI (modal + dashboard) 201 8.4% 143 45 13
Licensing 3 0.1% 3 0 0
Total 2,385 100% 1,649 397 339

@mengw15
mengw15 requested a balanced review from Copilot September 30, 2026 17:08

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

Review effort: Lite
Findings: 1 Medium severity · 3 Low severity

Open (4)
What changed in this PR

Adds support for migrating a local folder of Python files into a single workflow by assembling the folder into one numbered document (with per-file banner lines), prompting the LLM with folder-aware instructions, and deriving cells/mappings without changing downstream storage or the Jupyter panel mapping shape.

Changes:

  • Introduces folder assembly utilities (ordering, layout rendering, caps, entry point resolution) and wires them through notebook migration flow.
  • Extends script segmentation to support caller-forced cut points (used to prevent derived cells from spanning multiple files).
  • Updates the import modal + workflow creation path to accept folder selections, reject folder drag-drop, and attribute new diagram assets.
File Description
frontend/​src/​app/​workspace/​service/​notebook-migration/​script-segmentation.ts Adds SegmentOptions and forced boundaries support to prevent cells crossing caller-defined cut points.
frontend/​src/​app/​workspace/​service/​notebook-migration/​script-segmentation.spec.ts Updates helpers for new segmentScript signature and adds forced-boundary test coverage.
frontend/​src/​app/​workspace/​service/​notebook-migration/​notebook-migration.service.ts Adds folder parsing (caps + assembly) and unifies script/folder conversion via generateFromSource.
frontend/​src/​app/​workspace/​service/​notebook-migration/​notebook-migration.service.spec.ts Adds unit coverage for folder parsing/conversion service behavior and caps.
frontend/​src/​app/​workspace/​service/​notebook-migration/​migration-prompts.ts Adds folder-specific workflow + mapping prompts and a worked multi-file example.
frontend/​src/​app/​workspace/​service/​notebook-migration/​migration-llm.ts Adds folder conversion path (layout preamble, forced boundaries, entry point scoping) and refactors shared request/finish logic.
frontend/​src/​app/​workspace/​service/​notebook-migration/​migration-llm.spec.ts Adds unit tests ensuring folder prompting, numbering, forced cuts, and entry point scoping behavior.
frontend/​src/​app/​workspace/​service/​notebook-migration/​folder-assembly.ts New module for folder selection scoping, deterministic ordering, assembly with banners, caps, layout rendering, and entry point resolution/scoping.
frontend/​src/​app/​workspace/​service/​notebook-migration/​folder-assembly.spec.ts New, comprehensive unit tests for assembly, ordering, caps, layout, entry point resolution, and scoping.
frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.ts Adds folder tab behavior, selection summary for file/folder, and rejects folder drag-drop with a throttled notification.
frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.spec.ts Updates upload handler signature and adds tests for directory-picking and drop rejection.
frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.html Adds “Python Folder” tab, directory picker wiring, and unified selection summary display.
frontend/​src/​app/​dashboard/​component/​user/​user-workflow/​user-workflow.component.ts Dispatches generation based on selection shape (single file vs folder list) and names folder-derived workflows after the folder.
frontend/​src/​app/​dashboard/​component/​user/​user-workflow/​user-workflow.component.spec.ts Adds tests for folder selection flow, naming, parse errors, and timeout messaging.
frontend/​LICENSE-binary Updates third-party asset attribution to include the new folder diagram and missing prior attribution entry.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mengw15
mengw15 requested a balanced review from Copilot September 30, 2026 20:35

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.

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.

Copilot review overview

🔵 Needs a closer look

Entry-point matching can select the wrong case-colliding file, and the issue scope and required visual evidence remain unresolved.

Review effort: Balanced
Findings: None

Resolved since last review (4)
Previously missed (4)

In code that hasn't changed since last review

Medium severity Implement GitHub repository input or avoid closing #8008

frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.html:147

This adds only a local directory picker, but the linked #8008 explicitly scopes the feature to both local folders and GitHub repositories while this PR declares Closes #8008. Either implement the GitHub input path here or leave the remaining GitHub scope tracked instead of closing the issue.

Medium severity Require unique case-insensitive entry-point matches

frontend/​src/​app/​workspace/​service/​notebook-migration/​folder-assembly.ts:317

Case-insensitive matching can select the wrong entry point on case-sensitive filesystems. If a folder contains both A.py and a.py and the model reports A.PY, find silently chooses whichever file sorted first, contradicting the ambiguity fallback below. Preserve exact matches, but require a unique case-insensitive match.

Low severity Update callback documentation to reference the renamed method

frontend/​src/​app/​dashboard/​component/​user/​user-workflow/​user-workflow.component.ts:299

The changed callback now targets generateWorkflowFromSelection, but the method's doc comment still says it wires submission to the removed generateWorkflowFromFile. Update the comment so it does not point maintainers to a nonexistent method.

Low severity Add required before/after screenshots and interaction steps

frontend/​src/​app/​workspace/​component/​notebook-import-modal/​notebook-import-modal.component.html:154

This visible, interactive modal change lacks the side-by-side before/after screenshots or GIF and the click path/browser/viewport steps required by AGENTS.md:212-215. The linked demo video and generic end-to-end statement do not provide that required evidence; please add it to the PR description.

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

Read all 18 files at both heads, and read through your eight Copilot threads — the instanceof Blob pushback is the right call for the reason you gave, and locking the byte-message fix with a test that asserts no byte figure appears is a nice touch.

Ran the six specs locally on node 24.19.0 at 9cd269e28: 345 green. I also mutation-checked three invariants; two went red as expected and the third is nit 4 below.

One question on the cap, and three nits. Only the first wants an answer before merge, and it may already have one.

@zyratlo
zyratlo requested a review from mengw15 October 2, 2026 03:50

@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 October 5, 2026 23:07
@mengw15
mengw15 added this pull request to the merge queue Oct 5, 2026
Merged via the queue into apache:main with commit e2bd0cd Oct 5, 2026
24 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 Python folders from local files and GitHub

4 participants