Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rosetta): infused snippets not returned from cache #3291

Merged
merged 4 commits into from
Dec 24, 2021
Merged

Conversation

kaizencc
Copy link
Contributor

@kaizencc kaizencc commented Dec 23, 2021

Infused snippets do not have the right full source since we are adding the local fixture to the snippet
rather than the fixture from where the snippet came from. Since there is no hope in actually translating
an infused snippet (unless it is in the same directory), we might as well take any cache result as is.
So this PR adds logic that returns the cache result for infused snippets always.

This was tested on my local machine and dropped all errors from infused snippets. There are still errors
from directories that are not yet strict, which is understandable.

Also, the infuse command was missing cache-from argument that is present in infuseOptions.
We were using those options as part of rosetta extract --infuse but should be available via rosetta infuse
as well.

Also fixed up minor mistake in tests where I was testing for infused=true instead of infused=''.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Dec 23, 2021
@@ -149,6 +149,13 @@ export class RosettaTranslator {
function tryReadFromCache(sourceSnippet: TypeScriptSnippet, cache: LanguageTablet, fingerprinter: TypeFingerprinter) {
const fromCache = cache.tryGetSnippet(snippetKey(sourceSnippet));

// infused snippets won't pass the full source check or the fingerprinter
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do they not pass the fingerprinter? I tried to investigate this, and I can't really make sense of it.
Verified that the fqns are the same between fromCache.fqnsReferenced() and fromCache.snippet.fqnsReferenced. The only difference is that locally I removed the monocdk assembly and the fingerprinter takes in all assemblies at initialization. But I fail to see how that impacts anything here.

A bit of a cop out, but I think its unnecessary. We cant translate infused examples, so we might as well take what we've got. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised as well, but I agree with the solution. It's fine like this.

@@ -149,6 +149,13 @@ export class RosettaTranslator {
function tryReadFromCache(sourceSnippet: TypeScriptSnippet, cache: LanguageTablet, fingerprinter: TypeFingerprinter) {
const fromCache = cache.tryGetSnippet(snippetKey(sourceSnippet));

// infused snippets won't pass the full source check or the fingerprinter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised as well, but I agree with the solution. It's fine like this.

@mergify
Copy link
Contributor

mergify bot commented Dec 24, 2021

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Dec 24, 2021
@mergify mergify bot merged commit dd44431 into main Dec 24, 2021
@mergify mergify bot deleted the conroy/cache branch December 24, 2021 17:40
@mergify
Copy link
Contributor

mergify bot commented Dec 24, 2021

Merging (with squash)...

@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Dec 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants