The GitHub Actions job "Required Checks" on 
texera.git/gh-readonly-queue/main/pr-9240-fddc4303e8f739fe2a9e707a5d176e5032191753
 has failed.
Run started by GitHub user aglinxinyuan (triggered by aglinxinyuan).

Head commit for run:
f5bcd0d5de72106700132ee0189ca6886d06f119 / Kary Zheng 
<[email protected]>
feat: export Python scripts that import their helpers from texera-helpers 
(#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 module, `texera_helpers`, and the export
downloads as a zip that holds the module next to the script.

- `texera-helpers/` holds the module. Its `texera_helpers/__init__.py`
is generated from the helper blocks the operators already declare,
listed in `StandaloneHelpers.moduleHelpers`. `StandaloneHelpersSpec`
fails when the file is stale, and rewrites it with
`TEXERA_HELPERS_WRITE=1`.
- The translator writes `from texera_helpers import ...` with only the
names the script calls. It refuses an operator whose helper block is not
in the module, 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_helpers.py`, so the unzipped folder runs with `python script.py`
and nothing installed.
- Copying the script still works. When the script imports from the
module, the copy notice says it needs the `texera_helpers.py` in the zip
download next to it.
- A source whose file name matches a file in the zip, or another
source's, is read under a numbered name such as `data-2.csv`. Names are
compared ignoring case, since Windows and macOS treat `Script.py` and
`script.py` as one file. The modal says which file to save under which
name.

#### Why a zip and not a PyPI package

The proposal was to publish the helpers as a PyPI package, so a script
could start with `pip install texera-helpers`. That needs an Apache
release to publish from, a PPMC vote on it, and a decision on the
package name, and every exported script would need the release that
matches its Texera version.

The zip needs none of that. The module comes from the same Texera that
wrote the script, so the two always match, and a user installs nothing
for it. If the project later publishes the package, the script keeps the
same `from texera_helpers import ...` line and only the zip step goes
away.

### What it looks like

The export modal on a workflow whose two CSV scans read files with the
same name from two datasets. The script imports its helpers from the
module, the modal says to save the second file as
`canonical_fixture-2.csv`, and the button left of copy downloads the
zip.

<img width="1727" height="1086" alt="Screenshot 2026-11-17 at 4 53
09 PM"
src="https://github.com/user-attachments/assets/0d083e9f-df65-4d51-a975-d210dc3a4248";
/>

### Any related issues, documentation, discussions?

Closes #9525. The layout is discussed in #9368, where the zip (option B)
was preferred. The module was named `texera_support` until that
discussion asked for a clearer name.

The verify harness from #8325 runs the exported scripts. Once it lands,
its `StandaloneRunner` and `TranslatedPlanRunSpec` need `PYTHONPATH` set
to `texera-helpers`, and that change will be added here.

### How was this PR tested?

On this branch, merged with main:

- `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, that an operator whose helper the module lacks is refused, and
that a source is renamed off a file in the zip or another source's name,
ignoring case, with the renames reported.
- `WorkflowToPythonResourceSpec` checks that the module comes back with
a script that imports from it, and not with one that does not, and that
the renamed sources come back with the script.
- `menu.component.spec.ts` checks the zip holds the script and the
module, and only the script when nothing is imported, that the copy
notice names the module when the script imports one, and that it keeps
the renamed sources.

Before the rename, on the fork's integration branch, which has the
verify harness: `OperatorBehaviorSpec` ran every operator's exported
script with the module on `PYTHONPATH`, 151 passed and 2 ignored. By
hand, a downloaded zip, unzipped, ran 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)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Xinyuan Lin <[email protected]>

Report URL: https://github.com/apache/texera/actions/runs/44249755621

With regards,
GitHub Actions via GitBox

Reply via email to