Skip to content

Commit 5b4ffaf

Browse files
committed
python-sdk: add CLI 1.0 client init
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>
1 parent a976c93 commit 5b4ffaf

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎.dagger/modules/e2e/main.dang‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ type E2e {
156156
null
157157
}
158158

159+
"""
160+
initClient should not materialize files itself. The engine records the client
161+
and owns the generated context changeset.
162+
"""
163+
pub initClientCheck(ws: Workspace!): Void @check {
164+
let changes = pythonSdk.initClient(ws, path: outputRoot + "/client", module: generateModulePath, dev: true)
165+
166+
assert(changes.isEmpty, "initClient should return an empty SDK changeset")
167+
168+
null
169+
}
170+
159171
"""
160172
config.get should reflect pyproject.toml and report unset values as null
161173
rather than guessing, and config.set should edit only pyproject.toml.

‎python-sdk.dang‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ type PythonSdk {
145145
}
146146
}
147147

148+
"""
149+
Generate a typed Python client for `module` at `path`.
150+
151+
The engine records the managed client in workspace config before calling
152+
this function. The engine owns materializing the generated client files.
153+
"""
154+
pub initClient(ws: Workspace!, path: String!, module: String!, dev: Boolean! = false): Changeset! {
155+
polyfill.workspace(ws).fork.changes
156+
}
157+
148158
"""
149159
Render a Python template with the requested module name.
150160
"""

0 commit comments

Comments
 (0)