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

feat: implement batch map #133

Merged
merged 8 commits into from
Jul 11, 2024
Merged

feat: implement batch map #133

merged 8 commits into from
Jul 11, 2024

Conversation

kohlisid
Copy link
Contributor

@kohlisid kohlisid commented Jul 2, 2024

Fixes #1786

@kohlisid kohlisid marked this pull request as ready for review July 2, 2024 18:53
@kohlisid kohlisid requested review from whynowy, vigith and yhl25 July 2, 2024 18:53
Copy link
Member

@vigith vigith left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 60 to 121
if len(responses.Items()) != len(datums) {
errMsg := "batchMapFn: mismatch between length of batch requests and responses"
log.Panic(errMsg)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to avoid panic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can choose either to panic or send an error back(numa will be restarted in both cases), based on an earlier discussion with @vigith we thought that having a panic here would be a clear indication for the user that there is an issue. And as this in a mismatch in the implementation from the user side for not providing equal number of responses, the reason for restarts and error gives better clarity there.
But this is our decision on how do we want to keep the behavior in such scenarios.
@vigith @whynowy Any preferences?

@vigith vigith marked this pull request as draft July 4, 2024 22:37
Sidhant Kohli and others added 5 commits July 8, 2024 15:47
Signed-off-by: Sidhant Kohli <[email protected]>
Signed-off-by: Sidhant Kohli <[email protected]>
Signed-off-by: Sidhant Kohli <[email protected]>
Signed-off-by: Sidhant Kohli <[email protected]>
Signed-off-by: Sidhant Kohli <[email protected]>
@kohlisid kohlisid requested review from yhl25, vigith and whynowy July 9, 2024 04:48
@kohlisid kohlisid marked this pull request as ready for review July 9, 2024 16:14
Signed-off-by: Sidhant Kohli <[email protected]>
@kohlisid kohlisid requested a review from KeranYang July 10, 2024 00:33
Signed-off-by: Sidhant Kohli <[email protected]>
@kohlisid kohlisid requested a review from KeranYang July 10, 2024 16:26
Comment on lines +87 to +98
func (u *BatchMapFnServerErrTest) Context() context.Context {
return u.ctx
}

func TestService_BatchMapFn(t *testing.T) {
tests := []struct {
name string
handler BatchMapper
input []*batchmappb.BatchMapRequest
expected []*batchmappb.BatchMapResponse
expectedErr bool
}{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test to cover the error/panic case inside the user code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the current setup, this is difficult to test via UT directly. I tried to add the test there but the assert.Panics (which internally uses recover) was not able to catch it as the panic is invoked from within another goroutine. Would need to research more on how can we cover something like this. In python i'm able to mock the panic and test which wasn't working out here.

I tried few manual scenarios to induce such panics which were working fine.

Copy link
Contributor

@yhl25 yhl25 left a comment

Choose a reason for hiding this comment

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

LGTM!

@kohlisid kohlisid merged commit 15e4521 into main Jul 11, 2024
3 checks passed
@kohlisid kohlisid deleted the map-batch branch July 11, 2024 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Batch map: proto and Implementation (numaflow-go)
6 participants