Skip to content

Commit

Permalink
fix singlefiledata and some names (stfc#116)
Browse files Browse the repository at this point in the history
* fix singlefiledata and some names

* Revert changes not to singlefiledata filenames

This reverts commit 87444c1.

---------

Co-authored-by: ElliottKasoar <[email protected]>
  • Loading branch information
federicazanca and ElliottKasoar authored May 1, 2024
1 parent 7c7d34a commit c4fac19
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions aiida_mlip/parsers/base_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def parse(self, **kwargs) -> int:
self.retrieved.open(log_output, "rb") as log,
self.retrieved.open(output_filename, "rb") as output,
):
self.out("log_output", SinglefileData(file=log))
self.out("std_output", SinglefileData(file=output))
self.out("log_output", SinglefileData(file=log, filename=log_output))
self.out(
"std_output", SinglefileData(file=output, filename=output_filename)
)

return ExitCode(0)
6 changes: 3 additions & 3 deletions aiida_mlip/parsers/md_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def parse(self, **kwargs) -> ExitCode:
# Process trajectory file saving both the file and trajectory as aiida data
traj_filepath = md_dictionary.get("traj-file", MD.DEFAULT_TRAJ_FILE)
with self.retrieved.open(traj_filepath, "rb") as handle:
self.out("traj_file", SinglefileData(file=handle))
self.out("traj_file", SinglefileData(file=handle, filename=traj_filepath))
final_str, traj_output = xyz_to_aiida_traj(
Path(self.node.get_remote_workdir(), traj_filepath)
)
Expand All @@ -95,13 +95,13 @@ def parse(self, **kwargs) -> ExitCode:
# Process stats file as singlefiledata
stats_filepath = md_dictionary.get("stats-file", MD.DEFAULT_STATS_FILE)
with self.retrieved.open(stats_filepath, "rb") as handle:
self.out("stats_file", SinglefileData(file=handle))
self.out("stats_file", SinglefileData(file=handle, filename=stats_filepath))

# Process summary as both singlefiledata and results dictionary
summary_filepath = md_dictionary.get("summary", MD.DEFAULT_SUMMARY_FILE)
print(self.node.get_remote_workdir(), summary_filepath)
with self.retrieved.open(summary_filepath, "rb") as handle:
self.out("summary", SinglefileData(file=handle))
self.out("summary", SinglefileData(file=handle, filename=summary_filepath))

with self.retrieved.open(summary_filepath, "r") as handle:
try:
Expand Down
2 changes: 1 addition & 1 deletion aiida_mlip/parsers/opt_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def parse(self, **kwargs) -> ExitCode:

# Parse the trajectory file and save it as `SingleFileData`
with self.retrieved.open(traj_file, "rb") as handle:
self.out("traj_file", SinglefileData(file=handle))
self.out("traj_file", SinglefileData(file=handle, filename=traj_file))
# Parse trajectory and save it as `TrajectoryData`
opt, traj_output = xyz_to_aiida_traj(
Path(self.node.get_remote_workdir(), traj_file)
Expand Down
2 changes: 1 addition & 1 deletion aiida_mlip/parsers/sp_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def parse(self, **kwargs) -> int:
self.logger.info(f"Parsing '{xyz_output}'")

with self.retrieved.open(xyz_output, "rb") as handle:
self.out("xyz_output", SinglefileData(file=handle))
self.out("xyz_output", SinglefileData(file=handle, filename=xyz_output))

content = read(Path(self.node.get_remote_workdir(), xyz_output))
results = convert_numpy(content.todict())
Expand Down
1 change: 1 addition & 0 deletions tests/calculations/test_geomopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def test_run_opt(model_folder, janus_code):
assert "traj_file" in result
assert result["traj_output"].numsteps == 3
assert result["final_structure"].cell[0][1] == pytest.approx(2.8442048309822)
assert result["xyz_output"].filename == "aiida-results.xyz"


def test_example_opt(example_path):
Expand Down

0 comments on commit c4fac19

Please sign in to comment.