Feature request: import from (own) unpublished version of already published notebook

Use case:

I’ve created a notebook defining the adot template literal that I offer others to use.

I’m now adding functions to it and want to create tests of it in another notebook, but since I can’t import the unpublished version of the adot notebook, I’m forced to put the tests in the same notebook as the definition.

This clutters the notebook so I wouldn’t like to publish it with the test in it. If I fork a backup copy and then remove them in the “production” notebook, I have to cut-and-paste them back and forth.

Also, in this way I’m not testing that the import itself works.

I would be satisfied to be able to import only from my own unpublished notebooks.

From https://beta.observablehq.com/@mbostock/introduction-to-imports:

You can only import from published notebooks; you can’t import from draft notebooks, even your own. However, we’re planning on supporting “unlisted” publishing in the future, which would allow you to publish a notebook and import from it without it appearing in public feeds or on your profile.

That future is now here, so maybe it’s already possible. But how?


The future is here! If you “Share” your notebook, you can then import it from another one.


Then, in your notebook:

import {cell} from "866e77fcce6e40fa"

… replacing the notebook id with the notebook that you’ve just shared. Cheers!


Thanks. I wasn’t aware of that and it’s very useful, but I would like to import an unpublished version of an already published notebook. Sorry for being a bit unclear. I seem to be getting the published version always.

I see. Yes, I’m afraid we don’t provide a way to import (or share) unpublished versions of published notebooks … yet.

When we expand the way you can interact with a notebook’s history, this is the sort of thing that should become possible.

Interesting. Won’t this get exported though, kind of defeating the ‘non-publishedness’ on the original code?

Apparently not: https://api.observablehq.com/@kelleyvanevert/import-unpublished-secret-stuff.js?key=1f62dcb9e4f5275b — the original says “hello, world”, but the exported code indeed excludes the unpublished notebook, and hence the runtime fails. (“RuntimeError: secret could not be resolved”)

@kelleyvanevert — the inability to export notebooks that themselves imported shared (but not yet published) notebooks was an oversight on our part. Now corrected.

If you look at your import-unpublished-secret-stuff.js URL again, you’ll see that it now bundles the shared notebook, as it should.

Hmm, OK. But the combination of the following does seem a bit weird to me:

  • If you have an unpublished notebook with some url /d/as9d87fsayufd8d, you will not be able to import with import { v } from 'as9d87fsayufd8d' — which I find reasonable, as you haven’t published it yet, hence it should be private.
  • If you ‘share’ this notebook, it just copies the same link it already has, and ‘under the hood’ sometimes changes, so that now import { v } from 'as9d87fsayufd8d' does work (and, maybe, just imports the last version that you ‘shared’). — I think it would be a bit more logical / semantic if the shared url would be something like /shared/as9d87fsayufd8d (so there’s no implicit ‘under-the-hood’ logic to whether the import is allowed, the info is in the url) or /shared/as9d87fsayufd8d/v/12 (nothing the shared version, which only makes sense if multiple shared versions are possible) or /shared/092u3i99898 (an entirely new ID, to emphasize the static copy of the version at share-time).
  • You might want to import some small piece of secret code, such as an API token. [I think that question sprung up somewhere in the past in this forum.] For that use-case, I think it would be reasonable if you were able to import cells from your own, unpublished, unshared, notebooks?