Friendlier init() response when already initialized

[Context: a Terra/GATK workshop where users run some Hail commands in a Terra Jupyter notebook.]

Hail version 0.2.30-2ae07d872f43

Running the init() command when it’s already initialized results in:


FatalError Traceback (most recent call last)
in
1 # After importing, start a Hail session
----> 2 hl.init(default_reference = “GRCh37”, log = ‘ASHG_Terra_workshop.log’)

</usr/local/lib/python3.7/dist-packages/decorator.py:decorator-gen-1243> in init(sc, app_name, master, local, log, quiet, append, min_block_size, branching_factor, tmp_dir, default_reference, idempotent, global_seed, _optimizer_iterations, _backend)

/usr/local/lib/python3.7/dist-packages/hail/typecheck/check.py in wrapper(__original_func, *args, **kwargs)
583 def wrapper(original_func, *args, **kwargs):
584 args
, kwargs
= check_all(__original_func, args, kwargs, checkers, is_method=is_method)
–> 585 return original_func(*args, **kwargs)
586
587 return wrapper

/usr/local/lib/python3.7/dist-packages/hail/context.py in init(sc, app_name, master, local, log, quiet, append, min_block_size, branching_factor, tmp_dir, default_reference, idempotent, global_seed, _optimizer_iterations, _backend)
277 min_block_size, branching_factor, tmp_dir,
278 default_reference, idempotent, global_seed,
–> 279 _optimizer_iterations,_backend)
280
281

</usr/local/lib/python3.7/dist-packages/decorator.py:decorator-gen-1241> in init(self, sc, app_name, master, local, log, quiet, append, min_block_size, branching_factor, tmp_dir, default_reference, idempotent, global_seed, optimizer_iterations, _backend)

/usr/local/lib/python3.7/dist-packages/hail/typecheck/check.py in wrapper(__original_func, *args, **kwargs)
583 def wrapper(original_func, *args, **kwargs):
584 args
, kwargs
= check_all(__original_func, args, kwargs, checkers, is_method=is_method)
–> 585 return original_func(*args, **kwargs)
586
587 return wrapper

/usr/local/lib/python3.7/dist-packages/hail/context.py in init(self, sc, app_name, master, local, log, quiet, append, min_block_size, branching_factor, tmp_dir, default_reference, idempotent, global_seed, optimizer_iterations, _backend)
40 return
41 else:
—> 42 raise FatalError('Hail has already been initialized, restart session ’
43 ‘or stop Hail to change configuration.’)
44

FatalError: Hail has already been initialized, restart session or stop Hail to change configuration.

From the perspective of a Jupyter user rerunning already-run cells, it appears that something has gone terribly wrong and their notebook is in some invalid state that they need to correct by taking some action. But in reality, the notebook is in a fully usable state: Hail is initialized and ready for use, just as they had intended.

Would it be possible to alter this response to something less alarming? My preference would be something along the lines of:

  • no stack trace
  • Warning: No action taken for init() because Hail is already initialized. If this call was intended to alter Hail’s configuration, please stop Hail before calling init(), or restart the session.

Thanks!

Yeah, this is a reasonable ask. That message is very aggressive.

I really wish notebooks made it impossible to rerun a cell that’s already been run, though (can’t assume things are idempotent!). Maybe someday…

Fix here:

Thanks Tim!