observablehq / feedback

Customer submitted bugs and feature requests
42 stars 3 forks source link

RuntimeError when versions of directly and indirectly imported notebook differ #466

Open flurrux opened 2 years ago

flurrux commented 2 years ago

Describe the bug

sometimes, when the version of a notebook differs across multiple notebooks that depend on it, and those notebooks are imported together, it throws a RuntimeError.
I have entcountered this error multiple times now and had to update the dependencies of each imported notebook to their latest versions to fix it.

To Reproduce

here is a link to the main-notebook: https://observablehq.com/d/bbbce669a706cd3a?collection=@flurrux/observable-import-error

CobusT commented 2 years ago

Thanks for the detailed report! We will look into it asap.

duaneatat commented 2 years ago

We should improve the user experience here, since this can happen with the following steps:

  1. All of the notebooks were private and everything worked
  2. The imports were then locked.
  3. And then more edits were made.
  4. Published all three

Since published notebooks can't import unpublished versions, and the locked versions are unpublished (because after making edits, the version that is published is > the locked version), the import will then fail. This notebook https://observablehq.com/d/77a8cdd5590aed12 has locked this imported notebook at version 10, which is not published: https://observablehq.com/d/7e49ef484449dd9a@10

We should warn users when publishing notebooks that have imports that are locked at private versions to avoid this.

flurrux commented 2 years ago

I've repeated the steps and published each version along the way, but the error persists.
here is the new main notebook: https://observablehq.com/d/d7ae020541532e26 the intermediate version of the new math-util is now public: https://observablehq.com/d/e9306e44623d5a81@10

duaneatat commented 2 years ago

I see the issue now, thanks so much for your patience on this.

The problem is actually that, with the way that we have implemented Version locking, it's not possible to import vec2Sum from the vector util without getting an error. The reason is that, at the time of import, we ignore the locked versions of the imported notebook. So you end up indirectly importing the latest version of the math util notebook, which is incompatible with the vector util notebook.

vector util imports sum from math util, locking math util at version 10 (which exports the sum) cell.

When you import vec2Sum from vector util, we get the latest version of all direct and indirect imports, and ignore the locked versions in vector util, so you end up indirectly importing math util at the latest version, which doesn't export sum and is incompatible with vector util.

Here is a notebook that reproduces the issue without needing multiple imports: https://observablehq.com/d/3560bc755a254c3a

This behavior was the subject of a lot of internal debate, and I'll raise this issue again internally to see what we can do to help in this circumstance.

In the meantime, the only recourse you have is to update the vector util notebook so it imports the latest version of math util (and fix the incompatibility there).

Thanks for raising this issue, I will update here with any progress we make 🙏