-
Notifications
You must be signed in to change notification settings - Fork 29
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: Allow users to configure the internal thread pool (#11) #54
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Thanks for your contribution, @alhridoy! I have some initial feedback.
A couple more high-level notes:
- Make sure that users can set this from
open_dataset()
. To accomplish this, the new keyword arg needs to be accepted inEarthEngineBackendEntrypoint()
. - Please update our integration tests to prove that everything is working.
configurable-thread-pool
Outdated
@@ -0,0 +1 @@ | |||
Branch 'configurable-thread-pool' set up to track remote branch 'main' from 'origin'. |
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.
Please remove this file.
xee/ext.py
Outdated
@@ -634,7 +634,7 @@ def reduce_bands(x, acc): | |||
return target_image | |||
|
|||
def _raw_indexing_method( | |||
self, key: tuple[Union[int, slice], ...] | |||
self, key: tuple[Union[int, slice], ...], executor_kwargs: Optional[dict] = None |
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.
This extra argument is named well, but I think it should be set in the constructor.
xee/ext.py
Outdated
if executor_kwargs is None: | ||
executor_kwargs = {} |
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.
Let's do this bit of logic in the constructor, too.
# If executor_kwargs is None, use an empty dictionary | ||
if executor_kwargs is None: | ||
executor_kwargs = {} | ||
# Pass executor_kwargs to ThreadPoolExecutor |
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.
Comment is a bit too verbose for my taste.
Hi @alxmrs when i run the test file, this error pops up.
|
@alxmrs Thanks for your guidance. Would you check if these changes are working properly? if not, Please let me necessary the changes I need to make. Thanks |
xee/ext.py
Outdated
@@ -89,6 +89,12 @@ class EarthEngineStore(common.AbstractDataStore): | |||
|
|||
DEFAULT_MASK_VALUE = np.iinfo(np.int32).max | |||
|
|||
def __init__(self, executor_kwargs=None): |
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.
There already is a constructor.
@@ -358,6 +358,18 @@ def test_data_sanity_check(self): | |||
self.assertNotEqual(temperature_2m.min(), 0.0) | |||
self.assertNotEqual(temperature_2m.max(), 0.0) | |||
|
|||
def test_open_dataset_with_executor_kwargs(self): |
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.
Thanks for the test!
Please fix the merge conflicts in this branch. |
Hi @alxmrs . Thanks for the feedback. ,I added a new parameter executor_kwargs has been added to the init method also resolved merge conflict. |
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.
Definitely looking better. Here are a few more additional suggestions.
# Initialize executor_kwargs | ||
if executor_kwargs is None: | ||
self.executor_kwargs = {} | ||
else: | ||
self.executor_kwargs = executor_kwargs |
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.
# Initialize executor_kwargs | |
if executor_kwargs is None: | |
self.executor_kwargs = {} | |
else: | |
self.executor_kwargs = executor_kwargs | |
if executor_kwargs is None: | |
executor_kwargs = {} | |
self.executor_kwargs = executor_kwargs |
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.
Please initialize this at the top or bottom of the __init__
.
xee/ext.py
Outdated
@@ -706,7 +714,7 @@ def reduce_bands(x, acc): | |||
return target_image | |||
|
|||
def _raw_indexing_method( | |||
self, key: tuple[Union[int, slice], ...] | |||
self, key: tuple[Union[int, slice], ...] |
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.
Please remove extra space (to minimize the diff).
@@ -845,6 +854,7 @@ def open_dataset( | |||
primary_dim_name: Optional[str] = None, | |||
primary_dim_property: Optional[str] = None, | |||
ee_mask_value: Optional[float] = None, | |||
executor_kwargs: Optional[dict] = None, |
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.
In addition to adding it to the arguments, please update the docstring.
…methods, updates docstring
…g_method and updated docstrings
Hi @alxmrs , Would you check the new commits address your comments? If there is still any issue I would be happy to work on that. |
It feels like you are using a bot to make this patch. I'll be happy to work with you to add this feature. First, please do a self review before I make any additional reviews. |
Thanks! Please give me couple of weeks. |
This PR introduces a new feature that allows users to configure the internal thread pool used in the
_raw_indexing_method
function of theEarthEngineBackendArray
class.A new optional parameter
executor_kwargs
has been added to the function. This parameter is a dictionary that can be used to pass configuration options to theThreadPoolExecutor
. Ifexecutor_kwargs
is not provided, an empty dictionary is used, preserving the current behavior.This feature provides users with more flexibility and control over the execution of the function, especially in scenarios where specific thread pool configurations are needed.
Changes:
executor_kwargs
parameter to_raw_indexing_method
function inxee/ext.py
.Please review and let me know if any changes are required.