Copilot commented on code in PR #9578:
URL: https://github.com/apache/texera/pull/9578#discussion_r4649147901
##########
frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts:
##########
@@ -76,20 +78,61 @@ import { FiltersInstructionsComponent } from
"../filters-instructions/filters-in
import { NzSelectComponent } from "ng-zorro-antd/select";
import { FormsModule } from "@angular/forms";
-// The single-file input each language accepts besides .ipynb.
-const SCRIPT_INPUTS: Record<MigrationLanguage, { name: string; extension:
string; uploadHint: string }> = {
+// What each language accepts, and where the modal takes it, so a mismatch can
name the right place.
+const MIGRATION_INPUTS: Record<
+ MigrationLanguage,
+ {
+ name: string;
+ article: string;
+ // As a notebook's kernelspec.language or language_info.name gives it,
lowercased.
+ kernelLanguage: string;
+ extension: string;
+ uploadHint: string;
+ notebookType: string;
+ fileTab: string;
+ folderTab: string;
+ }
+> = {
python: {
name: "Python",
+ article: "a",
+ kernelLanguage: "python",
extension: "py",
uploadHint: "Please upload a Jupyter Notebook (.ipynb) or a Python (.py)
file.",
+ notebookType: "Python Notebook",
+ fileTab: "Python File",
+ folderTab: "Python Folder",
},
r: {
name: "R",
+ article: "an",
+ kernelLanguage: "r",
extension: "R",
uploadHint: "Please upload an R Jupyter Notebook (.ipynb) or an R (.R)
file.",
+ notebookType: "R Notebook",
+ fileTab: "R File",
+ folderTab: "R Folder",
},
};
+const MIGRATION_LANGUAGES = Object.keys(MIGRATION_INPUTS) as
MigrationLanguage[];
+
+const MIGRATION_ERROR_DURATION_MS = 8000;
+
+/** The language a notebook declares, lowercased. Undefined when it declares
none. */
+function notebookKernelLanguage(notebook: Notebook): string | undefined {
+ const declared = notebook.metadata?.["kernelspec"]?.language ??
notebook.metadata?.["language_info"]?.name;
+ return declared ? String(declared).trim().toLowerCase() : undefined;
Review Comment:
An empty `kernelspec.language` suppresses the `language_info.name` fallback:
with `language: ""` and `language_info.name: "R"`, this returns `undefined`, so
the R notebook still reaches the Python model prompts. A whitespace-only
declaration instead returns `""` and produces an unsupported-kernel error, even
when the fallback says Python or R. Normalize each field before choosing the
first non-empty value, and return `undefined` only when neither declares a
language.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]