Skip to content

Adopt the module-max SDK interface from dagger/dagger#13992 - #25

Merged
eunomie merged 3 commits into
dagger:mainfrom
eunomie:python-sdk-pr-13992-fast-adopt-lead-d4e003f3
Sep 4, 2026
Merged

eunomie merged 3 commits into
dagger:mainfrom
eunomie:python-sdk-pr-13992-fast-adopt-lead-d4e003f3

Conversation

@eunomie

@eunomie eunomie commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

Problem

dagger/dagger#13992 (branch sdk-ux-module-max, head 055def6f7794b9d0dfdcc4252f0695ea92257536) changes how the engine drives an SDK module, with no compatibility adapter:

  • It removes CurrentModule.asSDK and ModuleSource.generateLocalDependencies. Every public function of this module selected one of them, and Dang infers the whole program on each call, so on that engine every call of this module failed.
  • It replaces the beta SDK-module interface (initModule, targetRuntime, @generate) with detectScope(ws) and generateScope(ws, isModule, name, clients). The SDK is recorded under [sdks.python] in dagger.toml, the engine sets Workspace.cwd to a persisted scope, and the SDK writes the module manifest itself through the engine's manifest builder.
  • Module commands move under dagger module; dagger module deps and dagger module engine are gone; module dependencies are replaced by generated module clients.

This follows dagger/dang-sdk#13 and dagger/go-sdk#37, which adopt the same interface the same way.

Change

  • detectScope answers with the directory of the nearest pyproject.toml (lifted to the owning Python module when that is the vendored sdk/ library).
  • generateScope scaffolds a module that has no config file from the configured template and moduleManifest.withName(name).withLegacyPythonRuntime.tomlFile, which writes dagger-module.toml only (no dagger.json), then generates it; a module that already has a dagger-module.toml or dagger.json is only generated. A new module is generated even under a skip marker.
  • In a module scope the client set becomes the module's dependency set: the builder loads the module's dagger-module.toml (or the dagger.json of a pre-1.0 module that has nothing else), replaces the dependencies with one entry per client (a git ref as is, a local module by its path relative to the module), and writes that file back, so the vendored bindings include the clients' types; a removed client is dropped again, and a module with neither clients nor dependencies keeps its manifest untouched. Standalone clients, in a scope without a module, are refused with an error, so that client add fails atomically.
  • The template, Python version, uv, and base image choices are constructor settings; the CLI exposes them as dagger module init python --template=... --python-version=... flags.
  • initModule, targetRuntime, modules, and the generateAll generate hook are removed with the interface they served. mod stays for the config helpers and reads the registered modules through Workspace.sdk(name).modules.
  • Mod gains a generated workspace that generateScope returns directly: Workspace.changes compares both sides at their cwd, so a changeset computed at a scope cwd cannot be re-applied with withChanges.
  • dagger.toml moves to the [sdks.python] form with one scope per fixture; the as-sdk form and the sdk-sdk contract checks go away.
  • A new engine-e2e module builds an engine from sdk-ux-module-max at commit 055def6f (the engine-dev dependency and the engine source are pinned to that commit, so CI does not float with the branch; bump both to follow it), installs this checkout as the python SDK, initializes a Python module, and calls it.

The module needs an engine built from sdk-ux-module-max at 2af60773 or later: it selects moduleManifest(loadTOML:, loadJSON:), withName, withDependency, and withoutDependency, which that commit introduced.

Manifest v2 and entrypoint generation (dagger/dagger#14038) are out of scope.

Verification

  • engine-e-2-e:dev-sdk-check passes with the released CLI. It builds the engine from sdk-ux-module-max at 055def6f inside Dagger; there, dagger sdk list prints python python-sdk, dagger module init python --name sdk-smoke --path .dagger/modules/sdk-smoke writes dagger-module.toml (and no dagger.json), pyproject.toml, src/sdk_smoke/__init__.py, and sdk/src/dagger/client/gen.py, and dagger -m .dagger/modules/sdk-smoke call container file --path /etc/alpine-release contents runs the module.
  • The 13 e-2-e:* checks that call this module (detect-scope, the three generate-scope-*, the three lookup checks, generate, toml-generate, skip-generate, generate-skips-existing-files, config, skip-generate-filename) pass when dagger check runs inside that branch-engine playground; generate-scope-clients-check adds a Dang fixture module as a client of a Python module, asserts the dependency in the manifest and its type in the generated bindings, then removes it again.
  • The client-to-dependency step is verified at the API level only, because both CLI paths that would drive it are broken on the engine commit (see below). Inside the playground, Workspace.withClient on a freshly initialized Python module does return a workspace whose overlay modifies dagger.toml, the module's dagger-module.toml, and the vendored bindings, which is the SDK's part of the job.
  • e-2-e:runtime-call-check, e-2-e:runtime-naming-check, e-2-e:runtime-requires-generated-files-check, and e-2-e:sdk-test-check pass on the released engine v1.0.0-beta.11.

Known limitations and engine gaps

  • Like Support new SDK interface (1.0.0-beta.12 and later) dang-sdk#13 and Implement new SDK interface for engine 1.0.0-beta.12 go-sdk#37, the e-2-e:* checks that call this module fail on the released engine (v1.0.0-beta.11), which lacks moduleManifest; engine-e-2-e:dev-sdk-check, the runtime checks, and the SDK unit tests pass there.
  • Engine gap, to report on Better SDK UX: "modules-max" design dagger#13992: SDK settings persisted on a scope or under [modules.python-sdk.settings] were not delivered to the provider constructor in the SDK-module path on an engine built from the branch at 7ebd6da5 (--template=empty is persisted, the default template is scaffolded), while dagger call python-sdk template sees them. Reproduced again on 055def6f inside the engine-e2e playground: dagger module init python --name bare --path mods/bare --template=empty --python-version=3.13 records both settings under the scope and scaffolds the default template with requires-python = ">=3.14".
  • dagger module init python --path <dir> into an existing Python project without a module config overlays the template, which replaces a same-named pyproject.toml; the CLI shows the diff before applying.
  • Engine bug, to report on Better SDK UX: "modules-max" design dagger#13992: on 055def6f, dagger module client add <target> prints "no changes to apply" and writes nothing, although the withClient result carries the changes in its overlay; the CLI's changes(from: currentWorkspace) comes back empty. Reproduced with a path target and with an installed-module alias, from inside a subdirectory module scope and at a workspace-root scope, and with the engine's own core/integration/testdata/sdks/module-max-lifecycle fixture SDK, all inside the engine-e2e playground.
  • Engine bug, to report on Better SDK UX: "modules-max" design dagger#13992: on 055def6f, dagger generate with a client recorded on a module scope (clients = [".dagger/modules/e2e/fixtures/clients/dep"]) fails before calling the SDK: GeneratorGroup.moduleSource(path: "/.dagger/modules/e2e/fixtures/clients/dep"): "attach module source workspace: attach dependency result: attach dependency results: reconstruct attached self: cannot instantiate dagql.Class[*core.GeneratorGroup] with dag".
  • Engine bug, to report on Better SDK UX: "modules-max" design dagger#13992: ResolveDepToSource (core/modulesource.go) joins a module's local dependency source onto the module's workspace-relative root and passes the result to Workspace.moduleSource(path) without a leading slash, so the workspace resolves it against Workspace.cwd. With the cwd at a scope, as during generateScope, a dependency ../../clients/dep of .dagger/modules/e2e/fixtures/toml-generate/app is looked up at .dagger/modules/e2e/fixtures/toml-generate/app/.dagger/modules/e2e/fixtures/clients/dep. generateScope works around it by generating with the cwd at the workspace root and restoring the scope cwd on the result.
  • Standalone module clients (a scope without a module) are not generated yet.

@eunomie
eunomie force-pushed the python-sdk-pr-13992-fast-adopt-lead-d4e003f3 branch 4 times, most recently from d90d42d to ef02a1d Compare September 4, 2026 10:23
dagger/dagger#13992 replaces the beta SDK-module interface with no
compatibility adapter: an SDK is an installed module that implements
detectScope(ws) and generateScope(ws, isModule, name, clients), recorded
under [sdks.<name>] in dagger.toml. The engine persists a scope, sets
Workspace.cwd to it, and asks the SDK for the complete scope; the SDK writes
the module manifest itself. The same change removes currentModule.asSDK and
ModuleSource.generateLocalDependencies, which the beta entry points
selected, and it ignores an SDK's own @generate functions.

detectScope answers with the directory of the nearest pyproject.toml, lifted
to the owning Python module when that is the vendored sdk/ library.
generateScope scaffolds a module that has no config file from the configured
template and a dagger-module.toml from the engine's manifest builder, naming
the python runtime and writing no dagger.json, then generates the module in
place; a module that already has a config is only generated, and a new
module is generated even under a skip marker. In a module scope the client
set becomes the module's dependency set: the manifest builder loads the
manifest file the module has, replaces the dependencies with one entry per
client, and writes that file back, so the vendored bindings include the
clients' types; a module with neither clients nor dependencies keeps its
manifest untouched. Standalone clients, in a scope without a module, are
refused rather than silently skipped, so a client add fails atomically.

The template, Python version, uv, and base image choices are constructor
settings, which the CLI exposes as `dagger module init python --template=...
--python-version=...` flags and persists on the scope. initModule,
targetRuntime, modules, and the generateAll @generate hook go away with the
interface they served, as in dagger/dang-sdk#13 and dagger/go-sdk#37. mod
stays for the config helpers and reads the registered modules through
Workspace.sdk(name).modules; the cwd policy moves into Dang.

Mod gains a public `generated` workspace, which generateScope returns
directly. A changeset computed at a scope cwd cannot be re-applied with
withChanges: Workspace.changes compares both sides at their cwd, so the
round trip copied the scope subtree onto the workspace root. skipGenerate
anchors its findUp start at the root for the same reason: Workspace.findUp
resolves a relative start against the cwd.

Signed-off-by: Yves Brissaud <[email protected]>
…mmand tree

dagger/dagger#13992 records an SDK under [sdks.<name>] with one scope per
managed module, and ignores [modules.<name>.as-sdk]. dagger.toml moves to
that form, as in dagger/dang-sdk#13 and dagger/go-sdk#37: the checks that
read the registered modules pass on an engine with #13992, and `dagger
generate` drives the same fixtures generateAll drove before. The sdk-sdk
contract checks covered the beta interface and go with it.

.dagger/lock and .dagger/config.toml predate the workspace layout: nothing
reads the config, and an engine with #13992 refuses the version 1 lock file
before it can initialize a module in this checkout.

The README follows the CLI: module operations live under `dagger module`,
install records the SDK, init generates the whole module in one step, and
`module deps` / `module engine` are gone. Module dependencies are replaced
by generated clients, which this SDK does not produce yet.

Signed-off-by: Yves Brissaud <[email protected]>
The released engine cannot drive the new SDK interface, so the check that
proves the whole flow builds its own engine: engine-dev from
dagger/dagger's sdk-ux-module-max branch, pinned in dagger.lock, gives a
playground with the CLI and engine from that branch. The check mounts this
checkout as the python SDK, lists it, initializes a Python module, and calls
a function of the generated module. dagger/dang-sdk#13 and dagger/go-sdk#37
use the same check.

Signed-off-by: Yves Brissaud <[email protected]>
@eunomie
eunomie force-pushed the python-sdk-pr-13992-fast-adopt-lead-d4e003f3 branch from ef02a1d to c05426e Compare September 4, 2026 16:07
@eunomie
eunomie marked this pull request as ready for review September 4, 2026 17:11
@eunomie
eunomie merged commit d8f8eca into dagger:main Sep 4, 2026
7 of 19 checks passed
@eunomie
eunomie deleted the python-sdk-pr-13992-fast-adopt-lead-d4e003f3 branch September 4, 2026 17:12
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