Resolve toolbox dependencies by source identity and for component imports#299
Merged
Conversation
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.
Problem
Two gaps in the toolbox manager's dependency resolution:
1. Resolution keyed on the toolbox
id. Theidis a UI-construction artifact — the catalog uses a fixed id, the PyPI tab buildspypi:<pkg>, the file uploadinline:<filename>. It reflects how a toolbox was added, not what it is:inline:<filename>— two different.pyfiles sharing a name collide; opening a file treats the dependency as satisfied and silently uses the locally-installed code instead of the file's embedded code.2. Direct block/subsystem import resolves nothing.
requiredToolboxesonly exists onModelContent.createBlockFile/createSubsystemFilenever record it, andimportComponentnever installs anything — it just throwsUnknown block type(s): ...if the toolbox is not installed. ABubbler4block exported as.blkand imported on a machine withoutpathsim-chemhard-fails, even though the same block inside a.pvmmodel triggers the install flow.Fix
Source identity (
toolbox/identity.ts, new):toolboxSourceKey(source)derives a stable key purely from the install source —pypi:<pkg>(PEP 503 normalized),url:<url>,inline:<code-hash>.findMissingRequirementsnow matches ontoolboxSourceKeyinstead of the rawid, so a file referencingpypi:pathsim-chemresolves against a catalog-installedpathsim-chem, and inline toolboxes match by code rather than filename.confirmPyPI/confirmUrl/confirmFilebuild theidviatoolboxSourceKey— inline ids are content-addressed, so same-named uploads no longer collide.availableCatalogfilters by source identity, so a catalog entry installed via the PyPI tab no longer shows as available.Component imports:
BlockContent/SubsystemContentgain an optionalrequiredToolboxesfield.createBlockFile/createSubsystemFilerecord requirements viacollectRequiredToolboxes(recurses into subsystem graphs).importComponentis now async and installs declared toolboxes (same confirmation dialog as the model path) beforevalidateNodeTypes.