Updates to MalloyTranslator to enable model caching#2091
Merged
christopherswenson merged 14 commits intomainfrom Jan 13, 2025
Merged
Updates to MalloyTranslator to enable model caching#2091christopherswenson merged 14 commits intomainfrom
MalloyTranslator to enable model caching#2091christopherswenson merged 14 commits intomainfrom
Conversation
…ts parent was cached and therefore never created
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.
Changes
queryListintoModelDefdependenciestoModelDef, which is a nested object map (url to dependency tree)translate()method returns an object with amodelDef: ModelDef, rather than atranslated: { modelDef: ModelDef }translatorForDependencywhich returns the translator for a dependent URL.newlyTranslatedDependencies, which returns all dependencies that were newly translated{ translations: { [url]: ModelDef } }to theupdatemethod to provide pre-translated models. It us up to the user to only do so when those models are known to be up-to-date. The user may respond to{ urls: ... }requests in this way.Note, this preserves the
translate().fromSourcesproperty, buttranslate().modelDef.dependenciescontains the same information plus the tree structure. VSCode seems to prefer the flat version, so leaving it for now.Next Steps
Cachefor theRuntimeAPI, which hasget()andset(key: string)methodsCacheto be passed into aRuntimeon constructionURLReader.readURLto return both the file contents and an "invalidation key"getInvalidationKeytoURLReader, which should return the current invalidation key of a file.ModelCacheclass inmalloy.tswhich manages invalidation keys and decides whether a file can be retrieved from cache or should be recompiledtranslate().fromSourcesExample Dependency Traversal