zyratlo commented on code in PR #9578:
URL: https://github.com/apache/texera/pull/9578#discussion_r4656166551
##########
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:
Fixed in
[a64660e](https://github.com/apache/texera/pull/9578/commits/a64660e5f06003b8c99912344787dc6119e431b4).
Each field is now trimmed and lowercased before the first non empty one is
chosen, so a blank or whitespace only kernelspec.language falls back to
language_info.name, and a notebook is treated as declaring nothing only when
both are blank. Added tests for the empty and whitespace cases and for both
fields blank.
--
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]