Skip to content

Suggest extension names and versions in nwbInstallExtension - #936

Draft
ehennestad wants to merge 4 commits into
test-extension-installationfrom
complete-extension-versions
Draft

ehennestad wants to merge 4 commits into
test-extension-installationfrom
complete-extension-versions

Conversation

@ehennestad

@ehennestad ehennestad commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Problem — A user who installs a specific release with nwbInstallExtension(name, version) (#932) has to look up the available versions on PyPI, because MATLAB suggests nothing for either argument. Typing nwbInstallExtension("ndx-miniscope", offers no versions, although ndx-miniscope has seven releases, from 0.1.0 to 0.5.1. MATLAB suggests argument values only for functions listed in resources/functionSignatures.json, and nwbInstallExtension has no entry there.

Solution — nwbInstallExtension gets a signature entry. MATLAB suggests the catalog extensions for the first argument, and the released versions of the chosen extension for the second. The extension names come from a new enumeration, matnwb.extension.CatalogExtension, so the suggestions work offline.

What changed

  • After nwbInstallExtension( MATLAB suggests the names of the extensions in the Neurodata Extensions Catalog, without network access.
  • After nwbInstallExtension("ndx-miniscope", MATLAB suggests the released versions of ndx-miniscope.
  • The versions are read from PyPI the first time an extension's versions are suggested in a MATLAB session. If PyPI does not answer within two seconds, there are no version suggestions, and no error.
  • matnwb.extension.CatalogExtension has one member per catalog extension, for example CatalogExtension.ndx_miniscope, whose Name is "ndx-miniscope". CatalogExtension.listNames() returns all names.
  • nwbInstallExtension and matnwb.extension.installExtension check names the same way: against CatalogExtension first, and against the online catalog only for a name it does not list. Names in CatalogExtension need no network access, and an extension added to the catalog after this version of MatNWB can still be installed with either function.
  • An unknown name fails with NWB:InstallExtension:UnknownExtension in nwbInstallExtension, instead of the generic mustBeMember error, and with NWB:InstallExtension:ExtensionNotFound in installExtension, as before. Both messages name the extension and list the valid names; the installExtension message used to put the list where the name belonged.
  • Called without an argument, nwbInstallExtension lists the names in CatalogExtension without reading the online catalog.
  • The update_extension_list workflow regenerates CatalogExtension.m together with nwbInstallExtension.m from the catalog, and commits both.
Implementation notes
  • The entry uses choices= expressions. MathWorks documents that the expression "can refer by name to other input arguments that appear in the argument list" and is evaluated at run time (Customize Code Suggestions and Completions), so the version choices are matnwb.extension.internal.listVersionChoices(extensionNames).
  • matnwb.extension.internal.isCatalogExtension holds the shared check.
  • The name choices are matnwb.extension.CatalogExtension.listNames(). Enumeration member names must be valid identifiers, so each member is the identifier form of the name (ndx_miniscope) and holds the name as its Name property.
  • tools/maintenance/matnwb_createNwbInstallExtension writes +matnwb/+extension/CatalogExtension.m from resources/function_templates/CatalogExtension.txt. The arguments block of nwbInstallExtension no longer lists the names; its docstring still does.
  • listVersionChoices returns a cell array of versions from listPypiVersions (Install the extensions an extension requires #933), cached per extension in a persistent map. It returns {} when the first argument is not a single name, the extension does not exist on PyPI, or PyPI does not answer within two seconds. listPypiVersions gets a Timeout option for this.
  • MATLAB sorts suggestions alphabetically regardless of the order a choices= expression returns them in.

Examples

Versions offered for an extension

The function behind the version suggestions, called with the extension name the user typed:

versions = matnwb.extension.internal.listVersionChoices("ndx-miniscope");
fprintf("versions: %s\n", strjoin(versions, ", "))

Before — The function does not exist, and nwbInstallExtension has no signature entry, so MATLAB has nothing to suggest.

After — The released versions of ndx-miniscope on PyPI.

versions: 0.1.0, 0.2.0, 0.2.1, 0.2.2, 0.4.0, 0.5.0, 0.5.1

How to test

In a MATLAB session with MatNWB on the path, type nwbInstallExtension( and press Tab to see the extension names, then nwbInstallExtension("ndx-miniscope", and press Tab to see its versions. Then run the install tests, which check the enumeration, the errors for an unknown name in both functions, and the version lookup, including the empty results for several names, an unknown extension and a non-text argument:

results = runtests("tests.unit.InstallExtensionTest");
disp(table(results))

Checklist

  • Have you ensured the PR description clearly describes the problem and solutions?
  • Have you checked to ensure that there aren't other open or previously closed Pull Requests for the same change?
  • If this PR fixes an issue, is the first line of the PR description fix #XX where XX is the issue number?

🤖 Generated with Claude Code

@ehennestad
ehennestad added this pull request to stack #934 October 4, 2026 17:02
@ehennestad ehennestad changed the title feat(extensions): suggest extension names and versions in nwbInstallExtension Suggest extension names and versions in nwbInstallExtension Oct 4, 2026
ehennestad and others added 4 commits October 6, 2026 20:10
…xtension

MATLAB now suggests the catalog extensions for the first argument of
nwbInstallExtension, and the released versions of the chosen extension
for the second. The signature entry uses choices expressions that MATLAB
evaluates while the user types, with the first argument passed to the
version lookup by name.

listVersionChoices reads the versions from PyPI once per extension and
MATLAB session. Both helpers return no suggestions instead of an error
when the catalog or PyPI cannot be reached.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The names of the catalog extensions were listed in the arguments block
of nwbInstallExtension, and the code suggestions read them from the
online catalog. The suggestions then needed network access and could
offer a name that nwbInstallExtension rejects.

matnwb.extension.CatalogExtension is an enumeration with one member per
catalog extension. nwbInstallExtension validates its first argument
against it, lists its names when called without an argument, and
MATLAB suggests its names. matnwb_createNwbInstallExtension generates it
from the catalog together with nwbInstallExtension.m, and the
update_extension_list workflow commits both.

Version suggestions still come from PyPI, but listVersionChoices waits
at most two seconds, because MATLAB waits for it while the user types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
matnwb.extension.installExtension checked the extension name against
the online catalog, while nwbInstallExtension checks it against
matnwb.extension.CatalogExtension. A name added to the catalog after
CatalogExtension.m was generated passed one check and failed the
other. Both now use CatalogExtension, so the check needs no network
access.

The error message named the list of extensions where it meant to name
the extension that was not found; it now names the extension and lists
the valid names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nwbInstallExtension and installExtension accepted only the names in
matnwb.extension.CatalogExtension, which lists the catalog as of the
last update of matnwb. An extension added to the catalog since then
could not be installed until matnwb was updated.

Both now check names with matnwb.extension.internal.isCatalogExtension,
which looks a name up in the online catalog when CatalogExtension does
not list it. Names in CatalogExtension still need no network access.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ehennestad
ehennestad force-pushed the complete-extension-versions branch from 1f0deec to 8937e45 Compare October 6, 2026 18:10

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant