HyukjinKwon opened a new pull request, #898:
URL: https://github.com/apache/spark-connect-rust/pull/898
### What changes were proposed in this pull request?
The `SparkConnectClient` of the Python client (`pyspark-client-rust`) kept
its attributes in the Rust transport, behind Python subclasses that kept the
two in step, and a kept `conf` or `client` held its session open. PySpark's
client holds plain attributes, which its requests read when they are built, and
does not keep the session object. This closes the differences that
`dev/parity/known-differences.md` listed for them:
- The client's `thread_local`, its set of tags and its lists of user context
extensions are PySpark's plain `threading.local`, set and lists. So are
`global_user_context_extensions`, `_session_id`, `_user_id` and `_closed`,
plain attributes that a set changes for the requests.
- The transport reads them on the calling thread when a call starts its
requests, and when a finalizer sends its request.
- A `copy.copy` of a client sends its own attributes, also at once with
its client on another thread.
- A call that runs during another call of the same thread, of a progress
handler or a finalizer, sends its own client's attributes. The outer call then
reads its client's attributes again, as they are then, as PySpark's requests
do. All per-thread state is keyed by the thread that waits for the call, so the
interrupt of a Ctrl-C carries the extensions of the thread, and nothing more is
requested once a signal interrupted the wait.
- A kept `conf` or `client` does not keep its session open. Once the program
dropped the session and the objects that hold it, they raise
`NO_ACTIVE_SESSION`, as PySpark's do once the session's `__del__` closed the
client, and the exit sends nothing for the session.
- `channelBuilder(...)` takes any object, and the session fails, when it is
made, of the errors of PySpark's client.
- A failed `CloneSession` asks the server for nothing more, as PySpark's
`clone`: neither the details of its error nor the configs of its stack trace.
The response of a clone is not checked.
### Why are the changes needed?
To close these differences from PySpark (the known-differences review).
### Does this PR introduce _any_ user-facing change?
Yes: the client and session behave as PySpark's above. What remains is
documented in `docs/compatibility.md` and `dev/parity/known-differences.md`.
The main case: the `next()` of a copy's execution iterator reads nothing of the
client, so its requests carry the context of the thread's last call. The core
crates gain doc-hidden items for the Python client, which the 4.4 Rust
migration notes list.
### How was this patch tested?
- New tests in `python/tests/test_dropin_offline.py`,
`test_exit_cleanup_offline.py` and `test_dropin_e2e.py`, and in the core
crates. The mock server gained knobs for them. Each round's new tests fail
without its change.
- Four rounds of an independent review, which compared the requests of the
drop-in and of PySpark 4.3.0 through a recording proxy. It covered:
- the attributes of clients and their copies, threads and thread-inherited
targets;
- nested calls of progress handlers and finalizers;
- Ctrl-C;
- clones and new sessions of other users;
- the lifetimes of sessions, confs and clients;
- leaks of the entries of 9000 threads, and the performance of small calls.
Every finding was fixed or documented.
- The core tests (release and debug), wasm, clippy, rustdoc, the stubs, the
offline suite in sorted order and under coverage, and the live e2e with and
without protobuf.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code
This pull request and its description were written by Isaac.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]