#Rust SDK
1 messages Β· Page 1 of 1 (latest)
I am taking heavy inspiration from the python one. As the general interaction from go was a bit confusing. And as a side project I'd rather keep it purely in rust.
I am starting with a simpler set of rules, as to not be bogged down by the specifics, I also need to figure out the API, and I can first get a feel for it when I've got a working example.
I will reach out if I am blocked, that said the only wildcard is the querier to the session. But that is mostly because I haven't gotten around to looking at the code just yet.
Making good progress, I've only got the object type left (it is the largest by far though =D, also need to align it with existing sdks, sorting, naming and so on)
@proper kayak quick question.
I might be misunderstanding the NON_NULL type, but I am getting some conflicting results with the python sdk.
I generate a dockerBuild like so:
However, this is set as optional in the python sdk:
From my understanding the params shouldn't be nullable (Optional)
Source of truth is the API. It's not required here: https://github.com/dagger/dagger/blob/7ec2af948d04f3a4d005f5d223824b43b67127c0/core/schema/directory.graphqls#L64-L80
Great, that was what I was seeing as well. Should I fix the python api then as well?
But how's Python wrong?
The optional type in the args
If you look at the API they are indeed optional.
Ah, yes, missed the ! in the name =D. GraphQL is a bit interesting that it optional by default π
Yes π
Rust SDK
Yeah, itβs a weird behavior, optional by default
Marshaller to engine done. I am missing some graphql names, but those will be solved in the codegen parts. Missing the context sharing between the different objects but when that is done I should be able to replicate the quickstart
I haven't put too much energy into making it "rustaceaus code". In anticipation of the potential breaking changes in the coming release.
So it is relatively ineffecient atm, and I could shave off quite a lot of memory allocations. But this isn't really a requirement for this kind of app, so I'd rather not complicate it more than it needs to be π
implemented some stuff manually in the code gen to get a feel for it. Couldn't resist testing the full flow.
GQLClient Error: Failed to parse response: Error("invalid type: map, expected a string", line: 1, column: 8). The response body is: {"data":{"container":{"from":{"exec":{"stdout":"3.16.2\n"}}}}}
first container started trough dagger-rs.
Amazing @trim citrus ! The first of many hopefully π
Heyo, a little update. I had to rebuild the codegen. I could generate some of the internal code for the funcs, but the code quickly got out of hand. I've found a better approach, which is both more performant (not that it matters much as it is only the codegen part) and more intuitive.
I am not nearly at the position I was before, but it is close, and with a far more robust codegen engine.
Thanks for the update! Anything we can do to help?
Nah it is all good. I am quite comfortable with the direction now. Now my daily work has to stop burning so that I can actually spend a few evenings finishing the mvp
Aight, the MVP is done'ish.
https://github.com/kjuulh/dagger-rs/blob/main/crates/dagger-sdk/tests/mod.rs
I am having a bit of trouble with a few of the args, the ones with array of object (array of envVariables, projects etc), but I will work on it more in the evening.
Most of the functionality works as intended.
- My plan for now is to add tests for the generated output
- setup simple CI for building and versioning the project
- implement optional variant to reduce verbosity
- add optional async runtime
- fix return Vec<EnvVariable, Project, etc.>
- build the quickstart example
Very cool! π€©
the ones with array of object
You're not alone in that β https://github.com/dagger/dagger/issues/3457
Yep, I've not implemented bind and tree unpacking yet. As such I just unpack the leaf result (like what was done in nodejs). It wouldn't be that difficult to implement, but rust doesn't like linked lists or trees that much (shared memory is a pain) as such I've chosen the easy solution for now. It is solvable, just requires a bit of time =D.
What I meant is that returning lists of objects is not supported by the other SDKs either. We still need to find a solution for that.
sounds good. π
If you come up with something you can contribute to the discussion π
Will do π
There's a more recent discussion about that here in Discord: #maintainers message
I've added the quickstart to the project as well. There is still some quite verbose syntax. But I will deal with that at some point
I've improved the general API: https://github.com/kjuulh/dagger-rs/blob/c312bc57ad3e5380b6a2a927f3bb758aa5344efd/crates/dagger-sdk/examples/multi-stage-build/main.rs
Now there are separate methods for with Optional arguments, as rust doesn't have default type arguments.
Also spent some time fixing arguments to not require "".into() everywhere. This is because rust has different string types one on the stack and one on the heap. The heap variant which is used internally requires some conversion. However externally it is much nicer to use the stack variant "", as opposed to "".into() or "".to_string(). Also added a builder macro.
HostDirectoryOptsBuilder::default().exclude(vec!["node_modules"]).build()?,
// vs
HostDirectoryOpts {
exclude: Some(vec!["node_modules"]),
include: None,
}
I've also been spending some time using it myself in the CI I use to actually build the project π
https://github.com/kjuulh/dagger-rs/tree/main/ci
It is a bit more complicated that is probably necessary, but rust is SLO to build.
Missing async variant and comments and then I am satisfied π
Aaand it is done. everything should be up to par now. π
Nicely done!!
I've released dagger-rs to align with dagger: v0.3.14
https://github.com/kjuulh/dagger-rs/releases/tag/dagger-sdk-v0.2.15
Only minor changes required (first time we deserialize into an enum, sorry unmarshal π )
A little progress update.
Not much development had happened over the last few weeks except handling cases brought in by users. We've got a few which is nice to see.
@lost vector is also helping me when he has time which is awesome.
I am adding official ci support for all the major platforms, I am working on adding windows rn.
The next feature to be developed will probably be using an external dagger session.