Skip to content

Update to session builder API to enable context, config, or runtime sharing.#862

Open
hoytak wants to merge 1 commit into
mainfrom
hoytak/260603-session-context-sharing
Open

Update to session builder API to enable context, config, or runtime sharing.#862
hoytak wants to merge 1 commit into
mainfrom
hoytak/260603-session-context-sharing

Conversation

@hoytak

@hoytak hoytak commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

The XetContext object is designed partly to enable control over shared runtime, config, and common resources between sessions, but this isn't fully reflected in the XetSessionBuilder API. This PR simply adds this API polish to enable this.


Note

Medium Risk
Breaking API removal (new_with_config, with_tokio_handle) and changed config() return type affect integrators; context/config precedence and shared common state can surprise callers tuning concurrency via config overrides.

Overview
XetSessionBuilder is refactored to a consistent with_* API: new_with_config is removed (use new().with_config(...)), with_tokio_handle is replaced by with_runtime(Arc<XetRuntime>), and with_context lets new sessions reuse an existing XetContext so runtime, config, and common (including shard-file manager caches) are shared instead of re-scanning the shard cache on every session.

XetSession gains context(), runtime(), and config() now returns Arc<XetConfig>. Build order: explicit context wins ( with_runtime ignored ); with_config overrides the context’s config via XetContext::with_new_config while keeping shared common (construction-time limits in common are not rebuilt).

XetContext constructors take impl Into<Arc<XetConfig>>; with_new_config is added. XetContext / XetRuntime are re-exported from xet::xet_session. Python hf_xet and docs/tests are updated accordingly; an api_changes note documents the migration.

Reviewed by Cursor Bugbot for commit ec2cc73. Bugbot is set up for automated code reviews on this repo. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant