Skip to content

fix(python_adapter): more __yield_messages fixes#202

Merged
bmckerry merged 5 commits intomainfrom
ben/fix-rust-step-code
Sep 4, 2025
Merged

fix(python_adapter): more __yield_messages fixes#202
bmckerry merged 5 commits intomainfrom
ben/fix-rust-step-code

Conversation

@bmckerry
Copy link
Member

@bmckerry bmckerry commented Aug 28, 2025

#203 fixed the initial error by returning messages as a Sequence instead of a generator, but this caused another issue where watermarks weren't handled by the python adapter's handle_py_return_value function.

This required implementing From Py<PyAny> for Watermark to allow converting the python PyWatermark returned from the PythonAdapter into a rust PyWatermark.

A rust test for this code path is coming in a future PR.

@bmckerry bmckerry requested a review from a team as a code owner August 28, 2025 20:33
Copy link
Collaborator

@fpacifici fpacifici left a comment

Choose a reason for hiding this comment

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

Please ensure this still works.

cursor[bot]

This comment was marked as outdated.

@bmckerry bmckerry force-pushed the ben/fix-rust-step-code branch from f11b4e3 to 5372e47 Compare August 29, 2025 20:31
cursor[bot]

This comment was marked as outdated.

Copy link
Collaborator

@fpacifici fpacifici left a comment

Choose a reason for hiding this comment

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

Please see the issue with From

})
.unwrap()
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cursor is right. From cannot fail. You should use TryFrom for type conversions that can fail
https://doc.rust-lang.org/std/convert/trait.TryFrom.html

cursor[bot]

This comment was marked as outdated.

@bmckerry bmckerry changed the title fix(python_adapter): retrieve messages as Sequence fix(python_adapter): more __yield_messages fixes Sep 4, 2025
}

#[test]
fn test_submit_watermark() {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test was almost entirely redundant and only passed because make_test_watermark had the wrong route. I moved submitting a watermark into the above test_submit_with_matching_route test (the diff makes this look weird)

}

fn make_test_watermark(py: Python<'_>) -> Message<RoutedValue> {
fn make_test_watermark() -> Message<RoutedValue> {
Copy link
Member Author

Choose a reason for hiding this comment

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

This was completely broken and only worked because it returned a message with the wrong route.

@bmckerry bmckerry dismissed fpacifici’s stale review September 4, 2025 19:04

I fixed the problems

@bmckerry bmckerry merged commit af1c1c1 into main Sep 4, 2025
19 checks passed
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.

3 participants