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

Backwards compatibility for deprecated pymatgen.core.units.Memory.from_string #284

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading