Skip to content

Ms endorse#195

Open
jbrezmorf wants to merge 18 commits intomasterfrom
MS_endorse
Open

Ms endorse#195
jbrezmorf wants to merge 18 commits intomasterfrom
MS_endorse

Conversation

@jbrezmorf
Copy link
Collaborator

Various changes made during application to the Endorse software.

res = np.array(res)
fine_coarse_res = res[:, 1]

result_type = np.dtype((np.float, np.array(fine_coarse_res[0]).shape))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason: float seems to be incompatible with new Numpy versions

for i_level in range(len(self._hdf_object.level_parameters)):
self._level_groups.append(self._hdf_object.add_level_group(str(i_level)))

def _hdf_result_format(self, locations, times):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified, moved into hdf5.py as it is implementation detail how the format is stored.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moereover the format saving was wrong since it same format has been assumed for all dict elements.

Load result format
"""
results_format = self._hdf_object.load_result_format()
quantities = []
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing, but using constructing function with named parameters.

for level, samples in successful_samples.items():
if len(samples) > 0:
self._level_groups[level].append_successful(np.array(samples))
ids, sample_values = zip(*samples)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to make pairs here and convert to numpy arrays just before storage.

except Exception:
str_list = traceback.format_exception(*sys.exc_info())
err_msg = "".join(str_list)
print(err_msg)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: replace by suitable logging? Only in case of debugging turned on.
Problem is that the exceptions may not be propagated to the Sampler if pool somehow fail. So it would be great to log the exception within the sampling job process.

if not os.path.isdir(sample_dir):
os.makedirs(sample_dir, mode=0o775, exist_ok=True)

# We have observed possible problems with directory creation on the
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guessed that there is some problem with NFS, however in fact there was probably problem with various threads writing to the same directory, randomly cleaning it after it was created.
I suggest to keep the code commented, it allows to better check that we are able to write into the directory. There could be problem with rights anyway.

self._save_running_time(level_sim._level_id, running_time)

if not err_msg:
self._queues.setdefault(level_sim._level_id, queue.Queue()).put((sample_id, (result[0], result[1])))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to improve readibility

Execute pbs script
:return: None
"""
if len(self._scheduled) > 0:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decrease indention level

pbs_process.write_pbs_id(pbs_id)

process = subprocess.run(['qsub', job_file], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
try:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quite didn't get reason for this try block. What is reason for PIPEs? I propose to just let subproces.run finish and take resulting stdout and stderr.

import time
import logging

class FileSafe(h5py.File):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context manager to open the file with some timeout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants