Skip to content

feat: Update Sourcer interface for propagating totalPartitions#343

Merged
vigith merged 15 commits intomainfrom
total_partitions
Mar 28, 2026
Merged

feat: Update Sourcer interface for propagating totalPartitions#343
vigith merged 15 commits intomainfrom
total_partitions

Conversation

@vaibhavtiwari33
Copy link
Copy Markdown
Contributor

@vaibhavtiwari33 vaibhavtiwari33 commented Mar 26, 2026

Sourcer changes:

  • Deprecate Remove partitions_handler in Sourcer
  • Replace partitions_handler with active_partitions_handler in Sourcer
  • Maintain backward compatibility
  • Add support for optional total_partitions

To maintain backward compatibility (in terms of code compilation on SDK version upgrade), I had made all the following Sourcer methods optional:

  • partitions_handler
  • active_partitions_handler
  • total_partitions_handler

But since the partitions_handler method was previously an @abstractmethod, I didn't like the fact that we were removing the constraint of implementing either of the .*partitions_handler methods.

Closes #334

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.68%. Comparing base (fd0f49a) to head (9f44725).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #343   +/-   ##
=======================================
  Coverage   92.67%   92.68%           
=======================================
  Files          67       67           
  Lines        3509     3513    +4     
  Branches      229      229           
=======================================
+ Hits         3252     3256    +4     
  Misses        193      193           
  Partials       64       64           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

from pynumaflow.proto.accumulator import accumulator_pb2 as pynumaflow_dot_proto_dot_accumulator_dot_accumulator__pb2

GRPC_GENERATED_VERSION = '1.75.0'
GRPC_GENERATED_VERSION = '1.78.0'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this expected?

Copy link
Copy Markdown
Contributor Author

@vaibhavtiwari33 vaibhavtiwari33 Mar 27, 2026

Choose a reason for hiding this comment

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

Seems like when I installed dependencies using the newly added uv manager, it downloaded the latest version of grpcio-tools:

uv.lock
_________
...
[[package]]
name = "grpcio-tools"
version = "1.78.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
    { name = "grpcio" },
    { name = "protobuf" },
    { name = "setuptools" },
]

I'm guessing since the dependencies allow versions >= lowest supported version:

pyproject.toml
_______________
...
dependencies = [
    "grpcio>=1.48.1",
    "grpcio-tools>=1.48.1",
...

Let me force the usage of v1.75.0 grpcio and generate again.

Copy link
Copy Markdown
Contributor Author

@vaibhavtiwari33 vaibhavtiwari33 Mar 27, 2026

Choose a reason for hiding this comment

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

Wait, but I see the uv.lock already updated with the 1.78.0 version for grpcio-tools. Maybe we never regenerated proto after moving package managers? The PR for migrating from poetry to uv shows version 1.78.0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ya, the previous poetry.lock in the PR shows v1.75.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's do in it 2 PRs if you want to update gRPC?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, let me use the previous grpc version

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted the grpcio version to 1.75.0
PR is much cleaner now. Ty!

@kohlisid
Copy link
Copy Markdown
Contributor

@vaibhavtiwari33 just a drop in note to update the examples with the updated signatures as well! Thanks
Will review the rest when moved from draft

@vaibhavtiwari33 vaibhavtiwari33 marked this pull request as ready for review March 28, 2026 03:47
Comment on lines +307 to +308
if total_partitions is not None:
result.total_partitions = total_partitions
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we really need that check? doesn't python default to None and None is the right value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you're right, the proto initializer for PartitionsResponse accepts _Optional[int]

def __init__(self, partitions: _Optional[_Iterable[int]] = ..., total_partitions: _Optional[int] = ...) -> None: ...

I can remove the check. Let me do that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated

vaibhavtiwari33 and others added 12 commits March 28, 2026 12:55
…for active_partitions_handler and total_partitions, * Maintain backward compatibility

Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
…his version

Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
…ss in sourcer/_dtypes

Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
…handler

Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
Co-authored-by: Vigith Maurice <vigith@gmail.com>
Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
@vigith vigith merged commit 5c7d07f into main Mar 28, 2026
11 checks passed
@vigith vigith deleted the total_partitions branch March 28, 2026 17:29
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.

Update udsource partitions method to include total partitions

3 participants