Skip to content

Prepare Python SDK for CLI 1.0 init contract#2

Open
eunomie wants to merge 2 commits into
mainfrom
prepare-cli-1.0-init-contract
Open

Prepare Python SDK for CLI 1.0 init contract#2
eunomie wants to merge 2 commits into
mainfrom
prepare-cli-1.0-init-contract

Conversation

@eunomie

@eunomie eunomie commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary

Mirrors the Go SDK's CLI 1.0 init-contract preparation (dagger/go-sdk#2) for the Python SDK.

  • add targetRuntime returning python so modules initialized through this SDK target the built-in Python runtime (consumed by the engine's RuntimeTarget wiring on design/cli-1.0)
  • replace the old init command with initModule(ws, name, path, template, pythonVersion, useUv, baseImage) that returns only the Python-owned template files. The engine owns the module config (dagger-module.toml) and workspace config, and merges this changeset with its own bookkeeping. Dropped from the SDK: writing dagger.json, path-defaulting against the nearest .dagger, the "module already exists" guard, and ignoreGenerated — all now engine concerns.
  • remove the SDK-owned mod deps / mod engine surfaces (mod-deps.dang, mod-engine.dang, and the Mod.deps / Mod.engine accessors). These are identical across SDKs and are now owned by the core CLI (dagger module deps / dagger module engine).
  • mark the modules / generate-all discovery path as legacy dagger.json discovery — obsolete for workspace-managed modules, where the engine owns the modules.<sdk>.as-sdk.modules source of truth.

Scope notes

  • The Python build-config surface (mod config, i.e. pyproject.toml editing) stays in this module — it is genuinely Python-specific and belongs to the SDK (reachable via dagger module sdk in the new CLI).
  • initClient is intentionally not added. Generating a Python client is a code-generator concern; this keeps Python module-only for now, mirroring the Go SDK.
  • The SDK-specific init args (pythonVersion, useUv, baseImage, template) are preserved on initModule so the CLI surfaces them as typed flags on dagger module init python.

Changes to tests / docs

  • e2e/main.dang: initCheck / initConfigCheck updated for initModule (no dagger.json, no ignoreGenerated); removed engineVersionCheck, dependencyListCheck, dependencyEditCheck (surface moved to core CLI); added a targetRuntimeCheck.
  • README.md: documents the dagger module init python flow, points deps/engine at the core CLI, keeps the config section, and notes the legacy discovery path.

Validation

Not run locally (no engine in this environment) — relies on CI to exercise the @check e2e suite. The Dang sources were edited to preserve existing style; please verify the checks pass.

Mirror the Go SDK's CLI 1.0 init-contract preparation (dagger/go-sdk#2)
for the Python SDK:

- add `targetRuntime` returning "python" so modules initialized through
  this SDK target the built-in Python runtime
- replace `init` with `initModule(ws, name, path, template, pythonVersion,
  useUv, baseImage)` that returns only the Python-owned template files; the
  engine owns dagger.json / dagger-module.toml and workspace config and
  merges this changeset with its own bookkeeping
- remove the SDK-owned `mod deps` / `mod engine` command surfaces, now
  owned by the core CLI (`dagger module deps` / `dagger module engine`)
- mark the `modules` / `generate-all` discovery path as legacy dagger.json
  discovery, obsolete for workspace-managed modules
- update the e2e checks and README to match

The Python build-config surface (`mod config`) stays in this module, as it
is genuinely SDK-specific. `initClient` is intentionally out of scope:
generating a Python client is a code-generator concern, mirroring the Go
SDK which stays module-only.

Signed-off-by: Yves Brissaud <yves@dagger.io>
Signed-off-by: Yves Brissaud <yves.brissaud@gmail.com>
grouville added a commit that referenced this pull request Jun 18, 2026
CLI 1.0 calls initClient when a workspace adds a managed client. The Python
SDK init-contract work lives in the stacked prepare-cli-1.0-init-contract
branch, but that branch does not add the client hook.

Add initClient with the CLI 1.0 signature, including the dev flag. It returns
an empty Changeset on purpose: the engine records the client and owns generated
client files through GeneratedContextChangeset.

This keeps the PR narrowly scoped on top of #2. It only adds the client init
hook and does not duplicate the targetRuntime or initModule changes from the
stacked base.

Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
grouville added a commit that referenced this pull request Jun 18, 2026
CLI 1.0 calls initClient when a workspace adds a managed client. The Python
SDK init-contract work lives in the stacked prepare-cli-1.0-init-contract
branch, but that branch does not add the client hook.

Add initClient with the CLI 1.0 signature, including the dev flag. It returns
an empty Changeset on purpose: the engine records the client and owns generated
client files through GeneratedContextChangeset.

Add an e2e check that calls initClient and verifies the SDK returns no file
changes.

This keeps the PR narrowly scoped on top of #2. It only adds the client init
hook and does not duplicate the targetRuntime or initModule changes from the
stacked base.

Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
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