zyratlo commented on code in PR #8963:
URL: https://github.com/apache/texera/pull/8963#discussion_r4557193911


##########
frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts:
##########
@@ -76,6 +76,20 @@ 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 }> = {
+  python: {
+    name: "Python",
+    extension: "py",
+    uploadHint: "Please upload a Jupyter Notebook (.ipynb) or a Python (.py) 
file.",
+  },
+  r: {
+    name: "R",
+    extension: "R",
+    uploadHint: "Please upload an R Jupyter Notebook (.ipynb) or an R (.R) 
file.",

Review Comment:
   The extension check is case insensitive, the same as for Python, where .PY 
is accepted and the messages say .py. The messages name the conventional .R, 
and a lowercase .r file is accepted without ever seeing the hint. Leaving it as 
is.



##########
frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts:
##########
@@ -381,19 +392,26 @@ export class UserWorkflowComponent implements 
AfterViewInit, OnDestroy {
     }
   }
 
-  /** Read and convert a .py. The notebook comes back derived, since the 
upload had no cells. */
-  private async generateFromScript(file: NzUploadFile, model: string): 
Promise<GeneratedWorkflowContent | null> {
+  /** Read and convert a script. The notebook comes back derived, since the 
upload had no cells. */
+  private async generateFromScript(
+    file: NzUploadFile,
+    model: string,
+    language: MigrationLanguage
+  ): Promise<GeneratedWorkflowContent | null> {
+    const { name, extension } = SCRIPT_INPUTS[language];
     let scriptSource: string;
     try {
       scriptSource = await this.notebookMigrationService.parseScriptFile(file 
as unknown as File);
     } catch (error) {
-      this.notificationService.error("Failed to read the Python file. Please 
upload a valid, non-empty .py file.");
-      console.error("Python file read failed:", error);
+      this.notificationService.error(
+        `Failed to read the ${name} file. Please upload a valid, non-empty 
.${extension} file.`
+      );

Review Comment:
   The extension check is case insensitive, the same as for Python, where .PY 
is accepted and the messages say .py. The messages name the conventional .R, 
and a lowercase .r file is accepted without ever seeing the hint. Leaving it as 
is.



-- 
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]

Reply via email to