Skip to content

Commit ca3eded

Browse files
committed
Experimental(refactor[chain]): rename package to chain and align names with ecosystem conventions
why: A study of naming across django, sqlalchemy, polars, datafusion, ibis, dask, mypy, ruff, celery, prefect, dagster, requests, and pydantic surfaced clearer conventions. `chain` is the recognized name for "compose an ordered sequence that runs together" (celery/airflow chain(), itertools, langchain). `aio` is never a library's own async-API name in that corpus (only third-party driver files). `adapters` universally means GoF interface/value conversion, not a live-backend bridge -- the loved words there are connection/engine/executor. what: - Rename libtmux._experimental.chainable_commands -> libtmux._experimental.chain - Rename aio.py -> _async.py and adapters.py -> _connection.py - Rename SessionPlanRunner/AsyncSessionPlanRunner -> SessionPlanExecutor/AsyncSessionPlanExecutor (dagster Executor.execute(plan), django MigrationExecutor, stdlib concurrent.futures.Executor precedent) - Keep ir.py / plan.py / batch.py -- idiomatic and loved per the same study (mypy mypyc/ir, polars plans/ir; datafusion LogicalPlan; dask batch) - Update all imports, tests, autodoc pages, toctree, and examples accordingly
1 parent 99a1dc3 commit ca3eded

18 files changed

Lines changed: 104 additions & 104 deletions

docs/experiment/api/libtmux._experimental.chainable_commands.aio.md renamed to docs/experiment/api/libtmux._experimental.chain._async.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Async - `libtmux._experimental.chainable_commands.aio`
1+
# Async - `libtmux._experimental.chain._async`
22

33
:::{warning}
44
Experimental. This API is **not** covered by version policies and can break or
55
be removed between minor versions.
66
:::
77

88
```{eval-rst}
9-
.. automodule:: libtmux._experimental.chainable_commands.aio
9+
.. automodule:: libtmux._experimental.chain._async
1010
:members:
1111
:undoc-members:
1212
:show-inheritance:

docs/experiment/api/libtmux._experimental.chainable_commands.adapters.md renamed to docs/experiment/api/libtmux._experimental.chain._connection.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Connecting to live tmux sessions - `libtmux._experimental.chainable_commands.adapters`
1+
# Connecting to live tmux sessions - `libtmux._experimental.chain._connection`
22

33
:::{warning}
44
Experimental. This API is **not** covered by version policies and can break or
55
be removed between minor versions.
66
:::
77

88
```{eval-rst}
9-
.. automodule:: libtmux._experimental.chainable_commands.adapters
9+
.. automodule:: libtmux._experimental.chain._connection
1010
:members:
1111
:undoc-members:
1212
:show-inheritance:

docs/experiment/api/libtmux._experimental.chainable_commands.plan.md renamed to docs/experiment/api/libtmux._experimental.chain.batch.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Expressions - `libtmux._experimental.chainable_commands.plan`
1+
# Chainability - `libtmux._experimental.chain.batch`
22

33
:::{warning}
44
Experimental. This API is **not** covered by version policies and can break or
55
be removed between minor versions.
66
:::
77

88
```{eval-rst}
9-
.. automodule:: libtmux._experimental.chainable_commands.plan
9+
.. automodule:: libtmux._experimental.chain.batch
1010
:members:
1111
:undoc-members:
1212
:show-inheritance:

docs/experiment/api/libtmux._experimental.chainable_commands.batch.md renamed to docs/experiment/api/libtmux._experimental.chain.ir.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Chainability - `libtmux._experimental.chainable_commands.batch`
1+
# Intermediate representation - `libtmux._experimental.chain.ir`
22

33
:::{warning}
44
Experimental. This API is **not** covered by version policies and can break or
55
be removed between minor versions.
66
:::
77

88
```{eval-rst}
9-
.. automodule:: libtmux._experimental.chainable_commands.batch
9+
.. automodule:: libtmux._experimental.chain.ir
1010
:members:
1111
:undoc-members:
1212
:show-inheritance:

docs/experiment/api/libtmux._experimental.chainable_commands.ir.md renamed to docs/experiment/api/libtmux._experimental.chain.plan.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Intermediate representation - `libtmux._experimental.chainable_commands.ir`
1+
# Expressions - `libtmux._experimental.chain.plan`
22

33
:::{warning}
44
Experimental. This API is **not** covered by version policies and can break or
55
be removed between minor versions.
66
:::
77

88
```{eval-rst}
9-
.. automodule:: libtmux._experimental.chainable_commands.ir
9+
.. automodule:: libtmux._experimental.chain.plan
1010
:members:
1111
:undoc-members:
1212
:show-inheritance:

docs/experiment/index.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,70 +14,70 @@ please [file an issue](https://github.com/tmux-python/libtmux/issues).
1414

1515
## Chainable commands
1616

17-
`libtmux._experimental.chainable_commands` lets you build an ordered sequence of
17+
`libtmux._experimental.chain` lets you build an ordered sequence of
1818
typed tmux commands that runs as **one** native `tmux ... \; ...` invocation,
1919
instead of one subprocess per command. The pieces layer up, so you can reach for
2020
as much or as little as you need:
2121

2222
- **Intermediate representation** -- the typed argv layer beneath everything: a
23-
{class}`~libtmux._experimental.chainable_commands.ir.CommandCall` is a single
23+
{class}`~libtmux._experimental.chain.ir.CommandCall` is a single
2424
command, and a
25-
{class}`~libtmux._experimental.chainable_commands.ir.CommandSequence` is an
25+
{class}`~libtmux._experimental.chain.ir.CommandSequence` is an
2626
ordered group that renders to one argv (with standalone `;` separators) and
2727
dispatches once.
2828
- **Expressions** -- compose commands from a lazy, target-safe pane query. A
29-
{class}`~libtmux._experimental.chainable_commands.plan.PaneQuery` resolves
29+
{class}`~libtmux._experimental.chain.plan.PaneQuery` resolves
3030
against a pure
31-
{class}`~libtmux._experimental.chainable_commands.plan.TmuxSnapshot`, maps each
31+
{class}`~libtmux._experimental.chain.plan.TmuxSnapshot`, maps each
3232
typed row to commands, and compiles to one sequence -- so you can build and
3333
assert the result without touching tmux.
34-
- **Async** -- {mod}`~libtmux._experimental.chainable_commands.aio` mirrors the
34+
- **Async** -- {mod}`~libtmux._experimental.chain._async` mirrors the
3535
same query and dispatch API with `await`, while command construction stays
3636
synchronous and one expression still compiles to one invocation.
3737
- **Connecting to live tmux sessions** -- the bridge to a real server:
38-
{func}`~libtmux._experimental.chainable_commands.adapters.snapshot_from_session`
38+
{func}`~libtmux._experimental.chain._connection.snapshot_from_session`
3939
reads live panes, and
40-
{class}`~libtmux._experimental.chainable_commands.adapters.SessionPlanRunner`
40+
{class}`~libtmux._experimental.chain._connection.SessionPlanExecutor`
4141
(with its async counterpart
42-
{class}`~libtmux._experimental.chainable_commands.adapters.AsyncSessionPlanRunner`)
42+
{class}`~libtmux._experimental.chain._connection.AsyncSessionPlanExecutor`)
4343
resolves and runs an expression against a live {class}`~libtmux.Session` in one
4444
invocation.
4545
- **Chainability** --
46-
{mod}`~libtmux._experimental.chainable_commands.batch` decides which commands
46+
{mod}`~libtmux._experimental.chain.batch` decides which commands
4747
may share one invocation: the static
48-
{attr}`~libtmux._experimental.chainable_commands.ir.CommandSpec.chainable`
48+
{attr}`~libtmux._experimental.chain.ir.CommandSpec.chainable`
4949
flag, plus a deferred result that won't hand back output until the chain has
5050
run.
5151

5252
::::{grid} 1 2 2 2
5353
:gutter: 2 2 3 3
5454

5555
:::{grid-item-card} Intermediate representation
56-
:link: api/libtmux._experimental.chainable_commands.ir
56+
:link: api/libtmux._experimental.chain.ir
5757
:link-type: doc
5858
The typed argv layer: `CommandCall`, `CommandSequence`, `CommandSpec`.
5959
:::
6060

6161
:::{grid-item-card} Expressions
62-
:link: api/libtmux._experimental.chainable_commands.plan
62+
:link: api/libtmux._experimental.chain.plan
6363
:link-type: doc
6464
Build commands from a lazy, target-safe pane query.
6565
:::
6666

6767
:::{grid-item-card} Async
68-
:link: api/libtmux._experimental.chainable_commands.aio
68+
:link: api/libtmux._experimental.chain._async
6969
:link-type: doc
7070
The same query and dispatch API, with `await`.
7171
:::
7272

7373
:::{grid-item-card} Connecting to live tmux sessions
74-
:link: api/libtmux._experimental.chainable_commands.adapters
74+
:link: api/libtmux._experimental.chain._connection
7575
:link-type: doc
7676
Read live panes and run an expression against a real session.
7777
:::
7878

7979
:::{grid-item-card} Chainability
80-
:link: api/libtmux._experimental.chainable_commands.batch
80+
:link: api/libtmux._experimental.chain.batch
8181
:link-type: doc
8282
Which commands may share one invocation.
8383
:::
@@ -89,7 +89,7 @@ Which commands may share one invocation.
8989
Compose typed calls and dispatch them as one tmux invocation:
9090

9191
```python
92-
>>> from libtmux._experimental.chainable_commands.ir import CommandCall
92+
>>> from libtmux._experimental.chain.ir import CommandCall
9393
>>> sequence = (
9494
... CommandCall("set-option", ("-g", "@cc_docs_a", "1"))
9595
... >> CommandCall("set-option", ("-g", "@cc_docs_b", "2"))
@@ -106,7 +106,7 @@ Build an expression from a query and compile it to one sequence -- pure, no tmux
106106
required:
107107

108108
```python
109-
>>> from libtmux._experimental.chainable_commands.plan import (
109+
>>> from libtmux._experimental.chain.plan import (
110110
... PaneRef,
111111
... PaneTarget,
112112
... SessionTarget,
@@ -133,12 +133,12 @@ required:
133133
```
134134

135135
Against a live server, run the same expression in one invocation with
136-
{class}`~libtmux._experimental.chainable_commands.adapters.SessionPlanRunner`:
136+
{class}`~libtmux._experimental.chain._connection.SessionPlanExecutor`:
137137

138138
```python
139-
>>> from libtmux._experimental.chainable_commands.adapters import SessionPlanRunner
140-
>>> from libtmux._experimental.chainable_commands.plan import panes
141-
>>> runner = SessionPlanRunner(session)
139+
>>> from libtmux._experimental.chain._connection import SessionPlanExecutor
140+
>>> from libtmux._experimental.chain.plan import panes
141+
>>> runner = SessionPlanExecutor(session)
142142
>>> live_plan = panes().filter(active=True).each(
143143
... lambda pane: pane.cmd.send_keys("echo libtmux", enter=True),
144144
... )
@@ -150,8 +150,8 @@ stays synchronous; only resolution and dispatch await:
150150

151151
```python
152152
>>> import asyncio
153-
>>> from libtmux._experimental.chainable_commands.aio import panes as async_panes
154-
>>> from libtmux._experimental.chainable_commands.plan import (
153+
>>> from libtmux._experimental.chain._async import panes as async_panes
154+
>>> from libtmux._experimental.chain.plan import (
155155
... PaneRef,
156156
... PaneTarget,
157157
... SessionTarget,
@@ -177,9 +177,9 @@ stays synchronous; only resolution and dispatch await:
177177
:hidden:
178178
:maxdepth: 1
179179
180-
api/libtmux._experimental.chainable_commands.ir
181-
api/libtmux._experimental.chainable_commands.plan
182-
api/libtmux._experimental.chainable_commands.aio
183-
api/libtmux._experimental.chainable_commands.adapters
184-
api/libtmux._experimental.chainable_commands.batch
180+
api/libtmux._experimental.chain.ir
181+
api/libtmux._experimental.chain.plan
182+
api/libtmux._experimental.chain._async
183+
api/libtmux._experimental.chain._connection
184+
api/libtmux._experimental.chain.batch
185185
```

src/libtmux/_experimental/chainable_commands/__init__.py renamed to src/libtmux/_experimental/chain/__init__.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
88
The layers build on each other:
99
10-
- :mod:`~libtmux._experimental.chainable_commands.ir` -- the immutable argv
10+
- :mod:`~libtmux._experimental.chain.ir` -- the immutable argv
1111
intermediate representation (``CommandCall``, ``CommandSequence``).
12-
- :mod:`~libtmux._experimental.chainable_commands.plan` -- typed, target-safe
12+
- :mod:`~libtmux._experimental.chain.plan` -- typed, target-safe
1313
deferred query-command plans (``panes()``, ``CommandPlan``).
14-
- :mod:`~libtmux._experimental.chainable_commands.aio` -- an async facade over
15-
the same engine (``aio.panes()``), preserving one dispatch per plan.
16-
- :mod:`~libtmux._experimental.chainable_commands.adapters` -- live-tmux
17-
adapters (``snapshot_from_session``, ``SessionPlanRunner``,
18-
``AsyncSessionPlanRunner``).
19-
- :mod:`~libtmux._experimental.chainable_commands.batch` -- the chainability
14+
- :mod:`~libtmux._experimental.chain._async` -- an async facade over
15+
the same engine (``_async.panes()``), preserving one dispatch per plan.
16+
- :mod:`~libtmux._experimental.chain._connection` -- live-tmux
17+
connection helpers (``snapshot_from_session``, ``SessionPlanExecutor``,
18+
``AsyncSessionPlanExecutor``).
19+
- :mod:`~libtmux._experimental.chain.batch` -- the chainability
2020
contract that decides which commands may fold into one dispatch
2121
(``CommandSpec.chainable`` + ``DeferredCommandResult``).
2222
@@ -28,19 +28,19 @@
2828

2929
from __future__ import annotations
3030

31-
from libtmux._experimental.chainable_commands.adapters import (
32-
AsyncSessionPlanRunner,
33-
SessionPlanRunner,
31+
from libtmux._experimental.chain._connection import (
32+
AsyncSessionPlanExecutor,
33+
SessionPlanExecutor,
3434
snapshot_from_session,
3535
)
36-
from libtmux._experimental.chainable_commands.batch import (
36+
from libtmux._experimental.chain.batch import (
3737
AutoBatchTarget,
3838
ChainabilityError,
3939
DeferredCommandResult,
4040
DeferredOutputUnavailable,
4141
is_chainable,
4242
)
43-
from libtmux._experimental.chainable_commands.ir import (
43+
from libtmux._experimental.chain.ir import (
4444
Arg,
4545
CommandCall,
4646
CommandResultLike,
@@ -49,7 +49,7 @@
4949
CommandSequence,
5050
CommandSpec,
5151
)
52-
from libtmux._experimental.chainable_commands.plan import (
52+
from libtmux._experimental.chain.plan import (
5353
CommandPlan,
5454
CommandValue,
5555
NoCommandsResolved,
@@ -65,7 +65,7 @@
6565

6666
__all__ = [
6767
"Arg",
68-
"AsyncSessionPlanRunner",
68+
"AsyncSessionPlanExecutor",
6969
"AutoBatchTarget",
7070
"ChainabilityError",
7171
"CommandCall",
@@ -83,7 +83,7 @@
8383
"PaneRef",
8484
"PaneTarget",
8585
"PlanRunner",
86-
"SessionPlanRunner",
86+
"SessionPlanExecutor",
8787
"SessionTarget",
8888
"TmuxSnapshot",
8989
"WindowTarget",

src/libtmux/_experimental/chainable_commands/aio.py renamed to src/libtmux/_experimental/chain/_async.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
r"""Asyncio facade over the deferred query-command plan.
22
33
This is a thin wrapper over the sync
4-
:mod:`~libtmux._experimental.chainable_commands.plan` engine: command
4+
:mod:`~libtmux._experimental.chain.plan` engine: command
55
*construction* stays synchronous, and only snapshot resolution and command
66
dispatch become awaitable. A plan still compiles to exactly one
7-
:class:`~libtmux._experimental.chainable_commands.ir.CommandSequence`, so the
7+
:class:`~libtmux._experimental.chain.ir.CommandSequence`, so the
88
"one plan = one native ``\\;`` dispatch" guarantee is preserved -- it just runs
99
without blocking the event loop, and independent plans can resolve and dispatch
1010
concurrently.
@@ -21,8 +21,8 @@
2121
import typing as t
2222
from dataclasses import dataclass
2323

24-
from libtmux._experimental.chainable_commands import plan as sync_plan
25-
from libtmux._experimental.chainable_commands.ir import (
24+
from libtmux._experimental.chain import plan as sync_plan
25+
from libtmux._experimental.chain.ir import (
2626
Arg,
2727
CommandResultLike,
2828
CommandSequence,
@@ -72,7 +72,7 @@ class PaneQuery:
7272
Examples
7373
--------
7474
>>> import asyncio
75-
>>> from libtmux._experimental.chainable_commands.plan import (
75+
>>> from libtmux._experimental.chain.plan import (
7676
... PaneRef, PaneTarget, SessionTarget, TmuxSnapshot, WindowTarget,
7777
... )
7878
>>> snapshot = TmuxSnapshot(panes=(
@@ -150,7 +150,7 @@ class CommandPlan(t.Generic[ResultT]):
150150
Examples
151151
--------
152152
>>> import asyncio
153-
>>> from libtmux._experimental.chainable_commands.plan import (
153+
>>> from libtmux._experimental.chain.plan import (
154154
... PaneRef, PaneTarget, SessionTarget, TmuxSnapshot, WindowTarget,
155155
... )
156156
>>> snapshot = TmuxSnapshot(panes=(
@@ -179,7 +179,7 @@ async def to_sequence(self, source: AsyncSnapshotSource) -> CommandSequence:
179179
"""Resolve the async query and compile mapped commands.
180180
181181
Reuses the sync compile path, so a plan still produces exactly one
182-
:class:`~libtmux._experimental.chainable_commands.ir.CommandSequence`.
182+
:class:`~libtmux._experimental.chain.ir.CommandSequence`.
183183
"""
184184
snapshot = await _resolve_snapshot(source)
185185
return self.query.query.flat_map(self.mapper).to_sequence(snapshot)

0 commit comments

Comments
 (0)