Skip to content

Commit

Permalink
Always write to tar file in serial to prevent EmptyHeader and related…
Browse files Browse the repository at this point in the history
… errors (#197)
  • Loading branch information
spencerkclark authored and Spencer Hill committed Aug 31, 2017
1 parent 253f1c4 commit ce7c784
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 14 additions & 2 deletions aospy/automate.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,20 +295,32 @@ def _exec_calcs(calcs, parallelize=False, client=None, **compute_kwargs):
def func(calc):
"""Wrap _compute_or_skip_on_error to require only the calc
argument"""
if 'write_to_tar' in compute_kwargs:
compute_kwargs['write_to_tar'] = False
return _compute_or_skip_on_error(calc, compute_kwargs)

if client is None:
n_workers = _n_workers_for_local_cluster(calcs)
with distributed.LocalCluster(n_workers=n_workers) as cluster:
with distributed.Client(cluster) as client:
return _submit_calcs_on_client(calcs, client, func)
result = _submit_calcs_on_client(calcs, client, func)
else:
return _submit_calcs_on_client(calcs, client, func)
result = _submit_calcs_on_client(calcs, client, func)
if compute_kwargs['write_to_tar']:
_serial_write_to_tar(calcs)
return result
else:
return [_compute_or_skip_on_error(calc, compute_kwargs)
for calc in calcs]


def _serial_write_to_tar(calcs):
for calc in calcs:
if calc.proj.tar_direc_out:
for dtype_out_time in calc.dtype_out_time:
calc._write_to_tar(dtype_out_time)


def _print_suite_summary(calc_suite_specs):
"""Print summary of requested calculations."""
return ('\nRequested aospy calculations:\n' +
Expand Down
3 changes: 3 additions & 0 deletions docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ Bug Fixes
- Retain original input data's mask during gridpoint-by-gridpoint
temporal averages (fixes :issue:`193` via :pull:`196`). By `Spencer
Hill <https://github.com/spencerahill>`_.
- Always write output to a tar file in serial to prevent empty header file
errors (fixes :issue:`75` via :pull:`197`). By `Spencer Clark
<https://github.com/spencerkclark>`_

.. _whats-new.0.1.2:

Expand Down

0 comments on commit ce7c784

Please sign in to comment.