[batch] Use _batch_client() to query supported_regions() and default_region()#15289
Open
jmarshall wants to merge 2 commits intohail-is:mainfrom
Open
[batch] Use _batch_client() to query supported_regions() and default_region()#15289jmarshall wants to merge 2 commits intohail-is:mainfrom
jmarshall wants to merge 2 commits intohail-is:mainfrom
Conversation
As default_region() is used in __init__(), it needs to work in all scenarios, including those in which credentials are provided via __init__'s token parameter. Thus it will need self._token so can't be a staticmethod, so it might as well reuse _batch_client() and its session. Do the same with supported_regions() for good measure. Lift self.__batch_client=None to the top so it occurs before anything might use _batch_client(), e.g. our self.default_region() call. This also ensures the __batch_client attribute exists within __del__() even if __init__() raises an exception, preventing a common red herring warning.
TomConner
approved these changes
Mar 11, 2026
cjllanwarne
requested changes
Mar 11, 2026
Collaborator
cjllanwarne
left a comment
There was a problem hiding this comment.
My comments are mostly "nit" level so feel free to push back. But it looks like you ran into trouble with the static analysis (unused BatchClient import) and doctest (service_backend is not defined) so I figured I might as well comment and let you decide what to do about these ones too.
Contributor
Author
Oops. I suppose now that that's unused and so not imported we could stop renaming the other BatchClient in this source file: from hailtop.batch_client.aioclient import BatchClient as AioBatchClient
# ^^^^^^^^^^^^^^^^^but doing that might be more confusing… |
cjllanwarne
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Description
As
default_region()is used in__init__(), it needs to work in all scenarios, including those in which credentials are provided via__init__'s token parameter. Thus it will needself._tokenso can't be a staticmethod, so it might as well reuse_batch_client()and its session.Do the same with
supported_regions()for good measure.Lift
self.__batch_client=Noneto the top so it occurs before anything might use_batch_client(), e.g., ourself.default_region()call. This also ensures the__batch_clientattribute exists within__del__()even if__init__()raises an exception, preventing a common red herring warning.Security Assessment
Impact Rating
Impact Description
Some requests that currently fail due to being entirely unauthenticated will be tried using the authentication token the caller intends to use instead, and will have an opportunity to succeed.
Appsec Review