Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real time analysis dynamic naming from reporter #565

Merged
merged 3 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions openmmtools/multistate/multistatereporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,8 +1323,10 @@ def write_current_statistics(self, data):
data: dict
Dictionary with the key, value pairs to store in YAML format.
"""
reporter_dir, _ = os.path.split(self._storage_analysis_file_path)
output_filepath = f"{reporter_dir}/real_time_analysis.yaml"
reporter_dir, reporter_filename = os.path.split(self._storage_analysis_file_path)
# remove extension from filename
yaml_prefix = os.path.splitext(reporter_filename)[0]
output_filepath = f"{reporter_dir}/{yaml_prefix}_real_time_analysis.yaml"
# Remove if it is a fresh reporter session
if self._overwrite_statistics:
try:
Expand Down
7 changes: 5 additions & 2 deletions openmmtools/tests/test_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1506,8 +1506,11 @@ def test_real_time_analysis_yaml(self):
# Run
sampler.run()
# load file and check number of iterations
storage_dir, _ = os.path.split(sampler._reporter._storage_analysis_file_path)
with open(f"{storage_dir}/real_time_analysis.yaml") as yaml_file:
storage_dir, reporter_filename = os.path.split(sampler._reporter._storage_analysis_file_path)
# remove extension from filename
yaml_prefix = os.path.splitext(reporter_filename)[0]
output_filepath = f"{storage_dir}/{yaml_prefix}_real_time_analysis.yaml"
with open(f"{storage_dir}/{yaml_prefix}_real_time_analysis.yaml") as yaml_file:
yaml_contents = yaml.safe_load(yaml_file)
# Make sure we get the correct number of entries
assert len(yaml_contents) == expected_yaml_entries, \
Expand Down