-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[BEAM-13632][Playground] Save catalog data to the cache #16493
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
[BEAM-13632][Playground] Save catalog data to the cache #16493
Conversation
playground/backend/internal/utils/precompiled_objects_utils_test.go
Outdated
Show resolved
Hide resolved
AydarZaynutdinov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM. Last minor suggestion.
| } else { | ||
| logger.Errorf("GetPrecompiledObjects(): cache error: %s", err.Error()) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } else { | |
| logger.Errorf("GetPrecompiledObjects(): cache error: %s", err.Error()) | |
| } | |
| } | |
| logger.Errorf("GetPrecompiledObjects(): cache error: %s", err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, thanks!
pavel-avilov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| func (controller *playgroundController) GetPrecompiledObjects(ctx context.Context, info *pb.GetPrecompiledObjectsRequest) (*pb.GetPrecompiledObjectsResponse, error) { | ||
| bucket := cloud_bucket.New() | ||
| sdkToCategories, err := bucket.GetPrecompiledObjects(ctx, info.Sdk, info.Category) | ||
| if info.Sdk == pb.Sdk_SDK_UNSPECIFIED && info.Category == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need this if here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed per our discussion
| LogsIndex SubKey = "LOGS_INDEX" | ||
|
|
||
| // ExamplesCatalog is catalog of examples available in Playground | ||
| ExamplesCatalog SubKey = "EXAMPLES_CATALOG" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of make workarounds with subkey without pipeline id. Can we extend the Cache interface and implementation with SetCatalog, GetKatalog?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, changed
| } | ||
|
|
||
| // GetPrecompiledObjectsCatalogFromCache returns the precompiled objects catalog from the cache | ||
| func GetPrecompiledObjectsCatalogFromCache(ctx context.Context, cacheService cache.Cache) ([]*pb.Categories, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this name shorter?
GetPrecompiledObjectsFromCache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one became redundant and GetPrecompiledObjectsCatalogFromStorage I changed to GetCatalogFromStorage
d93dc2b to
7fe3d8b
Compare
| // SetCatalog adds the given catalog to cache by ExamplesCatalog key. | ||
| SetCatalog(ctx context.Context, catalog []*pb.Categories) error | ||
|
|
||
| // GetCatalog return catalog from cache by ExamplesCatalog key. | ||
| GetCatalog(ctx context.Context) ([]*pb.Categories, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we use already existing methods GetValue and SetValue? Is it because we use Get/Set for catalog instead of HGet/HSet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we save it without the workaround with nil pipelined as It was before.
| // - If SDK and category are unspecified in the request, gets the whole catalog from the cache | ||
| // - If there is no catalog in the cache, gets the catalog from the Storage and saves it to the cache | ||
| // - If SDK or category is specified in the request, gets the specific catalog from the Storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the comment here doesn't match the method logic. The method gets a catalog from the cache in all cases, not only if SDK and category are unspecified
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for noticing, changed!
AydarZaynutdinov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| } | ||
|
|
||
| // GetCatalogFromStorage returns the precompiled objects catalog from the cloud storage | ||
| func GetCatalogFromStorage(ctx context.Context) ([]*pb.Categories, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add tests for this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, its logic is connected with retrieving the data from the bucket – testing this will be integration testing, which we don't do now.
# Conflicts: # playground/backend/internal/cache/cache.go
daria-malkova
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ilya-kozyrev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks
|
R: @pabloem |
|
this looks fine to me. thanks! |
BEAM-13632 The catalog is now saved into the cache at the server startup.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username).[BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replaceBEAM-XXXwith the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
ValidatesRunnercompliance status (on master branch)Examples testing status on various runners
Post-Commit SDK/Transform Integration Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.