European-XFEL / EXtra-data

Access saved EuXFEL data
https://extra-data.rtfd.io
BSD 3-Clause "New" or "Revised" License
7 stars 14 forks source link

Add source, key & alias completions for IPython #514

Closed takluyver closed 7 months ago

takluyver commented 7 months ago

A picture is worth a thousand words:

image

I've tested all three interactively.

Thanks to @JamesWrigley for reminding me of this hook. It was actually something that I implemented in IPython. :grin:

philsmt commented 7 months ago

This is awesome!

I am wondering if we can somehow avoid suggesting a DataCollection can only be indexed by sources. Maybe add some notion behind each source string it could optionally be followed by keys, even if we cannot reasonably include them? Even a count of keys seems overly expensive, unless we'd use sel_keys if present.

takluyver commented 7 months ago

I see what you mean, but I don't see a great way to do that in completions. This _ipython_key_completions_ hook is a very convenient API, but not a very powerful one - it doesn't give you any ways to insert a comment (which would be annoying anyway) or annotate the results at all.

So I'll argue that we should just keep this simple and live with the limitations.

philsmt commented 7 months ago

LGTM

takluyver commented 7 months ago

Thanks!