AE
Ash Elixir•2y ago
Wout

Ash Tutorial With Livebook

GitHub
GitHub - woutdp/ash_tutorial
Contribute to woutdp/ash_tutorial development by creating an account on GitHub.
32 Replies
Wout
WoutOP•2y ago
Demo of what an Ash tutorial with Livebook could look like
Billboz
Billboz•2y ago
Thanks for putting this together!!! I am going to go through this right away
Wout
WoutOP•2y ago
Nice! Let me know if you have any feedback + it's still missing some chapters @Billboz was wondering if you managed to go through it. Was it useful? What's missing for you? Still expanding it but wonder what a good first version would be
Billboz
Billboz•2y ago
@Wout Yes, this is a fantastic resource for learning the basics of Ash! It would be fantastic to have a badge for this livebook in the Ash guide as a secondary resource for learning about Ash, @core-team.
You did a great job keeping your instructional style consistent and the instructions seem to be complete, well done! This is close to what I would consider good enough to be included in the documentation. I would like to see some links to the appropriate Ash documentation, similar to what are in the current docs. For example, when 'create_timestamp' was introduced add the link to the documentation https://ash-hq.org/docs/dsl/ash-resource#attributes-create_timestamp. I am sure you have intentions of doing this already. If you would like some help with the simple stuff like that then lets chat :). I offer to help with the simple stuff because I am at the relative beginning of my programming journey.
Ash HQ
Ash.Resource
View the documentation for Ash.Resource on Ash HQ.
ZachDaniel
ZachDaniel•2y ago
@Billboz thanks for the recommendation 🙂 I'll chat about this with the rest of the team. If we include it in the documentation, then realistically we'd need to "own" it (i.e it would need to live under ash-project/ash_livebook_tutorial, if you're open to that idea @Wout (you'd still have full access to the repo) then lets chat 🙂
Wout
WoutOP•2y ago
@Billboz thanks for that, yes some links to the docs are a good idea. I'll make work of that. @Zach Daniel I'd be perfectly fine with that, as long as I can edit them it's good 🙂 I'll be working on it a bit more, there are still a bunch of Ash concepts I can tackle
Wout
WoutOP•2y ago
I've added some more tutorials:
No description
Wout
WoutOP•2y ago
It's a good base, doesn't cover everything in Ash but that's not necessary for it to be useful. Would love to have it expanded with more advanced topics, but for now I'll stop working on it. Also happy to take contributions and feedback Like mentioned I'd be fine with making it an official tutorial resource and move the repo into the Ash project
ZachDaniel
ZachDaniel•2y ago
I think this is coming alnog really well I keep meaning to talk w/ other core team members about this and go through it with them see how we feel as a group about bringing it into the fold and point users there from the site
Wout
WoutOP•2y ago
Thanks @Zach Daniel Let me know if you have any feedback for it, happy to adjust wherever necessary for it to become an official documenation resource
gee5plus1
gee5plus1•2y ago
As per discussion I'm adding few ideas to consider for more advanced tutorials. These are something I am planning to experiment with and I believe they do touch on more advanced topics but are also quite relatable in the real world so it could be a good resource of inspiration for the community. (Note, as I'm new to the ecosystem I'm not sure how feasible they are from the point of view of what the framework would do, but having gone through initial guides and few additional resources for me these would be the next logical step to try out) 1. Mapping resource to external api. Let's assume there is a REST api handling CRUD operations for a collection. Create resource with CRUD support wrapping the external api so internally it can be treated as just another resource, while it's using REST to manage the state. (This in fact could reuse previous tutorials where rest api is being created in Ash - for example, let's say a follow up of Ticket resource from the guide) Things to consider in the scenario: - Authorization headers need to be present - Capturing different rest statuses and mapping to :ok, :error - Transaction support for typical resource with rest based resource - Handling situations where REST api is down 2. Two separate authentication flows for a single app. Let's consider an appolication composed of 3 pieces of functionality: - standard website - customer area (ash authentication) - backoffice (ash authentication, different strategy) Customer and Operator are treated as separate resources with different auth strategies, both use ash authentication but also both have different styling considerations for built-in sign-in/sign-out pages. 3. Many to Many with metadata Let's consider two standard resources: Article and Image, where there is many-to-many relationship between them, but also the join table has extra fields: - label (string) - order (integer) In such scenario let's consider an article, where every image can optionally have one of the two fields filled. Use cases for this can be as follow: - mark label as 'cover' so the article can display predefined image on a listing page - display article images in predefined order Things to consider for the tutorial part: - the way to load metadata when loading articles (as a list) - the way to load metadata when fetching individual article - for 'cover' use-case add calculation that would populate the cover attribute with Image record if one is present in such collection 4. User with Role Two linked resources User and Role, and a set of policies to apply to say Article resource based on the Role queried from datastore. Simple but also expanding on the policies topic with more advanced example. @Wout As discussed, have a look, see if any of it makes sense 😉
Wout
WoutOP•2y ago
Thank you these are great 🙂
gee5plus1
gee5plus1•2y ago
There are more where this came from 😉 but these topics were at the top of my list to see how similar things can be done in Ash, with Ash mindset also, I know it's probably contentious topic, but good practices for solving some of these puzzles would probably be a good thing to. For me, as a beginner, it helps to see the opinions and learn good habits early. Later on I might disagree and take on a different route once I know the toolset but to start with, good habits are long term benefit imho oh, and I volunteer to test drive the livebooks 😛
Wout
WoutOP•2y ago
I think that's not contentious at all. For me I learn best when I can do things, and it helps to early on follow a certain style/best practice so I can focus on understanding core concepts. Then later on, like you said, you can divert in style and practices where you see fit 🙂
gee5plus1
gee5plus1•2y ago
btw, ignore bulletpoint indentations, can't seem to get them to the same level
Nefcairon
Nefcairon•2y ago
@Wout Just started with it. Thanks for creating this. Is there a reason why the order is "show solution" and then "enter your solution" and not the other way? Further I get the warning
warning: the Inspect protocol has already been consolidated, an implementation for Tutorial.Profile has no effect. If you want to implement protocols after compilation or during tests, check the "Consolidation" section in the Protocol module documentation
warning: the Inspect protocol has already been consolidated, an implementation for Tutorial.Profile has no effect. If you want to implement protocols after compilation or during tests, check the "Consolidation" section in the Protocol module documentation
Wout
WoutOP•2y ago
Thanks for the feedback, that warning is something I also get, not sure why but you can ignore it. Maybe there's a way to disable it, not sure The order of the show and enter solution can be changed if it makes more sense that way, I would be open to that 🙂 got the main structure from the dockyard tutorials
ZachDaniel
ZachDaniel•2y ago
Hey @Wout I've got more than a few pieces of great feedback on this, sorry for the delay. I'm going to put this up on the website. Would you mind giving me contributor access to the repository? Actually, perhaps you could transfer it to the ash organization, and I can grant you access to make edits/merge things? Once we get that settled, I'll put up the badge on the site and in the docs 🙂
Terris
Terris•2y ago
If this gets moved can someone please post a note to #announcements-archive or #showcase or ... ?
Wout
WoutOP•2y ago
So sorry @Zach Daniel I had this channel muted! Let me know what should be done, I can give you access or I can transfer it. I just tried transferring it but it is blocked since another repo already exists. https://github.com/ash-project/ash_tutorial I can rename it or you can remove the archive, let me know what you'd like to do
GitHub
GitHub - ash-project/ash_tutorial: The Ash Tutorial Book
The Ash Tutorial Book. Contribute to ash-project/ash_tutorial development by creating an account on GitHub.
Wout
WoutOP•2y ago
No description
ZachDaniel
ZachDaniel•2y ago
Giving me access would be the best way to:) And I’ll figure out the name conflict there I’d need like super user access to be able to move it I assume
Wout
WoutOP•2y ago
I've sent an invite Checking how I can give super user access Or maybe you have already?
Wout
WoutOP•2y ago
I think that worked?
No description
ZachDaniel
ZachDaniel•2y ago
Alright, moved over to ash org 🙂 https://github.com/ash-project/ash_tutorial
GitHub
GitHub - ash-project/ash_tutorial: A Tutorial for Ash
A Tutorial for Ash. Contribute to ash-project/ash_tutorial development by creating an account on GitHub.
ZachDaniel
ZachDaniel•2y ago
Next step is to put up a badge notification on ash-hq 😄 I will try to get to that in the next few days, but @Wout if you are interested you could PR to ash-hq 🙂
Wout
WoutOP•2y ago
Any specific place you think would be good to put it?
ZachDaniel
ZachDaniel•2y ago
🤔 not really sure! I think maybe next to the Get Started button on the front page, and then maybe just a markdown badge at the top of the guide in ash core I'm pretty sure the markdown parser should handle badges I hope 😆
Wout
WoutOP•2y ago
No description
No description
Wout
WoutOP•2y ago
yes no? maybe hide on mobile as I don't think anyone is running livebook on mobile https://github.com/ash-project/ash_hq/pull/115 https://github.com/ash-project/ash/pull/685
ZachDaniel
ZachDaniel•2y ago
🔥 its released 🙂 @Wout do you have a twitter handle?

Did you find this page helpful?