Repository navigation
fix: replace strcase library to fix module name transformation related issues - #8122
rajatjindal wants to merge 2 commits into
Conversation
|
|
||
| go 1.22 | ||
|
|
||
| require ( |
There was a problem hiding this comment.
the go.mod changes were triggered by running go mod tidy in the runtime folder. I am trying to identify if there is a way to update the file without triggering these unwanted changes.
401b865 to
2aff1aa
Compare
906f8c3 to
aa38802
Compare
| strcase.SplitAfterNumber, | ||
| ) | ||
|
|
||
| return strcase.NewCaser(false, nil, splitFn) |
There was a problem hiding this comment.
This is done this way to avoid dependency on dagql in runtime. But can we add this to internal package and use it from there? what do you think @jedevc @marcosnils?
There was a problem hiding this comment.
Although, for sdk-runtime, it seems like there is no dependency on dagger's core/dagql package, so right now we are duplicating the code from strcase pkg into those files. But this mean, they can go out of sync quickly.
Yeah, the duplication is definitely not good 😢 I like the idea of adding a dependency onto the root module, that sounds fine to me - we can then have a replace directive in elixir/typescript/python to point it back to the top (though maybe this might require a bit of a chance to how the runtime gets built).
Another potential option would be to add this into the auto-generated internal package - but I'm not a huge fan of this - since it's kind of a work-around that only we're able to do - we should try and dogfood the other approach if we can.
There was a problem hiding this comment.
Or copy strcase under the engine directory to internal package of each runtime module when calling a generate function (dagger call sdk <sdk> generate)? So we can keep in sync with the engine and runtime.
There was a problem hiding this comment.
I actually like this idea. this way we may be able to omit the manual copy step. but I am not entirely sure if there are any other downsides to it.
|
The CI is green (finally). and I think we can review the changes now. There is one question around configuring strcase in runtime (vs dependency on dagql or adding the configuration part to internal pkg). |
aa38802 to
68fb31f
Compare
jedevc
left a comment
There was a problem hiding this comment.
Nice 🎉 left some comments, but I think the shape is mostly right! I like having our own package in front of this, keeping all this centralized is good (and means it's importable by anyone else, like an external sdk author).
One very sad question - is this a breaking change? Does this change the casing of any args/function names/modules? If so... that's annoying.
We would have to decide to either:
- Just break 💥 It's likely these cases were kinda broken already, and maybe they're uncommon enough.
- Add version compatibility 🎉 This is trickier, but means that we can have older modules not break, but expose the newer behavior correctly.
- This would probably work by somehow passing
engineVersiontostrcase, and then we would do a semver comparison - versions before v0.12.X get the old behavior, and versions after get the new behavior. - This seems like a total pain to plumb it all through correctly, propagating
dagger.jsonsengineVersionall the way through to all the places we call this function is not very fun.
- This would probably work by somehow passing
| strcase.SplitAfterNumber, | ||
| ) | ||
|
|
||
| return strcase.NewCaser(false, nil, splitFn) |
There was a problem hiding this comment.
Although, for sdk-runtime, it seems like there is no dependency on dagger's core/dagql package, so right now we are duplicating the code from strcase pkg into those files. But this mean, they can go out of sync quickly.
Yeah, the duplication is definitely not good 😢 I like the idea of adding a dependency onto the root module, that sounds fine to me - we can then have a replace directive in elixir/typescript/python to point it back to the top (though maybe this might require a bit of a chance to how the runtime gets built).
Another potential option would be to add this into the auto-generated internal package - but I'm not a huge fan of this - since it's kind of a work-around that only we're able to do - we should try and dogfood the other approach if we can.
68fb31f to
81d311b
Compare
with these changes, I didn't had to change any arg/func/module-name etc in the testcases. and with the failures I was getting with other combination of these changes, it seems like we have pretty good coverage in terms of casing (indirectly though). The major customization we had to do with new lib is to preserve initialism in
which was the behavior with existing library as well (https://go.dev/play/p/HJrH5cuDW40), which was also the source of all our failures while I tried different permutations of strcase configs with our testcases. Having said that, maybe we can write an automation script to list all modules from our daggerverse list, and try calling their functions with new engine. Maybe we can identify some edge cases using that. what do you think? |
Perfect, yes, that's a good idea - cc @marcosnils @matipan who have a script for this already I think 🤔 |
how do you feel about importing (if we do that, we may have to do the runtime change in next PR because right now |
This shouldn't be an issue if we set the |
ah ok. i was not sure about that (I don't completely understand the concept of |
it seems like this may not work? when I run a test with this, i get following error: which means during the dagger init execution, engine code may not be copied over to the container directly? |
8d08cff to
b393cfe
Compare
jedevc
left a comment
There was a problem hiding this comment.
Some notes, I wonder if we need to do this same thing in the SDKs as well, but I suggested writing a few tests to see if we need to - we might not.
Quick note - I really like the new core/compat package, I think this is a good approach to move forward with. I like the idea of being to attach more things in the future 😄
| func (s *moduleSchema) addCompatToCtx(ctx context.Context) context.Context { | ||
| return compat.AddCompatToContext(ctx, s.dag.View) | ||
| } |
| } | ||
| } | ||
|
|
||
| func (ModuleSuite) TestModuleNamingCompatFuncName(ctx context.Context, t *testctx.T) { |
There was a problem hiding this comment.
Hm, I suspect there's still something missing here 😢
Suppose:
- We have a dep using "new dagger" that was one of these weird cases like
WithDaggerCLIAlpine - We have a main module that's using an "old dagger" that install
WithDaggerCLIAlpine - What does the codegen look like for the main module? I think it probably needs to generate with the "old dagger" form.
Maybe this "just works" as is, but I'd like a test to confirm that (and ideally for go/python/typescript consumers).
If this is an issue, then the fix will be to propagate the strcase.Caser code into cmd/codegen and each of the runtime modules. Thankfully we already propagate the engineVersion into there, so hopefully wouldn't be too bad with all the context plumbing you've already done 🎉
| return call.NewModule(mod.InstanceID, mod.Name(), ref) | ||
| } | ||
|
|
||
| func (mod *Module) addCompatToCtx(ctx context.Context) (context.Context, error) { |
There was a problem hiding this comment.
I think this isn't needed? By calling this in the server, doesn't this propagate down everywhere to where it needs to go?
Might be just leftover, but can't quite tell.
| //this is ugly, but lets try it | ||
| if fn.ctx != nil { | ||
| cp.ctx = fn.ctx | ||
| } |
There was a problem hiding this comment.
nit: we can remove this now, WithArg should take a context arg, as with all the other typedef methods.
There was a problem hiding this comment.
I don't think needs to be a separate module. strcase doesn't either now, since we're going with the copy-paste approach for now.
Signed-off-by: Rajat Jindal <[email protected]>
Signed-off-by: Rajat Jindal <[email protected]>
b9cfae7 to
eb84bde
Compare
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
What's the status of this PR? I see a lot of conflict with main, I think this one should be rebase to have a change to be merged :D |
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
This PR was closed because it has been stalled for 7 days with no activity. |
|
This PR was closed because it has been stalled for 7 days with no activity. |
|
apologies for losing track of this PR updates here. but I do plan to pick this one up again sometime soon. |
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
This PR was closed because it has been stalled for 7 days with no activity. |
|
This PR was closed because it has been stalled for 7 days with no activity. |
This PR attempts to replace the existing strcase library with a different implementation to fix #7941
In addition to replacing the library, we are moving this implementation to a local dagger package (currently under
dagqlfolder, more on this later), so that:Why is this under
dagqlfolder?I considered a few options e.g.
core,internalor a new pkg under root anddagqlseemed like the best option among those. Alsodagqlwas a common dependency for most of the places where strcase is currently used.Although, for sdk-runtime, it seems like there is no dependency on dagger's core/dagql package, so right now we are duplicating the code from strcase pkg into those files. But this mean, they can go out of sync quickly.
how do folks feel about adding a dependency from sdk-runtime onto dagger/dagql package? (one option could be to have a separate repo under dagger, but that seemed like an overkill).
i am open to suggestions here if folks think we can move the strcase package elsewhere.