Repository navigation
module CLI commands renames - #6533
Conversation
Yes, that's mostly true. Only in the Python SDK, if you use top-level functions instead of a class, then you don't need to update the code if you rename the module. The Python SDK dev module is an example of this. There's nothing in code referencing the However, I've been rethinking the support for top-level functions in Python. Even though there's usually a preference for functions over classes in the ecosystem, over time we've added state in the form of object fields, constructors, main object description..., so I'm worried that users will start with functions and find the need to upgrade to a class pretty often, so I've been considering deprecating the top-level functions support. There was a lot of pushback in the React community because the same thing happened where you could create components with either functions or classes. People preferred the simplicity of functions, but had to upgrade to a class for more "advanced" lifecycle hooks. It took some time but later they implemented hooks in a way that could be used in functions so that took care of it. Coming back to changing code on a rename, we could make this easier if the main object wasn't named after the module, but instead be something static that the engine would then rename automatically. Same as in GraphQL you have the Query object type that's mandatory. Then this static and conventionalized class name would be handled in codegen and engine so there's less to worry about on a rename. |
Yeah, I like |
👍 I think Example usage scenario, starting from a codeless module: $ dagger develop
Error: no SDK configured. Please specify one with --sdk
$ dagger develop --sdk go
Error: no module name configured. Please specify one with --name
$ dagger develop --sdk go --name mymod
Saving new SDK configuration: Go
Downloading SDK...
Building SDK...
Initializing SDK...
No source file detected. Generating template...
Generating source files...
To start developing, edit ./main.go
$ Then to re-generate as you develop: $ dagger develop
Generating source files...
To start developing, edit ./main.goYou can change SDK, but it's disruptive and expected to be uncommon. $ dagger develop --sdk python
Error: SDK is already configured. Use --force to start over with a new SDK.
$ dagger develop --sdk python --force
Saving new SDK configuration: Python
Downloading SDK...
Building SDK...
Initializing SDK...
No source file detected. Generating template...
Generating source files...
To start developing, edit ./src/main.py
I think that is wrong,
I think it's best to keep configuration CRUD out of it. Open question: does
Thoughts?
Ha, I didn't even know you could do that :)
Yeah that's pretty good.
This is where we are going to hit the limits of CLI crud. There are going to be a bunch of fields in that config file, of various meaning and format. I don't know if mapping each top-level key to a flag will be enough - for example how do you manage Possible options:
See above my note about using |
|
We're also going to need:
|
|
Note from Nipuna about another adjustment I think we should consider to He was in a dir for module A and wanted to install But the syntax actually meant "install ../c to module ../b", with He suggested having more explicit flags here like: dagger mod install --source a --target bThe exact name of the flags is worth bikeshedding, but I fully agree that more explicit flags here would result in more obvious syntax. Just adding as a comment here in case it makes sense to tackle. Otherwise will spin out to separate issue. |
|
From @shykes, we should retire I think at the very minimum it should not be a top-level flag on |
|
I have a few items for a follow up left from (see Todo): I've been changing For TUI and module flags, once the flags are parsed there's no sense continuing to have them available on sub-commands. It's too late to apply. Most of the others could be shown only on the root |
I like that! |
Yep that makes sense to me. My only source of hesitation was that there's a lot of fields in
Just for context, updating deps today looks like e.g.:
The above works when specifying I do like having a separate command for this though since it would be much more explicit and obvious in many ways. And also agree that we'd then want In this new model, I think it would make sense for On a high-level note: I'm going to update this PR to just contain the things that seem clear in terms of consensus and split out some of the thornier parts to separate follow-ups (will make issues). That'll unblock parallelizing those efforts. Updating it to have just:
Follow-ups:
|
While developing modules I find myself renaming them occasionally. It would be great to have at least basic support for it. I am happy even if it comes with a warning. It would be great if dagger can identify local dependent modules and update their references also but I understand that may be to complicated/error prone. |
4eda39f to
dcd0877
Compare
6a7c093 to
27200e9
Compare
shykes
left a comment
There was a problem hiding this comment.
Playing with this build live (using Zed for the first time, yay!):
Focusing on dagger init:
-
dagger init -mfeels confusing. I think we should cut it, and later when/if-mbecomes a global flag like we discussed, then it will apply equally to all subcommands. -
dagger init [PATH]would be a nice addition, especially combined with a default value for--name.dagger init foois nicer to type thanmkdir foo && cd foo && dagger init --name foo -
dagger initshould not have--sdkat all. The idea is thatinitbecomes much more lightweight: just add a dagger.json. Later if you want to add code to your module, you develop functions withdagger develop
Yeah I can see how EDIT: pushed those changes, no
@shykes I feel like this just results in extra boilerplate in that if you want to init a module and develop on code right away you have to do two commands: But what's the harm in supporting |
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
This also required a slight implementation adjustment to give re-configuring an SDK the same behavior as re-configuring a name in that it only becomes an error once you try to re-generate the source code. This allows custom SDKs to re-use other SDKs more easily, which is relied on for our custom SDK test. Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
I see what you mean. The harm (big word but I'll run with it :) would come from making it slightly harder to understand the purpose of each command, because Not worth holding back merge though. |
@shykes Yeah that's true too. My gut feeling is that the cost of having I'll just leave it as is for now until I hear other opinions (cc @helderco or anyone who wants to be a tie-breaker here 😄). |
shykes
left a comment
There was a problem hiding this comment.
Let's merge and keep talking in follow-ups :)
This implements a bare minimum subset of the polish described here and discussed separately: #6291 (comment)
Specifically, it's mainly just the stuff that's backwards incompatible, with the addition of
dagger develop --sdk=... --name=...since it was trivial to support and needed as a follow-up to #6386Changes in this PR
syncis renamed todevelop--nameand--sdkflags for updating the name+sdk of a module that does not currently have those setinit/install/develop/publishare all top-level commands underdaggernow, not underdagger mod.dagger mod ...commands that redirect to the new commanddagger mod(for printing config) ->dagger configdagger configyet, will bikeshed that in separate standalone PR, it just prints config information atmdagger init-mis not supported anymore, you can just specify an extra arg if you want to init at a path other than cwd--nameis optional and defaults to the name of the directory being init'd inFollow-ups
install/update/uninstalldagger updateto update existing depsinstallto fail if dep at different version already existsuninstall--dry-run(if worth effort in short term, otherwise can backlog)install, re: module CLI commands renames #6533 (comment)dagger -m MOD install depmay suffice insteaddagger configgit configstyle,set/get, etc.include/excludedevelopOld PR description (outdated)
Expand
A few things worth detailing and/or discussing:What to do with
dagger mod?This change currently leaves in
dagger mod(no subcommands) with the same behavior as before of printing module configuration (name, sdk, source path, root path, dependencies, etc.)This isn't awful, but I do feel a better name might be
dagger config.And at that point, I'd probably want to tweak
dagger updatesuch that:dagger config- print the module configurationdagger config update --name foo --sdk go- update the module configurationI like that option the most, but holding off until I get feedback from others on this so I don't waste time 🙂
dagger updateThis currently can only be used to set the name+sdk of a module that does not already have one set. E.g. this sort of use case that's possible now via #6386:
dagger init- create an empty nameless+sdkless moduledagger install github.com/foo/bar/[email protected]- add a dependency that can now be invoked with e.g.dagger call -m coolmoddagger update --name mymod --sdk go- now initialize a real module with the deps from beforeAttempts to update the name/sdk of a module that already has those set result in an error.
The reason for this restriction at the moment is that actually updating the module name/sdk from existing values is a bit thornier:
So starting out with errors in these cases made the most sense, but easy to iterate on too.