Skip to content

Commit

Permalink
Merge afb7ae8 into 4674dcb
Browse files Browse the repository at this point in the history
  • Loading branch information
ssomnath committed Apr 7, 2020
2 parents 4674dcb + afb7ae8 commit edc1324
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyUSID/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = '0.0.8'
version = '0.0.8.1'
time = '2020-01-14 11:20:25'
6 changes: 3 additions & 3 deletions pyUSID/io/hdf_utils/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ def validate_anc_h5_dsets(h5_inds, h5_vals, main_shape, is_spectroscopic=True):
if h5_inds.shape != h5_vals.shape:
raise ValueError('h5_inds: {} and h5_vals: {} should be of the same '
'shape'.format(h5_inds.shape, h5_vals.shape))
print(main_shape)
if isinstance(main_shape, (list, tuple)):
if not contains_integers(main_shape, min_val=1) or \
len(main_shape) != 2:
Expand Down Expand Up @@ -802,8 +801,9 @@ def create_results_group(h5_main, tool_name, h5_parent_group=None):
# this are NOT being used right now but will be in the subsequent versions of pyUSID
write_simple_attrs(h5_group, {'tool': tool_name, 'num_source_dsets': 1})
# in this case, there is only one source
for dset_ind, dset in enumerate([h5_main]):
h5_group.attrs['source_' + '{:03d}'.format(dset_ind)] = dset.ref
if h5_parent_group.file == h5_main.file:
for dset_ind, dset in enumerate([h5_main]):
h5_group.attrs['source_' + '{:03d}'.format(dset_ind)] = dset.ref

return h5_group

Expand Down
16 changes: 14 additions & 2 deletions pyUSID/processing/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from .comp_utils import parallel_compute, get_MPI, group_ranks_by_socket, \
get_available_memory
from ..io.hdf_utils import check_if_main, check_for_old, get_attributes
from ..io.hdf_utils import check_if_main, check_for_old, write_simple_attrs
from ..io.usi_data import USIDataset
from ..io.dtype_utils import integers_to_slices, lazy_load_array, \
validate_single_string_arg
Expand Down Expand Up @@ -276,7 +276,7 @@ def __init__(self, h5_main, process_name, parms_dict=None, cores=None,

if self.mpi_rank == 0:
print('Consider calling test() to check results before calling compute() which computes on the entire'
' dataset and writes back to the HDF5 file')
' dataset and writes results to the HDF5 file')

self.duplicate_h5_groups, self.partial_h5_groups = self._check_for_duplicates()

Expand Down Expand Up @@ -771,6 +771,17 @@ def __create_compute_status_dataset(self):
if completed_pixels > 0:
self._h5_status_dset[:completed_pixels] = 1

def _write_source_dset_provenance(self):
"""
Writes path of HDF5 file and path of h5_main to the results group
if results are being written to a new HDF5 file
"""
if self.h5_main.file == self.h5_results_grp.file:
return
write_simple_attrs(self.h5_results_grp,
{'source_file_path': self.h5_main.file.filename,
'source_dataset_path': self.h5_main.name})

def _get_existing_datasets(self):
"""
The purpose of this function is to allow processes to resume from partly computed results
Expand Down Expand Up @@ -892,6 +903,7 @@ def get_cycles(self):
if self.verbose and self.mpi_rank == 0:
print('Creating HDF5 group and datasets to hold results')
self._create_results_datasets()
self._write_source_dset_provenance()
else:
# resuming from previous checkpoint
resuming = True
Expand Down

0 comments on commit edc1324

Please sign in to comment.