Skip to content

Commit

Permalink
[batch] Add hailctl config batch/backend (#12522)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-goldstein authored Dec 1, 2022
1 parent 1e1ef36 commit 0f82efb
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions hail/python/hailtop/batch/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from hailtop.utils import secret_alnum_string, url_scheme, async_to_blocking
from hailtop.aiotools import AsyncFS
from hailtop.aiotools.router_fs import RouterAsyncFS
from hailtop.config import configuration_of

from . import backend as _backend, job, resource as _resource # pylint: disable=cyclic-import
from .exceptions import BatchException
Expand Down Expand Up @@ -48,7 +49,13 @@ class Batch:
name:
Name of the batch.
backend:
Backend used to execute the jobs. Default is :class:`.LocalBackend`.
Backend used to execute the jobs. If no backend is specified, a backend
will be created by first looking at the environment variable HAIL_BATCH_BACKEND,
then the hailctl config variable batch/backend. These configurations, if set,
can be either `local` or `service`, and will result in the use of a
:class:`.LocalBackend` and :class:`.ServiceBackend` respectively. If no
argument is given and no configurations are set, the default is
:class:`.LocalBackend`.
attributes:
Key-value pairs of additional attributes. 'name' is not a valid keyword.
Use the name argument instead.
Expand Down Expand Up @@ -121,7 +128,15 @@ def __init__(self,
self._uid = Batch._get_uid()
self._job_tokens: Set[str] = set()

self._backend = backend if backend else _backend.LocalBackend()
if backend:
self._backend = backend
else:
backend_config = configuration_of('batch', 'backend', None, 'local')
if backend_config == 'service':
self._backend = _backend.ServiceBackend()
else:
assert backend_config == 'local'
self._backend = _backend.LocalBackend()

self.name = name

Expand Down

0 comments on commit 0f82efb

Please sign in to comment.