-
Notifications
You must be signed in to change notification settings - Fork 0
feat(controller) Score controller scores batches using heuristic scorer #121
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,12 +15,15 @@ import ( | |
| _ "github.com/go-sql-driver/mysql" | ||
| "github.com/uber-go/tally/v4" | ||
| "github.com/uber/submitqueue/core/consumer" | ||
| "github.com/uber/submitqueue/entity" | ||
| "github.com/uber/submitqueue/extension/counter" | ||
| mysqlcounter "github.com/uber/submitqueue/extension/counter/mysql" | ||
| "github.com/uber/submitqueue/extension/mergechecker" | ||
| githubchecker "github.com/uber/submitqueue/extension/mergechecker/github" | ||
| extqueue "github.com/uber/submitqueue/extension/queue" | ||
| queueMySQL "github.com/uber/submitqueue/extension/queue/mysql" | ||
| "github.com/uber/submitqueue/extension/scorer" | ||
| heuristicscorer "github.com/uber/submitqueue/extension/scorer/heuristic" | ||
| mysqlstorage "github.com/uber/submitqueue/extension/storage/mysql" | ||
| "github.com/uber/submitqueue/extension/storage" | ||
| "github.com/uber/submitqueue/orchestrator/controller" | ||
|
|
@@ -161,8 +164,11 @@ func run() error { | |
| // Create merge checker | ||
| mc := newMergeChecker(logger, scope) | ||
|
|
||
| // Create scorer | ||
| sc := newScorer(scope) | ||
|
|
||
| // Register controllers | ||
| if err := registerControllers(c, logger.Sugar(), scope, registry, mc, cnt, store); err != nil { | ||
| if err := registerControllers(c, logger.Sugar(), scope, registry, mc, cnt, store, sc); err != nil { | ||
| return err | ||
| } | ||
|
|
||
|
|
@@ -310,7 +316,7 @@ func newTopicRegistry(q extqueue.Queue, subscriberName string) (consumer.TopicRe | |
| // │ │ │ | ||
| // └────────┴────────────────────────┘ | ||
|
|
||
| func registerControllers(c consumer.Consumer, logger *zap.SugaredLogger, scope tally.Scope, registry consumer.TopicRegistry, mc mergechecker.MergeChecker, cnt counter.Counter, store storage.Storage) error { | ||
| func registerControllers(c consumer.Consumer, logger *zap.SugaredLogger, scope tally.Scope, registry consumer.TopicRegistry, mc mergechecker.MergeChecker, cnt counter.Counter, store storage.Storage, sc scorer.Scorer) error { | ||
| requestController := request.NewController( | ||
| logger, | ||
| scope, | ||
|
|
@@ -354,6 +360,8 @@ func registerControllers(c consumer.Consumer, logger *zap.SugaredLogger, scope t | |
| registry, | ||
| consumer.TopicKeyScore, | ||
| "orchestrator-score", | ||
| sc, | ||
| store, | ||
| ) | ||
| if err := c.Register(scoreController); err != nil { | ||
| return fmt.Errorf("failed to register score controller: %w", err) | ||
|
|
@@ -442,6 +450,21 @@ func newMergeChecker(logger *zap.Logger, scope tally.Scope) mergechecker.MergeCh | |
| }) | ||
| } | ||
|
|
||
| // newScorer returns a temporary scorer that assigns a success probability of | ||
| // 1.0 to every change, regardless of its attributes. | ||
| // TODO: Replace with a better heuristic as the pipeline evolves. | ||
| func newScorer(scope tally.Scope) scorer.Scorer { | ||
| return heuristicscorer.New( | ||
| []heuristicscorer.Bucket{ | ||
| {Min: 0, Max: 100, Score: 1.0}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add "TODO" for the real one?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| }, | ||
| func(_ context.Context, _ entity.Change) (int, error) { | ||
| return 0, nil | ||
| }, | ||
| scope.SubScope("scorer"), | ||
| ) | ||
| } | ||
|
|
||
| // bearerTransport is an http.RoundTripper that adds a Bearer token to requests. | ||
| type bearerTransport struct { | ||
| token string | ||
|
|
||
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
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
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
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
Oops, something went wrong.
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.
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 need to increment the version? It should only be incremented after a successful atomic persistence (i.e. a write to the database).
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.
Now I see where it is used (after the update), the comment could reflect that.
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.
Added a comment.
Uh oh!
There was an error while loading. Please reload this page.
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.
i am wondering if this should be in entity at all?
to me it seems like we probably need this to be part of contract at storage layer itself which accepts,
entity, oldVersion, newVresion... I am not fan of implicit things as they hide away and lead to confusion/issues down the line..Thoughts?