Skip to content

Commit

Permalink
Generate unique entry_id using date time and hash of final structure.
Browse files Browse the repository at this point in the history
Fixes #4259
  • Loading branch information
shyuep committed Jan 23, 2025
1 parent 876b999 commit a4ee88c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/pymatgen/io/vasp/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from collections import defaultdict
from collections.abc import Iterable
from dataclasses import dataclass
from datetime import datetime, timezone
from glob import glob
from io import StringIO
from pathlib import Path
Expand Down Expand Up @@ -868,7 +867,11 @@ def get_computed_entry(
ComputedStructureEntry/ComputedEntry
"""
if entry_id is None:
entry_id = f"vasprun-{datetime.now(tz=timezone.utc)}"
calc_date = re.sub(" ", "", self.generator["DATE"])
calc_time = self.generator["TIME"]
hashed_structure = hash(str(self.final_structure))

entry_id = f"vasprun-{calc_date}-{calc_time}-{hashed_structure}"
param_names = {
"is_hubbard",
"hubbards",
Expand Down
4 changes: 3 additions & 1 deletion tests/io/vasp/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@ def test_standard(self):
assert dct["nelements"] == 4

entry = vasp_run.get_computed_entry(inc_structure=True)
assert entry.entry_id.startswith("vasprun")

assert entry.entry_id == "vasprun-20100729-15.0-5360923159595666479"

assert entry.parameters["run_type"] == "PBEO or other Hybrid Functional"

def test_unconverged(self):
Expand Down

0 comments on commit a4ee88c

Please sign in to comment.