You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "DanielLeens (via GitHub)" <gi...@apache.org> on 2026/07/04 11:37:03 UTC

[PR] [Feature][Connector-V2] Add PythonSource connector [seatunnel]

DanielLeens opened a new pull request, #11337:
URL: https://github.com/apache/seatunnel/pull/11337

   ### Purpose of this pull request
   
   This pull request adds a new `PythonSource` connector that lets SeaTunnel launch a user-provided Python script as a bounded source. The Phase 1 MVP focuses on a simple and explicit contract:
   
   - SeaTunnel starts one Python process via `ProcessBuilder`
   - SeaTunnel writes `python.script.config` as JSON to the first stdin line
   - The Python script prints one record per stdout line
   - SeaTunnel parses stdout lines with `file_format_type = text` and `field_delimiter`
   
   It also wires the new connector into plugin registration, distribution packaging, and EN/ZH connector docs.
   
   Resolves #10182
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Users can now configure a new `PythonSource` source connector and implement custom batch data extraction logic in Python scripts without writing a Java connector first.
   
   ### How was this patch tested?
   
   Module-scoped verification completed:
   
   1. `./mvnw -pl seatunnel-connectors-v2/connector-python test -DskipITs -DskipUTs=false`
   2. `./mvnw -pl seatunnel-connectors-v2/connector-python package -DskipTests`
   
   Real runtime verification included in tests:
   
   - The connector tests launch a real Python subprocess (`python3` or `python`)
   - Verify stdin JSON config handoff to the script
   - Verify stdout text rows are parsed into `SeaTunnelRow` by schema order
   - Verify non-zero Python exits fail the reader with recent stderr context
   
   Not fully revalidated in this round:
   
   - Full reactor build with `-am` was attempted locally, but the current `upstream/dev` baseline failed earlier in `seatunnel-config-shade` with unrelated `com.typesafe.config` compilation errors before reaching this connector’s full-chain packaging path
   - `seatunnel-engine-ui` was not built, because this change does not touch UI code and does not depend on UI artifacts
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [x] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [x] If you are contributing the connector code, please check that the following files are updated:
     1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
   * [ ] Update the [`release-note`](https://github.com/apache/seatunnel/blob/dev/release-note.md).
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2] Add PythonSource connector [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #11337:
URL: https://github.com/apache/seatunnel/pull/11337#issuecomment-4968427814

   Rechecked the same unchanged head `b9f53b50b0a1` after the CI / merge-gate fact changed.
   
   ## Runtime path rechecked
   ```text
   PythonSourceReader.internalPollNext(...)
     -> stdoutReader.readLine() loop
     -> only returns after stdout reaches EOF
     -> waitForProcessExit()
   ```
   
   ## Merge conclusion
   ### Conclusion: source blocker cleared from Daniel's side
   
   1. Blocking items
   - None from Daniel's source review on this unchanged head.
   
   2. Current gate
   - The current CI signal is now green: https://github.com/apache/seatunnel/actions/runs/28933119194/job/85836817793
   - Daniel only has `READ` permission on this repository, so GitHub may still show earlier review state and a write-capable maintainer may still need to handle the final approval / dismissal step.
   
   I do not see a reopened code-side blocker from Daniel on the current head.
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2] Add PythonSource connector [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #11337:
URL: https://github.com/apache/seatunnel/pull/11337#issuecomment-5014639143

   Thanks @SEZ9. I addressed the review feedback on the current head `09ff7f6086`.
   
   Key updates:
   - Rebuilt the PR on the current review base and removed the unrelated `FileMapStore.java` / `FileMapStoreTest.java` changes. The PR now contains exactly 28 Python connector, registration, documentation, and E2E files.
   - Reworked `PythonSourceReader` around asynchronous stdout/stderr pumps and bounded queues so `pollNext` no longer blocks indefinitely under the source checkpoint lock, and `close()` can terminate the direct Python process and unblock pending reads.
   - Added lifecycle regression coverage for non-terminating scripts, delayed output, cancellation/close, non-zero exits, invalid rows, working-directory behavior, and inherited stderr pipes.
   - Added the connector E2E module and label-scope registration.
   - Renamed the public plugin identity to `Python` and the option to `python.working.directory` before release.
   - Added explicit arbitrary-command-execution/security guidance to both English and Chinese docs and aligned the connector changelog/docs wording.
   
   Local validation:
   - `spotless:apply`: passed.
   - Connector dependency closure install with JDK 8: passed.
   - `PythonSourceFactoryTest` + `PythonSourceTest`: 17 tests, 0 failures, 0 errors, 0 skipped.
   - The focused Python E2E case was also validated locally in the implementation worktree.
   
   The new Build is queued on this exact head. Could you please re-review when convenient?
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2] Add PythonSource connector [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #11337:
URL: https://github.com/apache/seatunnel/pull/11337#issuecomment-5319296745

   Run `32041891318` on `d7ca6586` came back red; I read every failing job log before acting, and the failures split into two categories:
   
   - **Infra, not the PR**: `Dead links` 404'd on github.com blob URLs that demonstrably exist (`plugin-mapping.properties`, `seatunnel-dist/pom.xml` on dev), and all three `updated-modules-integration-test` failures died in `actions/setup-java` download with 429/503 before any test ran — GitHub was throttling/degraded in that window. Nothing to fix on our side; the new run retries these.
   - **Real test-timing flake, now fixed**: `unit-test (11, windows-latest)` failed `testCloseInterruptsInheritedStdoutWait` and `testConcurrentCloseStopsBufferedBatchEmission` — both on 5-second budgets that gate real python interpreter startup, which a loaded Windows runner can exceed on cold start alone. `f7dd2917b3` widens both waits to the 15s budget `pollUntilIOException` already uses for the identical arming wait in the same file. No assertion is changed or weakened — the tests prove the same conditions, they just stop racing a runner's process-spawn latency. Production code remains byte-identical to the green head `32ed4dfbba`.
   
   Build is running on the new head.


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2] Add PythonSource connector [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo merged PR #11337:
URL: https://github.com/apache/seatunnel/pull/11337


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2] Add PythonSource connector [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #11337:
URL: https://github.com/apache/seatunnel/pull/11337#issuecomment-4914114769

   Thanks for the update. I re-reviewed the latest head `b9f53b50b0` from the connector registration path down to the Python reader lifecycle.
   
   The good news first: the unrelated MySQL CDC E2E disabling change from my previous round is no longer part of the current diff, so that earlier blocker is closed on the latest head.
   
   Current runtime path rechecked:
   ```text
   Job config uses source = PythonSource
     -> PythonSourceFactory.createSource(...)
     -> PythonSource.createReader(...)
     -> PythonSourceReader.open()
        -> start Python process
        -> write `python.script.config` to stdin
     -> PythonSourceReader.internalPollNext(...)
        -> stdoutReader.readLine() loop
        -> deserialize each line to SeaTunnelRow
        -> waitForProcessExit()
   ```
   
   I still see one blocking item on the current revision:
   
   1. `PythonSourceReader.internalPollNext(...)` can still block indefinitely until the Python process closes stdout.
   - Location: `seatunnel-connectors-v2/connector-python/src/main/java/org/apache/seatunnel/connectors/seatunnel/python/source/PythonSourceReader.java`
   - Why this is still real: the reader still drains the whole stdout stream inside a single `pollNext` call and then waits for process exit. If the user script hangs, waits on an external service, writes slowly without closing stdout, or simply never exits, the SeaTunnel reader thread stays blocked in the main source path.
   - Risk: the job can appear hung instead of failing with a clear timeout/cancellation boundary, and one stuck script can pin the source task indefinitely.
   - Best fix: add an explicit timeout / cancellation boundary around the bounded Python execution contract, or move stdout draining to an async pump plus bounded queue so `pollNext` can periodically return and observe task cancellation/process health.
   
   Tests still do not cover the long-running-script / stdout-not-closed case, which is the key lifecycle boundary here.
   
   ### Merge conclusion: fix before merge
   Blocking items:
   1. Close the indefinite blocking gap in `internalPollNext(...)`.
   
   Once that lifecycle boundary is fixed on the latest head, I’m happy to re-review again.


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2] Add PythonSource connector [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #11337:
URL: https://github.com/apache/seatunnel/pull/11337#issuecomment-4944509808

   Thanks @SEZ9. I rechecked the same head `b9f53b50b0a1` again after your review.
   
   I agree that the unrelated `FileMapStore.java` and `FileMapStoreTest.java` engine-server changes should not stay bundled in this connector PR. Those files are outside the PythonSource connector path and should be split into a dedicated Zeta PR instead of landing under a `Connector-V2` review thread.
   
   My earlier Python reader lifecycle blocker also still stands on this unchanged head:
   ```text
   PythonSourceReader.internalPollNext(...)
     -> stdoutReader.readLine() loop
     -> only returns after stdout reaches EOF
     -> waitForProcessExit()
   ```
   So a long-running or non-terminating script can still keep the source task blocked in the main poll path until the child process exits.
   
   So from Daniel's side the current head still needs a code update before merge:
   1. split the unrelated engine-server files into a separate PR
   2. close the indefinite-blocking gap in `PythonSourceReader.internalPollNext(...)`
   
   The green Build is helpful, but it is not the remaining gate yet on this revision.
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2] Add PythonSource connector [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on PR #11337:
URL: https://github.com/apache/seatunnel/pull/11337#issuecomment-5317291083

   Pushed `d7ca6586d6` addressing the one remaining before-merge item from the 2026-08-16 review round (Issue 4): the Limitations section in both EN and ZH docs now states explicitly that the source keeps no resumable offset — a failure recovery or restart re-executes the script from the beginning and re-emits rows already delivered downstream, so sinks must be idempotent or the job must tolerate duplicates.
   
   This is a doc-only commit — no code changed; `PythonSourceReader.java` and every other production file are byte-identical to the reviewed head `32ed4dfbba`. The remaining items from that review (descendant-process termination, bounded line length, bounded close wait, and the low-severity cleanups) stay tracked as Phase 2 follow-ups per its own scoping.
   
   Build is running on the new head; once it completes, the PR is ready for maintainer review.


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org