Files
eco/docs/tab_completion.md
Henrik Lemke 98d8e4a0c5 docs: "Did you know?" tips, pages for recent features, and a docs-site job
- docs/did_you_know/: one short tip per feature added since May 2026
  (<date>-<slug>.md, YAML front matter: added/tags/details), listed
  newest first; index.md describes the format for adding more.
- New pages for features that had none: launching, command_history,
  tab_completion, live_gui, tweak, scanning, status_server,
  channel_access, shared_files, schematic_panels. Wired into index.rst
  together with the existing queues page.
- Fix archiver_stripchart/listening_monitor: the method is
  archiver.strip_plot (strip_chart does not exist on DataHub); document
  the per-device .strip_plot().
- NAMESPACE_MONITOR_FORMAT.md: scan monitoring is wired into Daq's scan
  callbacks since 2026-09-09.
- scripts/eco-docs (+ -install-user-service): build the docs from an own
  clone and serve them over HTTP as user systemd units, rebuilt by a
  timer; a failed build never replaces the served site.
2026-10-25 14:26:52 +01:00

1.7 KiB

Tab completion on lazy devices

Most components in the Bernina namespace are lazy: they are only built (with real EPICS connections) the first time you use them. Tab completion has to look inside a device to list its children, so without care, pressing Tab would quietly build devices you never meant to touch.

Two Tabs to initialize

If the device you are completing into has not been initialized yet, the first Tab does nothing except tell you so:

In [1]: prepump.<TAB>
eco: 'prepump' is not initialized yet -- press Tab again to initialize it and complete.
In [1]: prepump.<TAB>
        check  gp  isolate_all  line1_usd  line2_lic  pump_down  roots_pump  show  vent  ...

The second Tab initializes it and completes as usual. This works at any depth (bernina.something.<TAB>) and still counts if you kept typing between the two Tabs.

Only the one component named in the expression is ever initialized, never its siblings that happen to share a prefix. Completing into a device that is already initialized works on the first Tab, as before.

What makes completion work on eco objects

You normally don't need to know this, but if completion breaks after an IPython upgrade, these are the three settings involved. eco sets them in every session it starts (terminal, desktop console, start_console()):

  1. Completer.use_jedi = False. jedi resolves every candidate to inspect it, which on a lazy namespace means initializing everything with a matching prefix. It also returns no matches at all on eco's dynamic objects.
  2. eco's lazy-proxy class is allow-listed in IPython's guarded_eval policy. Without it, completing two levels deep (prepump.line1_usd.<TAB>) silently returns nothing.
  3. The two-Tab gate described above.