kz930 opened a new pull request, #9240: URL: https://github.com/apache/texera/pull/9240
### What changes were proposed in this PR? An exported Python script no longer defines the helpers it calls. It imports them from a new package, `texera-support`, and the export downloads as a zip that holds the package's module next to the script. - `texera-support/` holds the package. Its `texera_support/__init__.py` is generated from the helper blocks the operators already declare, listed in `StandaloneHelpers.packaged`. `StandaloneHelpersSpec` fails when the file is stale, and rewrites it with `TEXERA_SUPPORT_WRITE=1`. - The translator writes `from texera_support import ...` with only the names the script calls. It refuses an operator whose helper block is not in the package, so a new helper cannot be left out. - The export endpoint returns the module with the script when the script imports from it. - The export modal gets a download button. The zip holds `script.py` and `texera_support.py`, so the unzipped folder runs with `python script.py` and nothing installed. `pip install ./texera-support` makes the package importable from anywhere. <!-- screenshot: texera-support-export-modal.png --> ### Any related issues, documentation, discussions? Related to #8325. This stays a draft until every PR in #8325 has merged. Six of the eight helper blocks `StandaloneHelpers.packaged` lists come from those PRs, so this branch does not compile on main until then. The verify harness from #8325 runs the exported scripts. Once it lands, its `StandaloneRunner` and `TranslatedPlanRunSpec` need `PYTHONPATH` set to `texera-support`, and that change will be added here. Publishing the package to PyPI is not part of this PR. ### How was this PR tested? Run on the fork's integration branch, which has the whole #8325 series: - `StandaloneHelpersSpec` checks the generated module against the helper blocks. - `WorkflowToPythonTranslatorSpec` checks that a helper is imported rather than defined, that a name in a comment or a string is not imported, and that an operator with an unpackaged helper is refused. - `WorkflowToPythonResourceSpec` checks that the module comes back with a script that imports from it, and not with one that does not. - `OperatorBehaviorSpec` runs every operator's exported script with the package on `PYTHONPATH`: 151 passed, 2 ignored. - `menu.component.spec.ts` checks the zip holds the script and the module, and only the script when nothing is imported. - By hand: a downloaded zip, unzipped, runs with `python script.py`, also from another directory. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5) 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
