Repository navigation
Suggest extension names and versions in nwbInstallExtension - #936
Draft
ehennestad wants to merge 4 commits into
Draft
ehennestad wants to merge 4 commits into
ehennestad wants to merge 4 commits into
Conversation
ehennestad
added this pull request to stack #934
October 4, 2026 17:02
…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
force-pushed
the
complete-extension-versions
branch
from
October 6, 2026 18:10
1f0deec to
8937e45
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. TypingnwbInstallExtension("ndx-miniscope",offers no versions, althoughndx-miniscopehas seven releases, from 0.1.0 to 0.5.1. MATLAB suggests argument values only for functions listed inresources/functionSignatures.json, andnwbInstallExtensionhas no entry there.Solution —
nwbInstallExtensiongets 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
nwbInstallExtension(MATLAB suggests the names of the extensions in the Neurodata Extensions Catalog, without network access.nwbInstallExtension("ndx-miniscope",MATLAB suggests the released versions ofndx-miniscope.matnwb.extension.CatalogExtensionhas one member per catalog extension, for exampleCatalogExtension.ndx_miniscope, whoseNameis"ndx-miniscope".CatalogExtension.listNames()returns all names.nwbInstallExtensionandmatnwb.extension.installExtensioncheck names the same way: againstCatalogExtensionfirst, and against the online catalog only for a name it does not list. Names inCatalogExtensionneed no network access, and an extension added to the catalog after this version of MatNWB can still be installed with either function.NWB:InstallExtension:UnknownExtensioninnwbInstallExtension, instead of the genericmustBeMembererror, and withNWB:InstallExtension:ExtensionNotFoundininstallExtension, as before. Both messages name the extension and list the valid names; theinstallExtensionmessage used to put the list where the name belonged.nwbInstallExtensionlists the names inCatalogExtensionwithout reading the online catalog.update_extension_listworkflow regeneratesCatalogExtension.mtogether withnwbInstallExtension.mfrom the catalog, and commits both.Implementation notes
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 arematnwb.extension.internal.listVersionChoices(extensionNames).matnwb.extension.internal.isCatalogExtensionholds the shared check.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 itsNameproperty.tools/maintenance/matnwb_createNwbInstallExtensionwrites+matnwb/+extension/CatalogExtension.mfromresources/function_templates/CatalogExtension.txt. The arguments block ofnwbInstallExtensionno longer lists the names; its docstring still does.listVersionChoicesreturns a cell array of versions fromlistPypiVersions(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.listPypiVersionsgets aTimeoutoption for this.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:
Before — The function does not exist, and
nwbInstallExtensionhas no signature entry, so MATLAB has nothing to suggest.After — The released versions of
ndx-miniscopeon PyPI.How to test
In a MATLAB session with MatNWB on the path, type
nwbInstallExtension(and press Tab to see the extension names, thennwbInstallExtension("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:Checklist
fix #XXwhereXXis the issue number?🤖 Generated with Claude Code