Skip to content

Commit

Permalink
Added backwards compatibility for deprecated pymatgen.core.units.Memo…
Browse files Browse the repository at this point in the history
…ry.from_string method (#284)
  • Loading branch information
SurgeArrester authored Feb 6, 2024
1 parent 62d10b9 commit 170508a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion abipy/flowtk/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -2498,7 +2498,11 @@ def make_tarfile(self, name=None, max_filesize=None, exclude_exts=None, exclude_
def any2bytes(s):
"""Convert string or number to memory in bytes."""
if is_string(s):
return int(Memory.from_string(s).to("b"))
# Support for deprecated pymatgen API
try:
mem = int(Memory.from_string(s).to("b"))
except:
mem = int(Memory.from_str(s).to("b"))
else:
return int(s)

Expand Down
7 changes: 6 additions & 1 deletion abipy/flowtk/qadapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ def __init__(self, **kwargs):

# Convert memory to megabytes.
m = str(kwargs.pop("mem_per_node"))
self.mem_per_node = int(Memory.from_string(m).to("Mb"))

# Support for old pymatgen API
try:
self.mem_per_node = int(Memory.from_string(m).to("Mb"))
except:
self.mem_per_node = int(Memory.from_str(m).to("Mb"))

if self.mem_per_node <= 0 or self.sockets_per_node <= 0 or self.cores_per_socket <= 0:
raise ValueError("invalid parameters: %s" % kwargs)
Expand Down

0 comments on commit 170508a

Please sign in to comment.