From ccb4a9446d0b8291819ff0a6644fd75f9730bc1c Mon Sep 17 00:00:00 2001 From: Daniel Goldstein Date: Thu, 14 Sep 2023 11:01:23 -0400 Subject: [PATCH] [batch] Fix batch local mode in jupyter notebooks (#13614) The `LocalBackend` recently was changed to include a call to `async_to_blocking` but does not apply `nest_asyncio`, so using the local backend in a jupyter notebook breaks. I lifted the application of `nest_asyncio` from the `ServiceBackend` to the super class. Should we add a test that runs in its own python session to make sure that this is caught? --- hail/python/hail/docs/index.rst | 3 --- hail/python/hailtop/batch/backend.py | 7 ++----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/hail/python/hail/docs/index.rst b/hail/python/hail/docs/index.rst index ee85d26b2ac..7cfad1165b0 100644 --- a/hail/python/hail/docs/index.rst +++ b/hail/python/hail/docs/index.rst @@ -38,6 +38,3 @@ Indices and tables * :ref:`genindex` If you would like to refer to our Hail v0.1 (deprecated) docs, please view `Hail 0.1 docs `_ - - - diff --git a/hail/python/hailtop/batch/backend.py b/hail/python/hailtop/batch/backend.py index 766e808259c..95165106882 100644 --- a/hail/python/hailtop/batch/backend.py +++ b/hail/python/hailtop/batch/backend.py @@ -48,11 +48,12 @@ class Backend(abc.ABC, Generic[RunningBatchType]): """ Abstract class for backends. """ - _closed = False def __init__(self): self._requester_pays_fses: Dict[GCSRequesterPaysConfiguration, RouterAsyncFS] = {} + import nest_asyncio # pylint: disable=import-outside-toplevel + nest_asyncio.apply() def requester_pays_fs(self, requester_pays_config: GCSRequesterPaysConfiguration) -> RouterAsyncFS: try: @@ -486,11 +487,7 @@ def __init__( gcs_requester_pays_configuration: Optional[GCSRequesterPaysConfiguration] = None, gcs_bucket_allow_list: Optional[List[str]] = None, ): - - import nest_asyncio # pylint: disable=import-outside-toplevel - super().__init__() - nest_asyncio.apply() if len(args) > 2: raise TypeError(f'ServiceBackend() takes 2 positional arguments but {len(args)} were given')