vgrechin
I redefine a module in my livebook for educational purpose in order to demonstrate evolution of code within the same page.
I migrating the notebook to v0.9.2 and I encounter an error. How can I now redefine the module within the same page of Livebook?
** (CompileError) notebook/MyNotebooks/Notebook1.livemd#cell:xb7luhdi543e3ttejayalzbnuf3crtgd:1: module MyModule is already defined
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 15 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
pasniak
New joiner here. It’s very unintuitive. Wouldn’t a solution be to restart a livebook (a bit like jupyter restarts a kernel wiping all state)?
(I am on mac (v.0.14.5) but could not find a way to restart.)
vgrechin
Thank you very, @linusdm for the detailed explanation of Livebook internals, but still can not observe evidence of the regression occurred in 0.8.0. When I tried to build 0.7.2 with Elixir 1.15-rc.2 just encountered a severe run-time error:
linusdm
Ah yes, now I see where my thinking was not correct. I totally forgot about the concurrent aspects of running Elixir code
.
There would indeed be no way to make such a system behave consistent. Thanks for clarifying!
josevalim
That’s exactly the issue. Module names are global, so how can you make only subsequent cells see a given module definition? Even if you say: “well, we will purge and swap module versions before execution”, you can still have long-running processes and other functionality that will now be swapping modules on the fly.
Redefining a module is global mutable state and, if you want reproducible notebooks, then it won’t work.
linusdm
Just to be clear: a failure when redefining a module is intended behaviour since Livebook 0.8.0 (see the changelog about “Improved reproducibility of module definitions”). That’s what you’re seeing. You previously were running on an older version of Livebook that was ok with redefining modules (with the problem of not being fully reproducible, as José mentioned) which is why you had no problems back then. Nothing in Elixir itself changed in any way, regarding this. Livebook is more restrictive to make sure all livebooks are reproducible (run in the same way, no matter in which order you execute the cells). Regular Elixir allows you to redefine modules (it emits a warning if you do) afaik.
vgrechin
Dave, I can not confirm yet that this problem has any relation to Elixir as language. I’m only upgrading livebook which also a great tool for sharing thoughts under very active development.
My latest observation that these cells were fine on Elixir v1.13.4 + Livebook v0.6.2
Now I’ve got Elixir v1.14.2 and Livebook v0.9.2. I’ll conduct more trials when Elixir v15 is released in order to upgrade my environment.
linusdm
I’m not sure if reproducibility can’t live together with redefining modules. For tutorials where there is a need to redefine a module over and over to evolve it over time, the only requirement is that the current cell, and all subsequent cells see the new module definition. I don’t think there would be confusion when the new module definition has no effect on previous cells, on the contrary, it’s kind of expected (which is exactly the reproducibility effect at work). If redefining a module has no effect on previous cells, then I don’t see how reproducibility (a non-negotiable property, I agree!) is in danger.
I see how it’s difficult to implement though, as module definitions live in a mutable global space.
You could think of the code cells as each defining their own closure, where the next code cell is closing over the previous cells to encompass it’s module definitions (and other bindings).
shortlyportly
Thanks @josevalim. I understand. Livebook is still brilliant and I’ll carry on using it (even if I can’t redefine modules
)
cheers
Dave
josevalim
We don’t plan to allow this because it completely messes up with Livebook ability of writing reproducible code.
If you redefine a module, and evaluate a previous cell, it gets the result of the new module, and now all of your computations may get out of sync.
shortlyportly
Hi @jonatanklosko.
I have the same issue with livebook (which I think is an amazing piece of software). Would the core team be open to adding a feature that did allow you to redefine a module. Would we need to raise this against the GitHub repo?
cheers
Dave