-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feedback on examples #1432
Comments
Regarding dependencies, this is sadly a general Rust problem which every project with examples will run into. We are pushing people towards using https://github.com/esp-rs/esp-template and picking parts from examples across for the time being. We want to improve the template further, but there are currently some limitations with cargo-generate: cargo-generate/cargo-generate#1054. As for features, each example has its features and supported chip listed at the top level docs. We use this metadata in our xtask subcommand to auto enable the features (instead of having to specify them yourself if using cargo directly). Thanks for the feedback! In this case I don't think we have anything we can action at this time, but if you some concrete ideas on how to improve our current situation please file another issue :). |
The problem I think is that going from an example to something standalone is really hard. Lets take I think my "frustration" is that it's hard to isolate what each example actually depends on and requires. it's hard to pick it apart into what you really need. That's why I think there needs to be a way to split this up, because while it may be convenient for tests, it's not serving as a useful example if I can't take it and action what it contains. An example is after all meant to educate on basic operation of a task and how to create and configure the ecosystem so that example can run. Especially when embassy is so "feature complex". |
Additionally it would be great if the cargo-template included an embassy variant too :) |
How about this as an idea - there needs to be a "glue" crate. Currently, a cargo.toml to build something looks like this:
And I had to copy paste huge parts of this from esp-wifi and it's multiple Cargo.toml files, and it still doesn't work. The issues are:
Going from This is why I think a "glue" crate would be useful. This could be something like 'esp-glue'. It could have features that describe high level concepts like:
This way a consumer's cargo.toml could be:
Examples could then be part of the glue crate since it's much easier to include. This would allow a tokio style library https://docs.rs/tokio/latest/tokio/#feature-flags where you enable what you are using, or could just opt into "full" if you wanted. It would also allow board selection to be much easier. Within the glue crate it could exposed tested and coordinated sets of libraries that are known to work together, via things like esp-glue::{wifi, net, embassy} etc. That way a user never has to worry about things like "which version of embassy and embassy net worktogethr with esp-hal, and what features do I need? " I think this would greatly improve the new user experience as well as existing users. |
Thank you for the feedback, it's really valuable! Something like
I agree, I've run into this with other projects too. My strategy is to copy all the deps, and get it building, then cut away deps one by one. This is obviously not ideal though. Having something like I think as an actionable item here, we can also try to document our deps and what they're needed for in |
It's pretty likely something like the "glue" crate could also just make it easier in general to upgrade versions too since it defines a working combination of parts. So I'd be more than happy to test that when you start to work on it (heck, I was tempted to throw together a basic one and try to expand it a bit if I got more parts working). |
I think a comment was added and then removed, but to address this point because I think it's really important. We have to look at this as "costs". By having a glue crate, you the maintainers of the project are in control of saying "what parts work together, and what doesn't". Yes, that does take work. Yes it does come with challenges when breaking changes are made to re-asses "what parts do work together?". But today you already have that cost. You need to pay this cost to keep every example working under all these moving parts. So this "glue" suggestion actually helps you, because instead of having to upgrade every crate and example, you can fix the part moving puzzle in a single location rather than many locations. In addition, think about how this feels as a consumer of the ecosystem - without the maintainers putting up some of this work (work that you already have to do because of the examples as noted), your consumers now also need to pay this cost. Not only this, they need to do so without the same level of subject matter expertise as you have. There are many smart users of your ecosystem, but they may not have all the insight you have to enable them to resolve which changes work together. For example , every time I go to update an esp-rs project, I can't just "upgrade" it. I have to create a new project from a new version of your cargo template, and then lift and move bits at a time. Because when I do try and upgrade, everything breaks in subtle and unexpected ways that I simply don't have the knowledge to solve. So I think while yes, a glue crate is work for you as maintainers, it's work you already have to perform in your projects, and it hugely benefits your users. The more users you have, and the more you empower and enable them to use your libraries, the more they will be able to step up and help and contribute in other ways. |
I've thought about this, and I've just created a repository, esp-examples, to try and add some standalone examples to illustrate the dependency options. I'll add them as soon as I have time. |
I'll check it out and try to help out if I can make some more. Thank you so much <3 |
We've recently merged many dependencies into the esp-hal tree directly. This doesn't solve all the issues you've mentioned, and a glue crate is still something we're thinking about for the future, but we hope it will improve the situation a little bit for now. |
Thank you! I did notice this actually, so I'll have to try it later. |
We had discussed removing the current example and replacing them with standalone projects, in a similar fashion to how things are done in ESP-IDF, to try and make it easier for users to get started from examples. With @MabezDev not sure if you'd like to discuss this in a meeting or just have the conversation here, but I'll leave that decision to you. Either way, I think our current approach to examples is not sustainable (or particularly useful), demonstrating how to use specific drivers should be relegated to the documentation IMO and we should provide more interesting examples. |
From a user's perspective turning the examples into standalone projects would definitely be a good thing. I guess it would be more effort maintaining them but if we reduce the number of examples (by removing the "not so awesome" ones - maybe turning them into tests if we can) - that's maybe not much of a problem 🤔 |
I think that while it's great there are so many examples, the issue is that because they all depend on one large Cargo.toml, it's very difficult to see which parts of the cargo.toml are actually needed to build any feature or part of the example in isolation. It would be better if the examples were broken out in some way so that it was clear which features they require, and which dependencies they rely on.
The text was updated successfully, but these errors were encountered: