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(dfir_rs, hydro_lang): add resolve_futures and resolve_futures_ordered APIs #1741

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

RyanAlameddine
Copy link
Contributor

No description provided.

@RyanAlameddine RyanAlameddine force-pushed the main branch 2 times, most recently from e64adca to d9bc803 Compare February 23, 2025 21:52
/// # use dfir_rs::futures::StreamExt;
/// # use hydro_lang::*;
/// # tokio_test::block_on(test_util::stream_transform_test(
/// |process| {
Copy link
Member

Choose a reason for hiding this comment

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

Ah, like the other doctests, you should move this line above, and also # out the assertion and only display a comment instead.

@RyanAlameddine RyanAlameddine force-pushed the main branch 3 times, most recently from 7fa6e13 to 6f604f7 Compare February 23, 2025 22:27
Copy link
Member

@shadaj shadaj left a comment

Choose a reason for hiding this comment

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

Couple tweaks needed to the docs, implementation looks great!

/// # use dfir_rs::futures::StreamExt;
/// # use hydro_lang::*;
/// # tokio_test::block_on(test_util::stream_transform_test(|process| {
/// let tick = process.tick();
Copy link
Member

Choose a reason for hiding this comment

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

You'll want to dedent these (you can hover over the function name in VSCode to see the rendered docs.

/// x
/// }))
/// .poll_futures()
/// // 1, 2, 3, 4, 5, 6, 7, 8, 9
Copy link
Member

Choose a reason for hiding this comment

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

Just to mirror the other docs, this should be next to the assertion.

/// # |mut stream| async move {
/// # assert_eq!(
/// # HashSet::<i32>::from_iter(1..10),
/// # HashSet::from_iter(vec![stream.next().await.unwrap(), stream.next().await.unwrap(), stream.next().await.unwrap(), stream.next().await.unwrap(), stream.next().await.unwrap(), stream.next().await.unwrap(), stream.next().await.unwrap(), stream.next().await.unwrap(), stream.next().await.unwrap()])
Copy link
Member

Choose a reason for hiding this comment

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

Can we use a for loop? :)

/// x
/// }))
/// .poll_futures_ordered()
/// // 2, 3, 1, 9, 6, 5, 4, 7, 8
Copy link
Member

Choose a reason for hiding this comment

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

Same comments as above

process
.source_iter(q!([2, 3, 1, 9, 6, 5, 4, 7, 8]))
.map(q!(|x| async move {
// tokio::time::sleep works, import then just sleep does not, unsure why
Copy link
Member

Choose a reason for hiding this comment

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

Very strange... this would indicate that something is wrong with the stageleft logic... But irrelevant to this PR so okay for now.

@shadaj shadaj changed the title feat(hydroflow): Added poll_futures and poll_futures_ordered to hydroflow plus. feat(dfir_rs,hydro_lang): add poll_futures and poll_futures_ordered APIs Feb 24, 2025
@shadaj shadaj changed the title feat(dfir_rs,hydro_lang): add poll_futures and poll_futures_ordered APIs feat(dfir_rs, hydro_lang): add poll_futures and poll_futures_ordered APIs Feb 24, 2025
@shadaj
Copy link
Member

shadaj commented Feb 24, 2025

Another open question; should we name this poll_futures or something like resolve_futures? It feels like "polling" is more of an implementation detail...

@shadaj shadaj changed the title feat(dfir_rs, hydro_lang): add poll_futures and poll_futures_ordered APIs feat(dfir_rs, hydro_lang): add resolve_futures and resolve_futures_ordered APIs Feb 25, 2025
Copy link
Member

@shadaj shadaj left a comment

Choose a reason for hiding this comment

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

Last set of changes!

@@ -356,7 +356,7 @@ Pipeline flags: Needs checking of bounded vs unbounded for batch()vs all_once()N

### Reverted

- <csr-id-256779abece03bee662b351430d27141d10bd5ef/> "feat(hydroflow): Added poll_futures and poll_futures_async operators.", fix #1183
- <csr-id-256779abece03bee662b351430d27141d10bd5ef/> "feat(hydroflow): Added resolve_futures and resolve_futures_async operators.", fix #1183
Copy link
Member

Choose a reason for hiding this comment

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

Ah, looks like a buggy global find-and-replace, we should restore the original file.

@@ -413,7 +413,7 @@ Pipeline flags: Needs checking of bounded vs unbounded for batch()vs all_once()N

### Reverted

- <csr-id-256779abece03bee662b351430d27141d10bd5ef/> "feat(hydroflow): Added poll_futures and poll_futures_async operators.", fix #1183
- <csr-id-256779abece03bee662b351430d27141d10bd5ef/> "feat(hydroflow): Added resolve_futures and resolve_futures_async operators.", fix #1183
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

@@ -1142,7 +1142,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Reverted

- <csr-id-256779abece03bee662b351430d27141d10bd5ef/> "feat(hydroflow): Added poll_futures and poll_futures_async operators.", fix #1183
- <csr-id-256779abece03bee662b351430d27141d10bd5ef/> "feat(hydroflow): Added resolve_futures and resolve_futures_async operators.", fix #1183
Copy link
Member

Choose a reason for hiding this comment

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

And here.

/// .resolve_futures()
/// # },
/// # |mut stream| async move {
/// // 1, 2, 3, 4, 5, 6, 7, 8, 9
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a small (in arbitrary order) note and scramble the order just so developers don't make any assumptions about that?

)
}

// fn test() {
Copy link
Member

Choose a reason for hiding this comment

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

leftover?

/// let tick = process.tick();
/// process.source_iter(q!([2, 3, 1, 9, 6, 5, 4, 7, 8]))
/// .map(q!(|x| async move {
/// // tokio::time::sleep works, import then just sleep does not, unsure why
Copy link
Member

Choose a reason for hiding this comment

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

Let's not put this inside the test. Also, the reason this happens is that for doctests specifically, we don't have infrastructure to extract the imports used outside the quoted code.

/// let tick = process.tick();
/// process.source_iter(q!([2, 3, 1, 9, 6, 5, 4, 7, 8]))
/// .map(q!(|x| async move {
/// // tokio::time::sleep works, import then just sleep does not, unsure why
Copy link
Member

Choose a reason for hiding this comment

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

Same here, let's drop this line.

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