kz930 commented on code in PR #9240:
URL: https://github.com/apache/texera/pull/9240#discussion_r4596742023
##########
frontend/src/app/workspace/component/menu/menu.component.ts:
##########
@@ -803,12 +806,34 @@ export class MenuComponent implements OnInit, OnDestroy {
try {
await navigator.clipboard.writeText(this.pythonCodeForModal);
- this.notificationService.success("Python script copied to clipboard");
+ // The copied script imports its helpers, so it does not run without the
module.
+ this.notificationService.success(
+ this.pythonHelpersModuleForModal
+ ? "Python script copied to clipboard. It needs the texera_helpers.py
in the zip download next to it."
+ : "Python script copied to clipboard"
+ );
} catch (error) {
this.notificationService.error("Failed to copy Python script");
}
}
+ /**
+ * The script as a zip, with the `texera_helpers.py` it imports beside it:
Python finds a
+ * module in the script's own directory, so the unzipped folder runs with
nothing installed.
+ */
+ public async downloadPythonZip(): Promise<void> {
+ if (!this.pythonCodeForModal) {
+ return;
+ }
+ const zip = new JSZip();
+ zip.file("script.py", this.pythonCodeForModal);
Review Comment:
Source names are assigned in the translator, so the fix is there:
`script.py` and `texera_helpers.py` now count as taken, and a source by either
name is read as `texera_helpers-2.py` / `script-2.py`, with a test in
`WorkflowToPythonTranslatorSpec`.
--
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]