livebook-dev / livebook

Automate code & data workflows with interactive Elixir notebooks
https://livebook.dev
Apache License 2.0
4.96k stars 427 forks source link

Using a Livebook for traditional Elixir development #198

Closed losvedir closed 3 years ago

losvedir commented 3 years ago

First: what an amazing project! I've been playing around with it these last couple days. Since I develop in Elixir at work, I usually have an iex shell open to try out little bits and pieces. Now I'm using a Livebook for that, and it's great!

Now I'm wondering how to integrate a Livebook further into a more traditional Elixir development workflow. (Feel free to close this issue if that's out of scope; so far it seems this tool is mostly about data science and ML exploration?) My immediate hurdle is trying to do something like iex -S mix from within my application directory. I.e., getting an iex shell, with all my modules loaded and the app started. Is there a way to fire up a Livebook "in the context" of an application like that?

And then maybe a further step would be doing actual development of the application from the notebook. Maybe this isn't the right tool for that job vs. something like VSCode, which has language server integration and all that, but watching the screencast and seeing the iteration on the code made me think that might be a great way to iteratively explore and build up modules in my application. I guess then the last step would be exporting the notebooks as .ex files or something. I'm thinking along the lines of nbdev here.

jonatanklosko commented 3 years ago

Hey @losvedir, you can definitely load your Mix project into Livebook! The easiest way is to open "Notebook settings" (icon in the left panel), then under "Runtimes" you just pick Mix and specify the project path. Having that you should be able to access all the modules and dependencies as with mix -S iex.

For completeness I'll mention that you can also run iex --sname teacup -S mix and then under "Attached" runtime connect to teacup. Using the Mix runtime should be easier in most cases, but if you want to have both iex and Livebook running together, you can do that :>

As for the .ex export, that's definitely on the roadmap. We plan to have .exs scripts with markdown as comments, and perhaps something to export only module definitions, etc.

I think this covers what you described, but let me know if I missed anything! :cat2: