Skip to content

feat(gax)!: stable paginator#1466

Merged
dbolduc merged 10 commits intogoogleapis:mainfrom
dbolduc:pagination-gated-stream-dev
Mar 13, 2025
Merged

feat(gax)!: stable paginator#1466
dbolduc merged 10 commits intogoogleapis:mainfrom
dbolduc:pagination-gated-stream-dev

Conversation

@dbolduc
Copy link
Member

@dbolduc dbolduc commented Mar 11, 2025

Part of the work for #720

Makes the Paginator class part of gax. It is no longer gated by the unstable-stream feature. The Paginator picks up a to_stream() function which is gated by the unstable-stream feature. (Same goes for ItemPaginator).

We renamed the stream() function to paginator() on the paginated builders.

unstable-stream feature in client crates

All downstream crates still have an unstable-stream feature. I think we should get rid of them, and let applications opt in via the dependency on gax. If we want to do this, I will send another PR.

We would need to update some of our docs, because we could no longer one-line things like:

   cargo add google-cloud-secretmanager-v1 --features unstable-stream

On testing feature configurations...

We now testing gax with and without unstable-stream. (By removing both dev.dependencies on this feature).

@codecov
Copy link

codecov bot commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 36.36364% with 14 lines in your changes missing coverage. Please review.

Project coverage is 95.18%. Comparing base (e5d7b72) to head (fee79b2).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/gax/src/paginator.rs 36.36% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1466      +/-   ##
==========================================
- Coverage   95.95%   95.18%   -0.77%     
==========================================
  Files          38       38              
  Lines        1531     1538       +7     
==========================================
- Hits         1469     1464       -5     
- Misses         62       74      +12     

☔ 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.

Copy link
Collaborator

@coryan coryan left a comment

Choose a reason for hiding this comment

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

I think you need a new integration test that does not enable unstable-stream and still runs the iterations.

/// Enable the `unstable-stream` feature to interact with a [`futures::stream::Stream`].
///
/// [`futures::stream::Stream`]: https://docs.rs/futures/latest/futures/stream/trait.Stream.html
pub async fn next_stable(&mut self) -> Option<Result<T, E>> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we arrange things so this function is called next()? If not, can we call it next_page()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Calling this function next() seems to work.

@dbolduc dbolduc marked this pull request as ready for review March 11, 2025 19:23
@dbolduc dbolduc changed the title feat(gax): stable paginator feat(gax)!: stable paginator Mar 12, 2025
@dbolduc
Copy link
Member Author

dbolduc commented Mar 12, 2025

I think you need a new integration test that does not enable unstable-stream and still runs the iterations.

I went with gating the unit test for the feature and testing the crates with all features or no features:

- name: Test with features disabled
run: cargo test --workspace --no-default-features
- name: Test with features enabled
run: cargo test --workspace --all-features

Copy link
Collaborator

@coryan coryan left a comment

Choose a reason for hiding this comment

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

I think this works, but we need to decide if we want to depend on futures (which is at 0.3) in our implementation.

@dbolduc
Copy link
Member Author

dbolduc commented Mar 13, 2025

but we need to decide if we want to depend on futures (which is at 0.3) in our implementation.

Ack. I did not make the dep on futures optional in this PR. I want to get something in first, then we can think about refactoring the implementation.

If you think it is cleaner to not use futures in the implementation, I can look into that.

I went with gating the unit test for the feature and testing the crates with all features or no features:

modification: I reverted the changes to sdk.yaml. But I did remove unstable-stream from being always on in our gax tests. (It was formerly enabled both by gax's dev.dependencies and via the echo-server.)

I have a meeting item to discuss the build cache anyway.

@dbolduc dbolduc force-pushed the pagination-gated-stream-dev branch from 6593c68 to 82ca8d4 Compare March 13, 2025 16:10
Copy link
Collaborator

@coryan coryan left a comment

Choose a reason for hiding this comment

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

The code looks fine to me, but the test coverage results look weird. I worry that maybe something in the features setting is making us miss testing?

- run: cargo doc --workspace
env:
RUSTDOCFLAGS: "-D warnings"
- run: cargo doc --package google-cloud-gax
Copy link
Collaborator

Choose a reason for hiding this comment

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

As I recall, cargo doc can fail to build if you have some features enabled vs. disabled (e.g. if you link an element that is not present because the feature is disabled). I believe we should keep this test.

Copy link
Member Author

Choose a reason for hiding this comment

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

I reverted all changes to .github/workflows/sdk.yaml, but that is not obvious from the 9000 commits associated with this PR.

let mut stream = client
.list_rpc_stream(TestRequest::default())
.items()
.to_stream();
Copy link
Collaborator

Choose a reason for hiding this comment

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

codecov.io seems confused about the coverage for to_stream(). is this code running?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, it should be exercised here:

- run: cargo test --workspace

Locally:

$ cargo test --workspace | grep to_stream
test paginator::tests::test_item_paginator_to_stream ... ok
test paginator::tests::test_paginator_to_stream ... ok

Copy link
Collaborator

Choose a reason for hiding this comment

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

FWIW, I believe the coverage build uses a different set of options:

- run: |
cargo tarpaulin --out xml \
--package google-cloud-auth \
--package google-cloud-gax \
--package google-cloud-lro \
--package google-cloud-wkt

Copy link
Member Author

@dbolduc dbolduc Mar 13, 2025

Choose a reason for hiding this comment

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

oh, duh. I misread the yaml.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we have a test for to_stream() in this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added. The crate depends on clients with the unstable-stream feature enabled. I will clean up the features/dependencies in a follow up PR.

@coryan
Copy link
Collaborator

coryan commented Mar 13, 2025

Congrats on the code removal btw.

@dbolduc dbolduc merged commit f8d2b7e into googleapis:main Mar 13, 2025
20 checks passed
@dbolduc dbolduc deleted the pagination-gated-stream-dev branch March 13, 2025 20:02
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.

2 participants