Repository navigation
fix: can't stop session issue during creation - #145
ZhiweiLinnn wants to merge 3 commits into
Conversation
Summary of ChangesHello @ZhiweiLinnn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the user experience by addressing an issue where users could not stop a Spark session creation process. It introduces robust Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly adds handling for KeyboardInterrupt to allow users to stop a Spark session during creation, which is a good improvement. The associated test case is also well-written. However, I've found a critical issue where an incorrect prefix is added to a session name, which will likely break the logic for reusing existing sessions. I've also suggested a medium-severity refactoring to reduce code duplication in the exception handling blocks for better maintainability. Please address the critical issue before merging.
| ) -> Optional["DataprocSparkSession"]: | ||
| s8s_session_id = DataprocSparkSession._active_s8s_session_id | ||
| session_name = f"projects/{self._project_id}/locations/{self._region}/sessions/{s8s_session_id}" | ||
| session_name = f"sc://projects/{self._project_id}/locations/{self._region}/sessions/{s8s_session_id}" |
There was a problem hiding this comment.
The session_name is being formatted with an sc:// prefix. This prefix is intended for Spark Connect URLs, not for Dataproc API resource names. The session_name variable is passed to get_active_s8s_session_response, which uses it in a GetSessionRequest. The Dataproc API expects a resource name in the format projects/{project}/locations/{region}/sessions/{session_id}. Adding this prefix will cause the API call to fail with an InvalidArgument error. Please remove the sc:// prefix.
| session_name = f"sc://projects/{self._project_id}/locations/{self._region}/sessions/{s8s_session_id}" | |
| session_name = f"projects/{self._project_id}/locations/{self._region}/sessions/{s8s_session_id}" |
| ) -> Optional["DataprocSparkSession"]: | ||
| s8s_session_id = DataprocSparkSession._active_s8s_session_id | ||
| session_name = f"projects/{self._project_id}/locations/{self._region}/sessions/{s8s_session_id}" | ||
| session_name = f"sc://projects/{self._project_id}/locations/{self._region}/sessions/{s8s_session_id}" |
The spark session creation can't be stopped when users click the execution button. Add except for KeyboardInterrupt to fix.
verified: https://screencast.googleplex.com/cast/NDYyMzU2MDc3MjQxOTU4NHxkYjc1ZWRiMi0yMQ