#Schema views
1 messages · Page 1 of 1 (latest)
So after version applies to every version after X, all version applies everywhere
It exists because if you want a field to have a view, it has to have a view on every declaration of that field (e.g. you can't declare it without a view and then with a view later)
The reason for this is subtle, it's enforced with panics, but it has to do with ensuring that the IDs for everything generate are somewhat reasonable
I'm testing it out with shellcheck and it's failing to load. Do I need docs generate or something?
Uh oh, hm, if you check the engine logs, are there any failures in there? You might be hitting one of the panics I mentioned
(I tried for so long to see if I could type check it with generics, it's feasible, but requires adding type parameters to almost every single struct in the engine)
[buildkit] [trace=00000000000000000000000000000000] [client=7pl3l5dkslk97l9wbz24b4xfo] ------
[buildkit] [trace=00000000000000000000000000000000] [client=7pl3l5dkslk97l9wbz24b4xfo] > exec go build -o /runtime .:
[buildkit] [trace=00000000000000000000000000000000] [client=7pl3l5dkslk97l9wbz24b4xfo] 0.441 # github.com/dagger/dagger/dev/shellcheck
[buildkit] [trace=00000000000000000000000000000000] [client=7pl3l5dkslk97l9wbz24b4xfo] 0.441 ./main.go:120:34: cannot use dagger.ContainerWithNewFileOpts{…} (value of type dagger.ContainerWithNewFileOpts) as string value in argument to base().WithExec([]string{…}).WithWorkdir("/src").WithNewFile
[buildkit] [trace=00000000000000000000000000000000] [client=7pl3l5dkslk97l9wbz24b4xfo] 0.441 ./main.go:121:4: unknown field Contents in struct literal of type dagger.ContainerWithNewFileOpts
[buildkit] [trace=00000000000000000000000000000000] [client=7pl3l5dkslk97l9wbz24b4xfo] ------
Hm okay, is this failing on a dagger develop?
dagger-dev call -m dev/shellcheck --help
Is Shell check using a v0.11.9 engineVersion as well?
Sorry I'm on mobile now, can't easily check, my bad
Yep, success with dagger v0.11.9. And with dagger-dev success if I update the code to use the contents as the required argument. Without any extra develop.
Going to share my changes.
I have an idea
If you remove the extend does it work? (And just duplicate the rest of the bits for now)
I suspect I might have screwed that up maybe
The views part looks perfectly fine to me
Tldr, extend tries to do some magic where it "pulls the field spec from the previous declaration"
So it's probably keeping the optional declaration
Yeah, that worked! 🙂
Awesome 🎉 I'll have a think and maybe Extend is just bad and should be removed
Or needs rework
It's very annoying to have to repeat all the doc strings, etc when there are no changes to those
That's pretty cool, now it works with both stable and dev 🎉 Good job!
🎉
With the schema duplicated, would you use AfterVersion or keep AllVersion for the new changes?
No strong opinions? It shouldn't affect it, but it's easy to change later
Yeah, I guess I prefer AllVersion to avoid hardcoding a specific version. And easier later when we decide to remove the compat (although I guess you'd remove the AllVersion too) 🙂
Hmm... there's an issue I didn't foresee. Runtime modules need to be stuck on an older version or avoid using apis with splitting views, otherwise they can't load modules on those older versions.
Wait hm why can't they load older versions? They should be able to right?
That potentially sounds like a bug, I thought they should be able to
(maybe there's something here with the follow-up pr I merged? I might have fixed something very similar in that one)
I can take a look at anything tomorrow fyi, I'll catch-up from everything
Maybe there's no issue 🤔 My thinking was that a user with an older cli/engine version can't run a module with a newer engineVersion. So I extrapolated that to mean that if a user is on v0.11.6 and is trying to load a Python module with "engineVersion": "0.11.6" it won't be able to if the Python runtime module is on v0.12. But, if the user is using cli/engine v0.11.6 then they will get the v0.11.6 bundled version of the Python runtime, not v0.12. Anything newer is fine.
The Python runtime module has a call to Container.withNewFile so I included in the PR to change it, but the engineVersion was set to "dev". I basically reverted to use the latest release, like in the dev module. That's when I realize there could be an incompatibility, but the SDK's version is tied to the cli/engine so I think we're good.
My thinking was that a user with an older cli/engine version can't run a module with a newer engineVersion
technically this restriction doesn't exist yet - i suggested it in https://github.com/dagger/dagger/pull/7692#issuecomment-2191897660
i think we should probably have it 🎉
but the SDK's version is tied to the cli/engine so I think we're good.
yeahhhh, i think so too 😄 note, there is a bit of subtlety here, each module is always initialized with thedevversion, so custom sdks don't benefit from this change - i have some idea for how to do this, but we really only need to do this when we modify the typedef api
each module is always initialized with the
devversion
Not sure what you mean exactly. The runtime module did have a dev version, but I dagger develop with latest release so it's bundled with the previous stable version. Would you say it's ok for the bundled runtime modules to have a dev version in engineVersion to basically mean it would match whatever the engine it was bundled with?
sorry, yeah, i wasn't clear - each module gets served the api it suggests, but on first initialization where it serves it's typedef schema, i think it gets served the latest schema: https://github.com/dagger/dagger/blob/ee91be20b8d9d9314e88d7a6f4c504fec51d332c/engine/server/session.go#L467-L474
it's a super edge case right now, so i don't really mind about it for this release
Oh, I see. You're talking about the SDK lib, not the SDK runtime module.
yup, sorry, my bad
@regal osprey, how do you suggest we do something like the schema views directly in codegen for https://github.com/dagger/dagger/pull/7773 ? No changes in schema in this case. Just pass on engineVersion and have each codegen parse and compare versions, or something else?
so i added __schemaVersion alongside __schema - this is now in the introspection.json file passed to codegen
in https://github.com/dagger/dagger/pull/7831, i've also exposed this alongside a CheckVersionCompatibility function inside the go templates
i suspect you might need a combination of them both?