Skip to content

Commit

Permalink
fix: ram units (#3730)
Browse files Browse the repository at this point in the history
* fix: ram units

* chore: adding changelog file 3730.fixed.md [dependabot-skip]

---------

Co-authored-by: pyansys-ci-bot <[email protected]>
  • Loading branch information
germa89 and pyansys-ci-bot authored Feb 10, 2025
1 parent e4e5ee2 commit 78a5ebc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/3730.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: ram units
6 changes: 3 additions & 3 deletions src/ansys/mapdl/core/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ def generate_mapdl_launch_command(
cpu_sw = "-np %d" % nproc

if ram:
ram_sw = "-m %d" % int(1024 * ram)
LOG.debug(f"Setting RAM: {ram_sw}")
ram_sw = "-m %d" % int(ram)
LOG.debug(f"Setting RAM: {ram_sw} MB")
else:
ram_sw = ""

Expand Down Expand Up @@ -1990,7 +1990,7 @@ def get_value(
ram = SLURM_MEM_PER_NODE

if not units:
args["ram"] = int(ram)
args["ram"] = int(ram) # Assuming in MB
elif units == "T": # tera
args["ram"] = int(ram) * (2**10) ** 2
elif units == "G": # giga
Expand Down
12 changes: 6 additions & 6 deletions tests/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ def test_generate_mapdl_launch_command_windows():
jobname = "myjob"
nproc = 10
port = 1000
ram = 2
ram = 2024
additional_switches = "-my_add=switch"

cmd = generate_mapdl_launch_command(
Expand All @@ -1022,7 +1022,7 @@ def test_generate_mapdl_launch_command_windows():
assert "-port" in cmd
assert f"{port}" in cmd
assert "-m" in cmd
assert f"{ram*1024}" in cmd
assert f"{ram}" in cmd
assert "-np" in cmd
assert f"{nproc}" in cmd
assert "-grpc" in cmd
Expand All @@ -1037,7 +1037,7 @@ def test_generate_mapdl_launch_command_windows():
assert f"{exec_file}" in cmd
assert f" -j {jobname} " in cmd
assert f" -port {port} " in cmd
assert f" -m {ram*1024} " in cmd
assert f" -m {ram} " in cmd
assert f" -np {nproc} " in cmd
assert " -grpc" in cmd
assert f" {additional_switches} " in cmd
Expand All @@ -1053,7 +1053,7 @@ def test_generate_mapdl_launch_command_linux():
jobname = "myjob"
nproc = 10
port = 1000
ram = 2
ram = 2024
additional_switches = "-my_add=switch"

cmd = generate_mapdl_launch_command(
Expand All @@ -1075,7 +1075,7 @@ def test_generate_mapdl_launch_command_linux():
assert "-port" in cmd
assert f"{port}" in cmd
assert "-m" in cmd
assert f"{ram*1024}" in cmd
assert f"{ram}" in cmd
assert "-np" in cmd
assert f"{nproc}" in cmd
assert "-grpc" in cmd
Expand All @@ -1091,7 +1091,7 @@ def test_generate_mapdl_launch_command_linux():
assert f"{exec_file} " in cmd
assert f" -j {jobname} " in cmd
assert f" -port {port} " in cmd
assert f" -m {ram*1024} " in cmd
assert f" -m {ram} " in cmd
assert f" -np {nproc} " in cmd
assert " -grpc" in cmd
assert f" {additional_switches} " in cmd
Expand Down

0 comments on commit 78a5ebc

Please sign in to comment.