Repository navigation
python: decouple SDK library components - #9538
Merged
Merged
Conversation
helderco
force-pushed
the
python/decouple
branch
from
February 10, 2025 13:38
67e005a to
5d690ef
Compare
helderco
force-pushed
the
python/decouple
branch
from
March 4, 2025 13:09
5d690ef to
72cba36
Compare
This comment was marked as resolved.
This comment was marked as resolved.
helderco
force-pushed
the
python/decouple
branch
2 times, most recently
from
April 3, 2025 13:11
e502fb3 to
158494b
Compare
helderco
force-pushed
the
python/decouple
branch
from
April 15, 2025 13:37
158494b to
7d6ce37
Compare
helderco
marked this pull request as ready for review
April 15, 2025 14:14
Contributor
Author
|
I'm going to let CI run all the tests to confirm nothing has changed. I'll fix any failures but the feature is frozen and ready for review. |
helderco
force-pushed
the
python/decouple
branch
from
April 15, 2025 14:24
7d6ce37 to
f34a704
Compare
helderco
force-pushed
the
python/decouple
branch
8 times, most recently
from
April 20, 2025 23:06
dfe28e8 to
3e8115a
Compare
sipsma
approved these changes
Apr 21, 2025
sipsma
left a comment
Contributor
There was a problem hiding this comment.
One comment but not sure how significant it is, otherwise LGTM
| return err | ||
| } | ||
| if ref == "" { | ||
| i = &Image{} |
Contributor
There was a problem hiding this comment.
nit: I think this is a no-op since it's just setting i, which is a local var. Guessing the intention is *i = Image{}? That would actually change the value i is pointing to. Need to be careful of i == nil case though
Not sure if this is actually a significant code branch ever expected to be hit though
Contributor
Author
There was a problem hiding this comment.
Good catch, that line can be removed.
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
…t.toml Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
helderco
force-pushed
the
python/decouple
branch
from
April 21, 2025 18:05
3e8115a to
28bfefb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The initial goal with this was to reduce the size of what gets generated into the user’s host when developing Dagger modules in Python. That has been expanded to also simplify the development workflow and avoid the need for
dagger developin order to have IDE completions.However, the simplified workflow part has been put on hold but the changes kept (turned off), in order to bring it at a later time with a bit more investment.
Additionally,
uvandcodegen+ dependencies have been bundled in the engine. This prevents issues for some users behind proxies, mirrors, or unauthenticated to ghcr.io (uv).External client bindings to avoid
dagger developWhy?
There’s a complaint in #8689 that
dagger initgenerates too many files to the host.The first iteration of this PR was to just exclude some parts of the client library that have no use in modules, like the automatic provisioning feature. This would allow generating less files to user’s host on
dagger init. At the time it was already on my mind because of confusion over the supported engine version included in the client library.1At the same time, some users complained that the client library was vendored instead of pulling from the published package. This was mostly on TypeScript, but I’ve seen it being asked generally too. I felt it was doable in Python, my problem was how do you run our integration tests, with changes to the client library that haven’t been published yet?
Then the discussion on #8689 led to complaints over the need to
dagger developin the first place. I started to think that if we generate the client bindings outside of the client library, we can depend on the published library, avoid the need to vendor and patch the whole client library, and recommend to commit those client bindings to git. This waydagger developis no longer a necessary pre-requisite on a clean clone. You just needuv sync.So this trades 50+ uncommitted files that need to be regenerated every time, with just one committed. It’s also aligned with support for calling module functions in custom clients (with
dagger run), and it simplifies the user’s workflow.How?
I wanted to generate the client bindings to the user’s
src/dagger/gen/client.py, which would sit next tosrc/my_module/main.py. The problem is that the clean solution for doing that would required thedaggerpackage to not have a__init__.py(implicit Python namespace package), but we need that to expose all the public API under the top leveldaggerimport. So I decided on a top levelsrc/dagger_gen.pymodule.The client library will try to import
dagger.Clientfromdagger_gen.pyand fallback to the defaultdagger/client/gen.pyif it doesn’t exist. So users continue to import fromdaggeras normal, and the client library no longer needs to be patched with the necessary client bindings for the current module.In the Python SDK runtime module, we check for the engine’s version from the API to always enforce the same version as a dependency in
pyproject.toml, for compatibility. On an engine upgrade, that version should be bumped automatically ondagger develop.If it’s detected that it’s a custom build of the engine, an override is added to
pyproject.tomlto look for the library in thesdksubdir. This config is used to actually decide to vendor or not, and where. It doesn’t matter is there’s adependencies = ["dagger-io==v0.19.0"], it’s just replaced like areplaceinstruction ingo.mod. This way our test suite continues to work as normal because it will continue to vendor the library and pick up changes.On hold ⏳
I started worrying about missing details on how to manage these versions, and the need to add more test cases for this, but this PR has been in draft for a long time, and used as base for an even longer PR in suspension (interfaces support).
In order to avoid blocking this even further I made a last minute decision to keep the vendoring in all cases for now, but making it easy to turn it off later. This way there’s no expected changes for users here.
My plan is to make another PR later, specifically for turning all of this on, in concert with the client generator work that @TomChv has done, for TypeScript and Go.
Bundled
codegenanduvSince this PR had a bunch of changes to the SDK, I reused it to experiment on bundling the
codegenscript. Python’scodegenis a subpackage of the client library, with only one dependency. It’s been installed during module load but since it’s a differentpyproject.tomlfrom the users’s it was a problem for some users that needed to set their mirrors more globally rather than just configuring them it theirpyproject.toml. Now it’s bundled in the engine as a single executable file, so it’s no longer trying to install the codegen’s dependencies during module load.Additionally, I also decided to include the
uvbinaries because they’re normally pulled from ghcr.io and it causes failures for people, either from a network failure, or from not having donedocker login ghcr.io, which adds friction.I also experimented with bundling a warmed
uvcache but didn’t seem to make any noticeable effect so I decided to try it again at a later time.Footnotes
It’s a chicken and egg situation because that version is only bumped right after the engine is released, before publishing to the public package registry. However the client library has already been copied into the just released engine which is what gets copied to the host on
dagger init. Thus, if you open that file, it always points to the previous engine version. ↩