Skip to content

Conversation

stepansergeevitch
Copy link
Collaborator

Refactored out result storing and iteration into a separate RowSet class family. This is a prerequisite to implement support for streaming functionality

@stepansergeevitch stepansergeevitch self-assigned this Apr 8, 2025
@stepansergeevitch stepansergeevitch requested a review from a team as a code owner April 8, 2025 13:18
@stepansergeevitch stepansergeevitch changed the title FIR-43722 add streaming to python sdk refactor: FIR-43722 refactor our result set logic from cursors Apr 9, 2025
Copy link

@goprean goprean left a comment

Choose a reason for hiding this comment

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

I tried looking to see if I understand and can review the code but I don't know python so it is hard to review a change this big.

One note though: do you want to change the quality gate for python sdk to fail if there are new issues (like new violations or test coverage is not enough). I did change it for JDBC and now the email tells you that he quality gate failed. for python it passes even though there are new issues.

content=query,
timeout=timeout if timeout is not None else USE_CLIENT_DEFAULT,
)
return await self._client.send(req, stream=True)
Copy link

Choose a reason for hiding this comment

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

was this the default, previous behavior with stream? I thought this is the refactoring and then you will add the streaming functionality.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We used to read the response here fully and then work with the result in memory. Now we stream the response here, and let the RowSet to decide whether to read the stream in memory and process it or (in future streaming implementation) to read it line by line and not store it in memory

@stepansergeevitch stepansergeevitch force-pushed the FIR-43722-add-streaming-to-python-sdk branch from 83b4bf9 to f2014db Compare April 10, 2025 12:51
Comment on lines 400 to 402
@check_not_closed
def __enter__(self) -> Cursor:
return self
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can still support enter, at least to make sure we don't break anything. It's "free" from the looks of it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We cannot have __enter__ and __exit__ now since close becomes async aclose, and we're not able to call it from a sync function anymore

Copy link
Contributor

Choose a reason for hiding this comment

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

But behind the scenes in async aclose we call super.close() so nothing stops us from having sync close pm cursor that would do the same. I believe one of the reasons why aenter and aexit were introduced instead of having async enter and exit is to allow an object that's both sync and async context manager.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After discussion, decided to leave a no-op function with a deprecation warning

Copy link
Contributor

@ptiurin ptiurin left a comment

Choose a reason for hiding this comment

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

Added suggestion for clarity, otherwise lgtm

stepansergeevitch and others added 2 commits April 14, 2025 19:31
Co-authored-by: Petro Tiurin <93913847+ptiurin@users.noreply.github.com>
Copy link

@stepansergeevitch stepansergeevitch merged commit 28a90ac into main Apr 15, 2025
8 checks passed
@stepansergeevitch stepansergeevitch deleted the FIR-43722-add-streaming-to-python-sdk branch April 15, 2025 07:15
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