-
Notifications
You must be signed in to change notification settings - Fork 744
[1/3]: Refactor S3 Connector Configuration and Initialization #2044
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
base: dev
Are you sure you want to change the base?
Conversation
Signed-off-by: Samuel Shen <slshen@uchciago.edu>
Summary of ChangesHello @sammshen, 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 focuses on refactoring the S3 Connector's configuration and initialization process to enhance clarity, control, and correctness. It renames an existing I/O concurrency setting, introduces a new option to manage TLS for non-AWS S3 services, and strengthens the validation of S3-related parameters. These changes streamline how the S3 connector is set up, ensuring that critical parameters like 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the S3 connector's configuration and initialization logic, which is a good improvement for maintainability and correctness. Key changes include renaming s3_max_io_concurrency to s3_num_io_threads, adding a disable_tls option, and improving how s3_part_size is handled. The changes make the configuration more robust and align better with the underlying AWS CRT library features. My review focuses on further improving the robustness of the new configuration parsing logic to handle various user inputs gracefully.
| self.s3_prefer_http2 = bool(extra_config.get("s3_prefer_http2", True)) | ||
| self.s3_region = extra_config.get("s3_region", None) | ||
| assert self.s3_region is not None, "s3_region is required" | ||
| self.s3_region = str(self.s3_region) | ||
| self.s3_enable_s3express = bool(extra_config.get("s3_enable_s3express", False)) | ||
| self.s3_file_prefix = extra_config.get("s3_file_prefix", None) | ||
| self.disable_tls = bool(extra_config.get("disable_tls", False)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the bool() constructor directly for parsing configuration values is unreliable. For instance, in Python, bool('False') evaluates to True, which can lead to silent misconfigurations if a user provides boolean values as strings in the YAML file (e.g., s3_prefer_http2: "False"). To ensure predictable behavior, it's better to parse boolean-like strings explicitly. This issue affects s3_prefer_http2, s3_enable_s3express, and disable_tls.
| self.s3_prefer_http2 = bool(extra_config.get("s3_prefer_http2", True)) | |
| self.s3_region = extra_config.get("s3_region", None) | |
| assert self.s3_region is not None, "s3_region is required" | |
| self.s3_region = str(self.s3_region) | |
| self.s3_enable_s3express = bool(extra_config.get("s3_enable_s3express", False)) | |
| self.s3_file_prefix = extra_config.get("s3_file_prefix", None) | |
| self.disable_tls = bool(extra_config.get("disable_tls", False)) | |
| _str_to_bool = lambda v: str(v).lower() in ("true", "1", "yes") | |
| self.s3_prefer_http2 = _str_to_bool(extra_config.get("s3_prefer_http2", True)) | |
| self.s3_region = extra_config.get("s3_region", None) | |
| assert self.s3_region is not None, "s3_region is required" | |
| self.s3_region = str(self.s3_region) | |
| self.s3_enable_s3express = _str_to_bool(extra_config.get("s3_enable_s3express", False)) | |
| self.s3_file_prefix = extra_config.get("s3_file_prefix", None) | |
| self.disable_tls = _str_to_bool(extra_config.get("disable_tls", False)) |
7440
| self.s3_part_size = int(extra_config.get("s3_part_size", full_chunk_size)) | ||
| self.s3_num_io_threads = int(extra_config.get("s3_num_io_threads", 64)) | ||
| self.s3_max_inflight_reqs = int(extra_config.get("s3_max_inflight_reqs", 64)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The direct int() conversion can be brittle. If a user provides a non-integer string value in the YAML configuration (e.g., s3_num_io_threads: "abc"), this will raise a ValueError and crash the application. It's better to handle this gracefully with a try-except block and provide a more user-friendly error message indicating which configuration key is invalid.
| self.s3_part_size = int(extra_config.get("s3_part_size", full_chunk_size)) | |
| self.s3_num_io_threads = int(extra_config.get("s3_num_io_threads", 64)) | |
| self.s3_max_inflight_reqs = int(extra_config.get("s3_max_inflight_reqs", 64)) | |
| try: | |
| self.s3_part_size = int(extra_config.get("s3_part_size", full_chunk_size)) | |
| self.s3_num_io_threads = int(extra_config.get("s3_num_io_threads", 64)) | |
| self.s3_max_inflight_reqs = int(extra_config.get("s3_max_inflight_reqs", 64)) | |
| except (ValueError, TypeError) as e: | |
| raise ValueError(f"Invalid integer value in S3 extra_config. Please check keys like 's3_part_size', 's3_num_io_threads', 's3_max_inflight_reqs'. Original error: {e}") |
| "s3_enable_s3express", True | ||
| ) | ||
| self.s3_file_prefix = config.extra_config.get("s3_file_prefix", None) | ||
| # Get full_chunk_size from context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should do type validation here
FIX #1961 @ksuma2109
This PR fixes the initialization logic and renames / adds some configs such as
num_io_threadsanddisable_tlsand enforcing thes3_part_sizeproperly as well as doing type validation.The follow up PRs are:
[2/3]: Add proper error validation to the S3Connector
[3/3]: create zero copy semantics (currently there is a copy from
/dev/shmto cudaHostRegistered memory but we should be able to remove this).